platform/kernel/u-boot.git
3 years agox86: tsc: Rename X86_TSC_TIMER_EARLY_FREQ to X86_TSC_TIMER_FREQ
Bin Meng [Wed, 28 Jul 2021 04:00:22 +0000 (12:00 +0800)]
x86: tsc: Rename X86_TSC_TIMER_EARLY_FREQ to X86_TSC_TIMER_FREQ

Currently there are two places to specify the x86 TSC timer frequency
with one in Kconfig used for early timer and the other one in device
tree used when the frequency cannot be determined from hardware.

This may potentially create an inconsistent config where the 2 values
do not match. Let's use the one specified in Kconfig in the device
tree as well.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agox86: kconfig: Drop ROM_NEEDS_BLOBS and BUILD_ROM
Bin Meng [Tue, 27 Jul 2021 15:15:39 +0000 (23:15 +0800)]
x86: kconfig: Drop ROM_NEEDS_BLOBS and BUILD_ROM

These 2 options are no longer needed as now binman is used to build
u-boot.rom.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agox86: crownbay: Adjust VGA rom address
Bin Meng [Tue, 27 Jul 2021 13:30:02 +0000 (21:30 +0800)]
x86: crownbay: Adjust VGA rom address

binman complains when binary blobs are present:

  Node '/binman/rom/intel-vga': Offset 0xfff90000 (4294508544) overlaps
  with previous entry '/binman/rom/u-boot-dtb-with-ucode' ending at
  0xfff9204c (4294516812)

Adjust VGA rom address to 0xfffa0000 so that u-boot.rom image can be
successfully built again.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agox86: tangier: Fix DMA controller IRQ polarity in CSRT
Andy Shevchenko [Fri, 30 Jul 2021 20:15:44 +0000 (23:15 +0300)]
x86: tangier: Fix DMA controller IRQ polarity in CSRT

IRQ polarity in CSRT has the same definition as by ACPI specification
chapter 19.6.64 "Interrupt (Interrupt Resource Descriptor Macro)", i.e.
ActiveHigh is 0, and ActiveLow is 1. On Intel Tangier the DMA controller
IRQ polarity is ActiveHigh.

Note, in DSDT (see southcluster.asl) it's described correctly.

Fixes: 5e99fde34a77 ("x86: tangier: Populate CSRT for shared DMA controller")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agox86: dts: Add "m25p,fast-read" to SPI flash node
Bin Meng [Thu, 29 Jul 2021 12:18:23 +0000 (20:18 +0800)]
x86: dts: Add "m25p,fast-read" to SPI flash node

Except ICH7 SPI, all SPI flashes connected to ICH9 / Fast SPI should
have "m25p,fast-read" property present in their DT nodes.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agox86: crownbay: Disable CONFIG_SPI_FLASH_SMART_HWCAPS
Bin Meng [Wed, 28 Jul 2021 10:28:57 +0000 (18:28 +0800)]
x86: crownbay: Disable CONFIG_SPI_FLASH_SMART_HWCAPS

Since commit 71025f013ccb ("mtd: spi-nor-core: Rework hwcaps selection")
SPI flash on Intel Crown Bay board does not work anymore.

Disable CONFIG_SPI_FLASH_SMART_HWCAPS until a proper fix is made to
the spi-nor core.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agospi: ich: Limit slave->max_read_size
Bin Meng [Wed, 28 Jul 2021 10:28:56 +0000 (18:28 +0800)]
spi: ich: Limit slave->max_read_size

Since commit 43c145b8b3ee ("spi: ich: Correct max-size bug in ich_spi_adjust_size()")
(in v2020.04-rc1), SPI flash read no longer works with ICH SPI controller
in software sequencer mode.

ICH controller can only transfer a small number of bytes at once.
Before commit 43c145b8b3ee, the logic happens to make sure data.nbytes
is limited to slave->max_write_size but after commit 43c145b8b3ee
data.nbytes is no longer limited because slave->max_read_size is not
initialized with a valid number.

Fixes: 43c145b8b3ee ("spi: ich: Correct max-size bug in ich_spi_adjust_size()")
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoMerge https://source.denx.de/u-boot/custodians/u-boot-sunxi
Tom Rini [Sun, 1 Aug 2021 00:51:24 +0000 (20:51 -0400)]
Merge https://source.denx.de/u-boot/custodians/u-boot-sunxi

- Move the PSCI runtime code for H3/A23/A33 into SRAM
- Pick the environment from the actual MMC boot device (SD card vs.
  eMMC)
- Plus a small improvement from Icenowy, just for good measure.

3 years agosunxi: decide the inclusion of SCP by SCP_ADDR existence
Icenowy Zheng [Thu, 22 Jul 2021 06:30:03 +0000 (14:30 +0800)]
sunxi: decide the inclusion of SCP by SCP_ADDR existence

There are more Allwinner SoCs that do not have a SCP now.

When there's no SCP_ADDR macro defined, we can assume there's no SCP
available.

Drop the scp part of FIT description when SCP_ADDR does not exist.

Signed-off-by: Icenowy Zheng <icenowy@sipeed.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
3 years agosunxi: A23/A33/H3: Move sun8i secure monitor to SRAM A2
Samuel Holland [Mon, 19 Apr 2021 03:21:41 +0000 (22:21 -0500)]
sunxi: A23/A33/H3: Move sun8i secure monitor to SRAM A2

So far for the H3, A23, and A33 SoCs, we use DRAM to hold the secure
monitor code (providing PSCI runtime services). And while those SoCs do
not have the secure SRAM B like older SoCs, there is enough (secure)
SRAM A2 to put the monitor code and data in there instead.

Follow the design of 64-bit SoCs and use the first part for the monitor,
and the last 16 KiB for the SCP firmware. With this change, the monitor
no longer needs to reserve a region in DRAM.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
[Andre: amend commit message, fix R40 and V3s build]
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
3 years agosunxi: Select environment MMC based on boot device
Samuel Holland [Mon, 19 Apr 2021 03:16:21 +0000 (22:16 -0500)]
sunxi: Select environment MMC based on boot device

Currently, the environment is always stored in eMMC if eMMC is enabled
in the config. This means images written to SD and eMMC will cross-
contaminate their environments unless the configuration is changed.

By dropping the device number from the environment location string and
implementing mmc_get_env_dev, we will always use the environment from
the boot device when booting from SD/eMMC.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
3 years agoMerge https://source.denx.de/u-boot/custodians/u-boot-marvell
Tom Rini [Sat, 31 Jul 2021 12:18:14 +0000 (08:18 -0400)]
Merge https://source.denx.de/u-boot/custodians/u-boot-marvell

- kwboot / kwbimage improvements reducing image size (Pali & Marek)
- a37xx: pinctrl: Correct PWM pins definitions (Marek)
- Convert the Dreamplug Ethernet and SATA to Driver Model (Tony)
- serial: a37xx: DEBUG_UART improvements / fixes (Pali)

3 years agoserial: a37xx: Do not call get_ref_clk() in _debug_uart_init()
Pali Rohár [Mon, 26 Jul 2021 12:58:59 +0000 (14:58 +0200)]
serial: a37xx: Do not call get_ref_clk() in _debug_uart_init()

Static inline function _debug_uart_init() should avoid calling external
(non-inline) functions. Therefore do not call get_ref_clk() in
_debug_uart_init() and reimplement its functionality without external
function calls.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
3 years agoserial: a37xx: Use CONFIG_BAUDRATE for initializing early debug UART
Pali Rohár [Mon, 26 Jul 2021 12:58:58 +0000 (14:58 +0200)]
serial: a37xx: Use CONFIG_BAUDRATE for initializing early debug UART

CONFIG_BAUDRATE should be used for setting the baudrate for the early debug
UART. This replaces current hardcoded 115200 value.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behun <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
3 years agoarm: kirkwood: Dreamplug: Add DM SATA and remove IDE configs
Tony Dinh [Mon, 26 Jul 2021 06:01:20 +0000 (23:01 -0700)]
arm: kirkwood: Dreamplug: Add DM SATA and remove IDE configs

- Enable DM SATA, removed IDE driver, and add SATA MV driver.
- Use ethernet PHY names from device tree in default boot command

Signed-off-by: Tony Dinh <mibodhi@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
3 years agoarm: kirkwood: Dreamplug: Use Ethernet PHY name and address from device tree
Tony Dinh [Mon, 26 Jul 2021 06:01:19 +0000 (23:01 -0700)]
arm: kirkwood: Dreamplug: Use Ethernet PHY name and address from device tree

In DM Ethernet, the old "egiga0" and 'egiga1" names are no longer valid,
so replace these with Ethernet PHY names from device tree. Also, read
Ethernet PHY address for each port from device tree.

Signed-off-by: Tony Dinh <mibodhi@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
3 years agoarm: kirkwood: Dreamplug: Add DM Ethernet and DM SATA configs
Tony Dinh [Mon, 26 Jul 2021 06:01:18 +0000 (23:01 -0700)]
arm: kirkwood: Dreamplug: Add DM Ethernet and DM SATA configs

Add DM_ETH, SATA_MV and associated configs to dreamplug_defconfig

Signed-off-by: Tony Dinh <mibodhi@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
3 years agoarm64: a37xx: pinctrl: Correct PWM pins definitions
Marek Behún [Fri, 23 Jul 2021 17:57:11 +0000 (19:57 +0200)]
arm64: a37xx: pinctrl: Correct PWM pins definitions

The PWM pins on North Bridge on Armada 37xx can be configured into PWM
or GPIO functions. When in PWM function, each pin can also be configured
to drive low on 0 and tri-state on 1 (LED mode).

The current definitions handle this by declaring two pin groups for each
pin:
- group "pwmN" with functions "pwm" and "gpio"
- group "ledN_od" ("od" for open drain) with functions "led" and "gpio"

This is semantically incorrect. The correct definition for each pin
should be one group with three functions: "pwm", "led" and "gpio".

Change the "pwmN" groups to support "led" function.

Remove "ledN_od" groups. This cannot break backwards compatibility with
older device trees: no device tree uses it since there is no PWM driver
for this SOC yet. Also "ledN_od" groups are not even documented.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
3 years agokwbimage: Update help message about how to extract from an existing image
Pali Rohár [Fri, 23 Jul 2021 09:14:35 +0000 (11:14 +0200)]
kwbimage: Update help message about how to extract from an existing image

Extracting is now supported by dumpimage, so mention it in help instead
of `kwbimage -x`.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
3 years agokwbimage: Add support for extracting images via dumpimage tool
Pali Rohár [Fri, 23 Jul 2021 09:14:34 +0000 (11:14 +0200)]
kwbimage: Add support for extracting images via dumpimage tool

The kwbimage library does not support extracting subimages. Implement it.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
3 years agoarm: mvebu: gdsys: Remove custom spl_board_init()
Pali Rohár [Fri, 23 Jul 2021 09:14:33 +0000 (11:14 +0200)]
arm: mvebu: gdsys: Remove custom spl_board_init()

The gdsys a38x config file (controlcenterdc_defconfig) uses BootROM to
load U-Boot proper.

Since it is now possible to do this via U-Boot SPL framework, we do not
need to provide custom spl_board_init() which calls return_to_bootrom().

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
3 years agoarm: mvebu: Remove unused macro CONFIG_SYS_U_BOOT_OFFS
Pali Rohár [Fri, 23 Jul 2021 09:14:32 +0000 (11:14 +0200)]
arm: mvebu: Remove unused macro CONFIG_SYS_U_BOOT_OFFS

Macro CONFIG_SYS_U_BOOT_OFFS is set but not used anymore. Remove it.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
3 years agotools: kwbimage: Remove v1 kwbimage SPL padding to CONFIG_SYS_U_BOOT_OFFS bytes
Pali Rohár [Fri, 23 Jul 2021 09:14:31 +0000 (11:14 +0200)]
tools: kwbimage: Remove v1 kwbimage SPL padding to CONFIG_SYS_U_BOOT_OFFS bytes

This padding depends on board config file and therefore it makes the
mkimage binary tool board specific, which is not correct. One cannot use
mkimage tool built as a result for board A to generate images for board
B, even if both A and B are on the same platform.

This CONFIG_SYS_U_BOOT_OFFS padding was needed when kwbimage v1 contained
SPL code which loaded U-Boot proper based on CONFIG_SYS_U_BOOT_OFFS,
instead of reading correct offset from kwbimage header.

Now that SPL code parses kwbimage header and deterinate correct offset,
there is no need for this CONFIG_SYS_U_BOOT_OFFS padding anymore.

By removing it we also reduce the size of SPL code and therefore also
decrease the final size of v1 kwbimage. This means there is more space
for U-Boot proper binary.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
3 years agoarm: mvebu: Remove legacy U-Boot header from kwbimage v1 files
Pali Rohár [Fri, 23 Jul 2021 09:14:30 +0000 (11:14 +0200)]
arm: mvebu: Remove legacy U-Boot header from kwbimage v1 files

The SPL code now already parses kwbimage v1 headers where all necessary
information about how to load and execute U-Boot proper is present. The
legacy 64-byte U-Boot header is not used anymore.

Remove this 64-byte header by putting u-boot.bin binary (instead of
u-boot.img) into kwbimage v1 and let SPL code or BootROM to load U-Boot
directly at its execution address.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
3 years agoarm: mvebu: Load U-Boot proper binary in SPL code based on kwbimage header
Pali Rohár [Fri, 23 Jul 2021 09:14:29 +0000 (11:14 +0200)]
arm: mvebu: Load U-Boot proper binary in SPL code based on kwbimage header

Now that proper load and execution addresses are set in v1 kwbimage we
can use it for loading and booting U-Boot proper.

Use the new spl_parse_board_header() function to implement parsing the
kwbimage v1 header. Use information from this header to locate offset and
size of the U-Boot proper binary, instead of using the legacy U-Boot
header which is prepended to the U-Boot proper binary stored at fixed
offset. This has the advantage that we do not need to relay on legacy
U-Boot header anymore and therefore U-Boot proper binary can be stored at
any offset, as is the case when loading & booting U-Boot proper by
BootROM. The CONFIG_SYS_U_BOOT_OFFS option is therefore not used by SPL
code anymore.

Also allow to compile U-Boot SPL without CONFIG_SPL_SPI_FLASH_SUPPORT,
CONFIG_SPL_MMC_SUPPORT or CONFIG_SPL_SATA_SUPPORT set. In this case
BootROM is used for loading and executing U-Boot proper. This reduces the
size of U-Boot's SPL image. By default these config options are enabled
and so BootROM loading is not used. In some cases BootROM reads from SPI
NOR at lower speed than U-Boot SPL. So people can decide whether they
want to have smaller SPL binary at the cost of slower boot.

Therefore dependency on CONFIG_SPL_DM_SPI, CONFIG_SPL_SPI_FLASH_SUPPORT,
CONFIG_SPL_SPI_LOAD, CONFIG_SPL_SPI_SUPPORT, CONFIG_SPL_DM_GPIO,
CONFIG_SPL_DM_MMC, CONFIG_SPL_GPIO_SUPPORT, CONFIG_SPL_LIBDISK_SUPPORT,
CONFIG_SPL_MMC_SUPPORT, CONFIG_SPL_SATA_SUPPORT and
CONFIG_SPL_LIBDISK_SUPPORT is changed from strict to related "imply"
(which can be selectivelly turned off and causes booting via BootROM).

Options CONFIG_SYS_SPI_U_BOOT_OFFS,
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR and
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET have to to be set to
zero as they define the location where kwbimage header starts. It is the
location where BootROM expects start of the kwbimage from which it reads,
parses and executes SPL part. The same applies to option
CONFIG_SPL_SATA_RAW_U_BOOT_SECTOR, which has to be set to one.

Update all config files to set correct values of these options and set
CONFIG_SYS_U_BOOT_OFFS to the correct value - the offset where U-Boot
proper starts.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
3 years agoSPL: Add support for parsing board / BootROM specific image types
Pali Rohár [Fri, 23 Jul 2021 09:14:28 +0000 (11:14 +0200)]
SPL: Add support for parsing board / BootROM specific image types

Platform specific BootROM may use its own image type for loading SPL or
U-Boot proper. In some cases it makes sense to not use BootROM supplied
code for booting U-Boot proper but rather to use U-Boot SPL for this,
e.g. when U-Boot SPL can load U-Boot proper faster than BootROM. In this
case it is required for platform board code to parse and load U-Boot in
BootROM specific image type.

This change adds support for parsing platform / board / BootROM specific
image types via weak function spl_parse_board_header() which is called
before marking boot image as a raw.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
3 years agoSPL: Add support for specifying offset between header and image
Pali Rohár [Fri, 23 Jul 2021 09:14:27 +0000 (11:14 +0200)]
SPL: Add support for specifying offset between header and image

Some image types (e.g. kwbimage v1) store the offset to SPL binary and
offset to U-Boot proper binary in their headers. To avoid reading SPL
binary when loading U-Boot proper, add support for specifying offset in
struct spl_image_info, which defines the offset from the beginning of
the header and the beginning of the executable data.

Initial support is added only for SPI, MMC and SATA code. We can extend
it later if needed.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
3 years agoarm: mvebu: Use U-Boot's SPL BootROM framework for booting from NAND/UART
Pali Rohár [Fri, 23 Jul 2021 09:14:26 +0000 (11:14 +0200)]
arm: mvebu: Use U-Boot's SPL BootROM framework for booting from NAND/UART

Current code uses hack in board_init_f() which calls return_to_bootrom()
to skip U-Boot SPL code and return back to BootROM to load U-Boot via
UART or from NAND.

This change migrates that hack from the board_init_f() function and
changes it to return BOOT_DEVICE_BOOTROM instead of returning to BootROM
directly, so that U-Boot's SPL framework is used for returning to
BootROM.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agoarm: mvebu: Implement return_to_bootrom() via U-Boot's SPL framework
Pali Rohár [Fri, 23 Jul 2021 09:14:25 +0000 (11:14 +0200)]
arm: mvebu: Implement return_to_bootrom() via U-Boot's SPL framework

U-Boot's SPL framework already has an API for loading U-Boot via
BootROM.

Implement the function board_return_to_bootrom() for mvebu SPL code.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agoarm: mvebu: Mark return_to_bootrom() as a noreturn function
Pali Rohár [Fri, 23 Jul 2021 09:14:24 +0000 (11:14 +0200)]
arm: mvebu: Mark return_to_bootrom() as a noreturn function

This function does not return, so add the appropriate compiler flag.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agoarm: mvebu: Fix return_to_bootrom()
Pali Rohár [Fri, 23 Jul 2021 09:14:23 +0000 (11:14 +0200)]
arm: mvebu: Fix return_to_bootrom()

Register r0 should be set to return value 0x0 - NO_ERR.

Set r0 with return value after all registers are restored from the
stack, so that the return value is always correct.

Signed-off-by: Pali Rohár <pali@kernel.org>
Fixes: 944c7a317675 ("arm: mvebu: Add option to use UART xmodem protocol via kwboot")
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agotools: kwboot: Fix checking image header version
Pali Rohár [Fri, 23 Jul 2021 09:14:22 +0000 (11:14 +0200)]
tools: kwboot: Fix checking image header version

Function image_version() returns unsigned value, so it can never be
negative. Explicitly check for two supported image versions: v0 and v1.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
3 years agotools: kwboot: Check for v1 header size
Pali Rohár [Fri, 23 Jul 2021 09:14:21 +0000 (11:14 +0200)]
tools: kwboot: Check for v1 header size

Too small invalid headers may cause kwboot to crash.
Check for header size of v1 images.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agotools: kwboot: Cosmetic fix - add missing curly brackets
Pali Rohár [Fri, 23 Jul 2021 09:14:20 +0000 (11:14 +0200)]
tools: kwboot: Cosmetic fix - add missing curly brackets

Add missing curly brackets for this else statement.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agotools: kwboot: Print trailing newline after terminal is terminated
Pali Rohár [Fri, 23 Jul 2021 09:14:19 +0000 (11:14 +0200)]
tools: kwboot: Print trailing newline after terminal is terminated

Print trailing newline as the last printed byte can be something
different.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agotools: kwboot: Fix restoring terminal
Pali Rohár [Fri, 23 Jul 2021 09:14:18 +0000 (11:14 +0200)]
tools: kwboot: Fix restoring terminal

Call tcsetattr() only if the file descriptor is valid. It may be
invalidated by previous lines (if it is not a tty descriptor).

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agotools: kwboot: Fix wrong parameter passed to read()
Pali Rohár [Fri, 23 Jul 2021 09:14:17 +0000 (11:14 +0200)]
tools: kwboot: Fix wrong parameter passed to read()

The 'buf' variable is a pointer and '_buf' is the array itself.
Therefore we should pass sizeof(_buf) instead of sizeof(buf) to read().

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agotools: dumpimage: Show error message when trying to extract data from kwbimage
Pali Rohár [Fri, 23 Jul 2021 09:14:16 +0000 (11:14 +0200)]
tools: dumpimage: Show error message when trying to extract data from kwbimage

There is no code for extracting data from kwbimage, so show an error
message when user tries this via e.g. dumpimage call:
  ./tools/dumpimage -T kwbimage -o /tmp/out u-boot-spl.kwb

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
3 years agotools: dumpimage: Fix crashing when trying to extract data from kwbimage
Pali Rohár [Fri, 23 Jul 2021 09:14:15 +0000 (11:14 +0200)]
tools: dumpimage: Fix crashing when trying to extract data from kwbimage

Trying to call the following command causes NULL pointer dereference in
strlen():
  ./tools/dumpimage -T kwbimage -o /tmp/out u-boot-spl.kwb

Fix it by checking whether params->imagename is non-NULL before calling
strlen().

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
3 years agotools: kwbimage: Mark all BootROM structures __packed
Pali Rohár [Fri, 23 Jul 2021 09:14:14 +0000 (11:14 +0200)]
tools: kwbimage: Mark all BootROM structures __packed

These structures must have specific size without padding, so mark them as
packed via the de-facto standard macro __packed. Also replace PACKED
macro.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
3 years agotools: kwbimage: Do not hide usage of secure header under CONFIG_ARMADA_38X
Pali Rohár [Fri, 23 Jul 2021 09:14:13 +0000 (11:14 +0200)]
tools: kwbimage: Do not hide usage of secure header under CONFIG_ARMADA_38X

The mkimage host tool can be used to generate kwbimage v1 image with
secure header on host system for A38x plaform also when U-Boot is being
compiled for different platform. So there is no reason to not allow
compiling of mkimage/kwbimage with secure header support for e.g. x86-64
host.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agotools: kwbimage: Add support for a new DATA_DELAY command
Pali Rohár [Fri, 23 Jul 2021 09:14:12 +0000 (11:14 +0200)]
tools: kwbimage: Add support for a new DATA_DELAY command

This command is supported only by v1 images and specifies a milliseconds
delay after executing some set of DATA commands. The special string value
SDRAM_SETUP instructs BootROM to setup SDRAM controller instead of
executing delay. SDRAM_SETUP may be specified only once and after the
last DATA command.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agotools: kwbimage: Add support for DATA command also for v1 images
Pali Rohár [Fri, 23 Jul 2021 09:14:11 +0000 (11:14 +0200)]
tools: kwbimage: Add support for DATA command also for v1 images

The DATA command is already supported by mkimage for v0 images, but not
for v1 images.

BootROM code which executes v1 images also supports DATA command via an
optional extended v1 header OPT_HDR_V1_REGISTER_TYPE.

Implement support for DATA command for v1 images.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agotools: kwbimage: Don't parse PAYLOAD keyword
Pali Rohár [Fri, 23 Jul 2021 09:14:10 +0000 (11:14 +0200)]
tools: kwbimage: Don't parse PAYLOAD keyword

The PAYLOAD keyword does nothing. No code is using it and both mkimage
and kwbimage completely ignore it. It looks like a relict from the past.
The payload image itself can be specified only via -d parameter to
mkimage.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agotools: kwbimage: Add support for more BINARY headers
Pali Rohár [Fri, 23 Jul 2021 09:14:09 +0000 (11:14 +0200)]
tools: kwbimage: Add support for more BINARY headers

The kwbimage v1 format supports multiple BINARY executable headers.
Add support for it into mkimage/kwbimage tool.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agotools: kwbimage: Fix calculating size of binary header
Pali Rohár [Fri, 23 Jul 2021 09:14:08 +0000 (11:14 +0200)]
tools: kwbimage: Fix calculating size of binary header

Binary header consist of:
* 1 byte for header type
* 3 bytes for header size
* 1 byte for number of arguments
* 3 reserved bytes
* N*4 bytes for arguments
* M bytes (aligned to 4 bytes) for executable data
* 1 byte for information about next header
* 3 reserved bytes

The first four bytes are specified as
  sizeof(struct opt_hdr_v1)
and the remaining bytes as
  ALIGN(s.st_size, 4) + (binarye->binary.nargs + 2) * sizeof(uint32_t)

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
3 years agotools: kwbimage: Change maximum number of arguments in binary header to 256
Pali Rohár [Fri, 23 Jul 2021 09:14:07 +0000 (11:14 +0200)]
tools: kwbimage: Change maximum number of arguments in binary header to 256

The number is stored in one byte, so the maximum should be 255.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
3 years agotools: kwbimage: Use -a parameter (load address) for v1 images
Pali Rohár [Fri, 23 Jul 2021 09:14:06 +0000 (11:14 +0200)]
tools: kwbimage: Use -a parameter (load address) for v1 images

The data part of v1 kwbimage currently contains U-Boot binary prepended
by 64 bytes long Legacy U-Boot image header. This means that the load
address is currently substracted by 64 bytes to ensure that U-Boot's
entry point is at specified execution address.

As mkimage has already separate arguments for load (-a) and execution
(-e) address, there is no need to derive fixed load address from
execution address.

Therefore remove this load address hack from the kwbimage tool and
support generating v1 kwbimage with arbitrary addresses for load and
execution.

Finally, calculate correct load address by caller for mkimage tool in
Makefile. File u-boot-spl.kwb is always a v1 kwbimage and it is the only
v1 kwbimage which U-Boot's build system generates.

Remove also useless overwriting of destaddr for /binary.0 to the value
which is already set on previous lines.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agotools: kwbimage: Cosmetic fix - remove redundant space character
Marek Behún [Fri, 23 Jul 2021 09:14:05 +0000 (11:14 +0200)]
tools: kwbimage: Cosmetic fix - remove redundant space character

Remove this space, since the constants are indented by tabs.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agotools: kwbimage: Print size of binary header in kwbimage_print_header()
Pali Rohár [Fri, 23 Jul 2021 09:14:04 +0000 (11:14 +0200)]
tools: kwbimage: Print size of binary header in kwbimage_print_header()

The binary header in kwbimage contains executable SPL code.

Print information about this binary header and not only information
about it's data part.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agotools: kwbimage: Validate data checksum of v1 images
Pali Rohár [Fri, 23 Jul 2021 09:14:03 +0000 (11:14 +0200)]
tools: kwbimage: Validate data checksum of v1 images

The data part of v1 images contains 32-bit checksum after the data.
Validate whether this checksum is correct.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agotools: kwbimage: Validate extended headers of v1 images
Pali Rohár [Fri, 23 Jul 2021 09:14:02 +0000 (11:14 +0200)]
tools: kwbimage: Validate extended headers of v1 images

Add basic checks for extended headers of v1 images.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agotools: kwbimage: Fix check for v0 extended header checksum
Pali Rohár [Fri, 23 Jul 2021 09:14:01 +0000 (11:14 +0200)]
tools: kwbimage: Fix check for v0 extended header checksum

Extended header checksum for v0 image is present only in the case when
extended header is present. Skip checksum validation if extended header
is not present.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agotools: kwbimage: Don't crash when binary file name does not contain '/'
Pali Rohár [Fri, 23 Jul 2021 09:14:00 +0000 (11:14 +0200)]
tools: kwbimage: Don't crash when binary file name does not contain '/'

In the case when the file name is specified relative to the current
working directory, it does not contain '/' character and strrchr()
returns NULL.

The following strcmp() function then crashes on NULL pointer
dereference.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agotools: kwbimage: Fix generation of SATA, SDIO and PCIe images
Pali Rohár [Fri, 23 Jul 2021 09:13:59 +0000 (11:13 +0200)]
tools: kwbimage: Fix generation of SATA, SDIO and PCIe images

SATA and SDIO images must be aligned to sector size (which in most cases
is 512 bytes) and Source Address in main header is stored in number of
sectors from the beginning of the drive. SATA image must be stored at
sector 1 and SDIO image at sector 0. Source Address for PCIe image is
not used and must be set to 0xFFFFFFFF.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agotools: kwbimage: Add constant for SDIO bootfrom
Marek Behún [Fri, 23 Jul 2021 09:13:58 +0000 (11:13 +0200)]
tools: kwbimage: Add constant for SDIO bootfrom

Add constant for SDIO value of the bootfrom header field.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agotools: kwbimage: Align SPI and NAND images to 256 bytes
Pali Rohár [Fri, 23 Jul 2021 09:13:57 +0000 (11:13 +0200)]
tools: kwbimage: Align SPI and NAND images to 256 bytes

Writing into SPI NOR and NAND memory can be done only in 256 bytes long
blocks. Align final image size so that when it is burned into SPI NOR or
NAND memory via U-Boot's commands (sf or mtd), we can use the $filesize
variable directly as the length argument.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agotools: kwbimage: Simplify aligning and calculating checksum
Pali Rohár [Fri, 23 Jul 2021 09:13:56 +0000 (11:13 +0200)]
tools: kwbimage: Simplify aligning and calculating checksum

The return value of kwbimage_generate() is used for aligning the data
part of kwbimage. Use it for calculating proper 4 byte alignment as is
required by BootROM and also use it for allocating additional 4 bytes
for the 32-bit data checksum.

This simplifies the alignment code to be only at one place (in function
kwbimage_generate) and also simplifies setting checksum as it can be
directly updated in memory.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agotools: kwbimage: Fix compilation without CONFIG_SYS_U_BOOT_OFFS
Pali Rohár [Fri, 23 Jul 2021 09:13:55 +0000 (11:13 +0200)]
tools: kwbimage: Fix compilation without CONFIG_SYS_U_BOOT_OFFS

The CONFIG_SYS_U_BOOT_OFFS option may be defined as empty string.
In this case it causes compilation error:

    tools/kwbimage.c: In function ‘image_headersz_v1’:
    tools/kwbimage.c:1002:39: error: expected expression before ‘)’ token
      if (headersz > CONFIG_SYS_U_BOOT_OFFS) {
                                           ^
    tools/kwbimage.c:1006:41: error: expected expression before ‘)’ token
        (int)headersz, CONFIG_SYS_U_BOOT_OFFS);
                                             ^
    tools/kwbimage.c:1011:35: error: expected expression before ‘;’ token
      headersz = CONFIG_SYS_U_BOOT_OFFS;
                                       ^
    make[1]: *** [scripts/Makefile.host:112: tools/kwbimage.o] Error 1
    make: *** [Makefile:1822: tools] Error 2

Check whether the value of CONFIG_SYS_U_BOOT_OFFS is really set.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
3 years agoMerge branch '2021-07-28-assorted-fixes'
Tom Rini [Thu, 29 Jul 2021 16:10:23 +0000 (12:10 -0400)]
Merge branch '2021-07-28-assorted-fixes'

- Assorted bugfixes

3 years agoMerge tag 'ti-v2021.10-rc2' of https://source.denx.de/u-boot/custodians/u-boot-ti
Tom Rini [Thu, 29 Jul 2021 12:20:06 +0000 (08:20 -0400)]
Merge tag 'ti-v2021.10-rc2' of https://source.denx.de/u-boot/custodians/u-boot-ti

- Add MMC High speed modes for AM64 and J7200
- Add Sierra/Torrent SERDES driver
- Minor clean-ups for R5F boot from SPL

3 years agoboard: ti: k2g: Program PadConfig_202 before locking RSTMUX8
Suman Anna [Mon, 26 Jul 2021 23:22:48 +0000 (18:22 -0500)]
board: ti: k2g: Program PadConfig_202 before locking RSTMUX8

The PADCONFIG_202 register (0x02621328) is affected by the locking
of the RSTMUX8 register (0x02620328), and so cannot be configured
in kernel. This has been confirmed as a hardware bug and affects
all K2G SoCs.

Setup the pinmux for this pin before locking the RSTMUX8 register
to allow the ICSS1 PRU1 Ethernet PHY port to work properly. The
workaround was added only for the K2G-ICE board to configure the
pins needed for the PRUSS Ethernet usecase.

Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Link: https://lore.kernel.org/r/20210726232248.24395-1-s-anna@ti.com
3 years agomkimage: use environment variable MKIMAGE_SIGN_PIN to set pin for OpenSSL Engine
Marc Kleine-Budde [Fri, 23 Jul 2021 20:17:50 +0000 (22:17 +0200)]
mkimage: use environment variable MKIMAGE_SIGN_PIN to set pin for OpenSSL Engine

This patch adds the possibility to pass the PIN the OpenSSL Engine
used during signing via the environment variable MKIMAGE_SIGN_PIN.
This follows the approach used during kernel module
signing ("KBUILD_SIGN_PIN") or UBIFS image
signing ("MKIMAGE_SIGN_PIN").

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
3 years agotest/py: Improve check for mksquashfs version
Marek Behún [Thu, 22 Jul 2021 20:52:05 +0000 (22:52 +0200)]
test/py: Improve check for mksquashfs version

Some builds of squashfs-tools append version string with "-git" or
similar. The float() conversion will fail in this case.

Improve the code to only convert to float() the string before the '-'
character.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com>
3 years agobuild: remove the variable NM in gen_ll_addressable_symbols.sh
Patrick Delaunay [Wed, 21 Jul 2021 07:56:07 +0000 (09:56 +0200)]
build: remove the variable NM in gen_ll_addressable_symbols.sh

With LTO activated, the buildman tools failed with an error on my
configuration (Ubuntu 20.04, stm32mp15_trusted_defconfig) with the error:

../arm-linux-gnueabi/bin/nm:
scripts/gen_ll_addressable_symbols.sh: file format not recognized

It seems the shell variable initialization NM=$(NM) is not correctly
interpreted when shell is started in the Makefile, but I have not this
issue when I compile the same target without buildman.

I don't found the root reason of the problem but I solve it by
providing $(NM) as script parameter instead using a shell variable.

The command executed is identical:

cmd_keep-syms-lto.c := NM=arm-none-linux-gnueabihf-gcc-nm \
u-boot/scripts/gen_ll_addressable_symbols.sh arch/arm/cpu/built-in.o \
.... net/built-in.o >keep-syms-lto.c

cmd_keep-syms-lto.c := u-boot/scripts/gen_ll_addressable_symbols.sh \
arm-none-linux-gnueabihf-gcc-nm arch/arm/cpu/built-in.o \
... net/built-in.o > keep-syms-lto.c

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
3 years agolib: rsa: rsa-sign: Minor bug in debug message
Chan, Donald [Mon, 19 Jul 2021 16:18:54 +0000 (09:18 -0700)]
lib: rsa: rsa-sign: Minor bug in debug message

*sig_size isn't set until later so use the correct variables.

Signed-off-by: Donald Chan <hoiho@lab126.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agolib: rsa: rsa-verify: Fix a typo in a debug message
Thomas Perrot [Mon, 19 Jul 2021 14:04:44 +0000 (16:04 +0200)]
lib: rsa: rsa-verify: Fix a typo in a debug message

Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com>
3 years agoarm64: Update memcpy_{from, to}io() helpers
Patrice Chotard [Mon, 19 Jul 2021 09:21:51 +0000 (11:21 +0200)]
arm64: Update memcpy_{from, to}io() helpers

At early U-Boot stage, before relocation, MMU is not yet configured
and disabled. DDR may not be configured with the correct memory
attributes (can be configured in MT_DEVICE instead of MT_MEMORY).

In this case, usage of memcpy_{from, to}io() may leads to synchronous
abort in AARCH64 in case the normal memory address is not 64Bits aligned.

To avoid such situation, forbid usage of normal memory cast to (u64 *) in
case MMU is not enabled.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: mark.kettenis@xs4all.nl
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
3 years agoarm: use the correct prototype for reset_cpu function
Patrick Delaunay [Mon, 19 Jul 2021 09:21:50 +0000 (11:21 +0200)]
arm: use the correct prototype for reset_cpu function

Align reset_cpu function with the next prototypes in
sysreset.h or in cpu_func.h to solve compilation issue:

  void reset_cpu(void);

This patch solves the prototype conflict when cpu_func.h is
included.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
3 years agodoc: sandbox: Fix up dependencies
Simon Glass [Sun, 18 Jul 2021 20:14:24 +0000 (14:14 -0600)]
doc: sandbox: Fix up dependencies

These are out of date. Update them and point to the existing build
instructions to avoid duplication. Add a few that are missing.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agopci: swap_case: Allow compilation on 32-bit machines
Simon Glass [Sun, 18 Jul 2021 20:14:23 +0000 (14:14 -0600)]
pci: swap_case: Allow compilation on 32-bit machines

At present this driver assumes that ulong is 64-bits long. On 32-bit
machines it is not. Use the 64-bit code only on 64-bit machines.

This makes things work correctly on 32-bit machines.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoMerge branch '2021-07-28-build-improvements'
Tom Rini [Wed, 28 Jul 2021 22:51:16 +0000 (18:51 -0400)]
Merge branch '2021-07-28-build-improvements'

- Assorted Makefile cleanups
- A few code / build cleanups

3 years agoMakefile: Move drivers/i2c/ into drivers/Makefile
Simon Glass [Sun, 11 Jul 2021 03:14:37 +0000 (21:14 -0600)]
Makefile: Move drivers/i2c/ into drivers/Makefile

This rule should not be in the top-level Makefile. Now that we have a
consistent set of I2C Kconfigs for U-Boot proper, SPL and TPL, we can move
it.

Make use of the existing SPL/TPL rule in drivers/Makefile instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoi2c: Rename SPL/TPL_I2C_SUPPORT to I2C
Simon Glass [Sun, 11 Jul 2021 03:14:36 +0000 (21:14 -0600)]
i2c: Rename SPL/TPL_I2C_SUPPORT to I2C

Rename these options so that CONFIG_IS_ENABLED can be used with them.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
3 years agoi2c: Create a new Kconfig for I2C
Simon Glass [Sun, 11 Jul 2021 03:14:35 +0000 (21:14 -0600)]
i2c: Create a new Kconfig for I2C

At present we have CONFIG_SPL_I2C but not CONFIG_I2C. The reason
CONFIG_I2C is not strictly necessary is that:

a) We have CONFIG_SYS_I2C_LEGACY and CONFIG_DM_I2C for the two possible
   i2c stacks
b) In U-Boot proper, we always build drivers/i2c/ regardless of the
   options

Still, it is better to have CONFIG_I2C - it makes U-Boot proper similar to
SPL/TPL, so we can (in a future commit) simplify the Makefile rules.

Enable it by default, since as above, we have separate options
(SYS_I2C_LEGACY and DM_I2C) to control whether it is 'really' enabled.

Once we have migrated I2C to driver model, we can drop SYS_I2C_LEGACY and
make DM_I2C become I2C. For now, this lets us simplify the Makefile rules.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
3 years agoi2c: Drop unused CONFIG_I2C
Simon Glass [Sun, 11 Jul 2021 03:14:34 +0000 (21:14 -0600)]
i2c: Drop unused CONFIG_I2C

This actually does nothing but is defined by a few dozen boards. Drop it,
so we can define a real one.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
3 years agoi2c: Fix the migration warning
Simon Glass [Sun, 11 Jul 2021 03:14:33 +0000 (21:14 -0600)]
i2c: Fix the migration warning

While there is a CONFIG_I2C it does not really mean anything and is
defined by only a few dozen boards. This should key off
CONFIG_SYS_I2C_LEGACY instead.

Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
3 years agoi2c: Rename CONFIG_SYS_I2C to CONFIG_SYS_I2C_LEGACY
Simon Glass [Sun, 11 Jul 2021 03:14:32 +0000 (21:14 -0600)]
i2c: Rename CONFIG_SYS_I2C to CONFIG_SYS_I2C_LEGACY

It is quite confusing that CONFIG_SYS_I2C selects the legacy I2C and
CONFIG_DM_I2C selects the current I2C. The deadline to migrate I2C is less
than a year away.

Also we want to have a CONFIG_I2C for U-Boot proper just like we have
CONFIG_SPL_I2C for SPL, so we can simplify the Makefile rules.

Rename this symbol so it is clear it is going away.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
3 years agoRename DRIVERS_MISC_SUPPORT to DRIVERS_MISC
Simon Glass [Sun, 11 Jul 2021 03:14:31 +0000 (21:14 -0600)]
Rename DRIVERS_MISC_SUPPORT to DRIVERS_MISC

Rename these options so that CONFIG_IS_ENABLED can be used with them.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoRename GPIO_SUPPORT to GPIO
Simon Glass [Sun, 11 Jul 2021 03:14:30 +0000 (21:14 -0600)]
Rename GPIO_SUPPORT to GPIO

Rename these options so that CONFIG_IS_ENABLED can be used with them.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoRename SPL_USB_HOST_SUPPORT to SPL_USB_HOST
Simon Glass [Sun, 11 Jul 2021 03:14:29 +0000 (21:14 -0600)]
Rename SPL_USB_HOST_SUPPORT to SPL_USB_HOST

Rename this option so that CONFIG_IS_ENABLED can be used with it.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoRename SPL_WATCHDOG_SUPPORT to SPL_WATCHDOG
Simon Glass [Sun, 11 Jul 2021 03:14:28 +0000 (21:14 -0600)]
Rename SPL_WATCHDOG_SUPPORT to SPL_WATCHDOG

Rename this option so that CONFIG_IS_ENABLED can be used with it.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoRename SPL_MUSB_NEW_SUPPORT to SPL_MUSB_NEW
Simon Glass [Sun, 11 Jul 2021 03:14:27 +0000 (21:14 -0600)]
Rename SPL_MUSB_NEW_SUPPORT to SPL_MUSB_NEW

Rename this option so that CONFIG_IS_ENABLED can be used with it.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoRename SPL_ETH_SUPPORT to SPL_ETH
Simon Glass [Sun, 11 Jul 2021 03:14:26 +0000 (21:14 -0600)]
Rename SPL_ETH_SUPPORT to SPL_ETH

Rename this option so that CONFIG_IS_ENABLED can be used with it.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoRename SPL_CRYPTO_SUPPORT to SPL_CRYPTO
Simon Glass [Sun, 11 Jul 2021 03:14:25 +0000 (21:14 -0600)]
Rename SPL_CRYPTO_SUPPORT to SPL_CRYPTO

Rename this option so that CONFIG_IS_ENABLED can be used with it.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoRename SPL_POWER_SUPPORT to SPL_POWER
Simon Glass [Sun, 11 Jul 2021 03:14:24 +0000 (21:14 -0600)]
Rename SPL_POWER_SUPPORT to SPL_POWER

Rename this option so that CONFIG_IS_ENABLED can be used with it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agoMakefile: Move phy rules into drivers/phy
Simon Glass [Sun, 11 Jul 2021 03:14:23 +0000 (21:14 -0600)]
Makefile: Move phy rules into drivers/phy

These don't belong in the drivers Makefile so move them down into
the correct place.

Signed-off-by: Simon Glass <sjg@chromium.org>
[trini: Fixup some missing dependencies this exposed]
Signed-off-by: Tom Rini <trini@konsulko.com>
3 years agoMakefile: Sort the subdirectories
Simon Glass [Sun, 11 Jul 2021 03:14:22 +0000 (21:14 -0600)]
Makefile: Sort the subdirectories

Adjust the subdirectories included in this file so that they are in
alphabetical order. This makes it easier to follow.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoREADME: Fix hyphenation in the directory docs
Simon Glass [Sun, 11 Jul 2021 03:14:21 +0000 (21:14 -0600)]
README: Fix hyphenation in the directory docs

Hyphens are missing in various places where the intent is to create an
adjective. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agolib: Create a new Kconfig option for charset conversion
Simon Glass [Fri, 2 Jul 2021 18:36:17 +0000 (12:36 -0600)]
lib: Create a new Kconfig option for charset conversion

Rather than looking at two KConfig options in the Makefile, create a new
Kconfig option for compiling lib/charset.c

Enable it for UFS also, which needs this support.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agoAllow efi_loader header to be included always
Simon Glass [Fri, 2 Jul 2021 18:36:16 +0000 (12:36 -0600)]
Allow efi_loader header to be included always

It is bad practice to put function declarations behind an #ifdef since
it makes it impossible to use IS_ENABLED() in the C code. The main reason
for doing this is when an empty static inline function is desired when
the feature is disabled.

To this end, this header provides two different versions of various
functions and macros. Collect them together in one place for clarity.
Allow all the rest of the header to be included, regardless of the
setting of EFI_LOADER.

With the inclusion of blk.h the 'struct blk_desc' declaration is
unnecessary. Drop it while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoUse LIB_UUID with ACPIGEN and FS_BTRFS
Simon Glass [Fri, 2 Jul 2021 18:36:15 +0000 (12:36 -0600)]
Use LIB_UUID with ACPIGEN and FS_BTRFS

Since the ACPI-generation code makes use of UUIDs we typically need to
enabled UUID support for it to build. Add a new Kconfig condition.

Use it for BTRFS also.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodisk: Tidy up #ifdefs in part_efi
Simon Glass [Fri, 2 Jul 2021 18:36:14 +0000 (12:36 -0600)]
disk: Tidy up #ifdefs in part_efi

This file does not correctly handle the various cases, sometimes
producing warnings about partition_basic_data_guid being defined but not
used. Fix it.

There was some discussion about adjusting Kconfig or making
HAVE_BLOCK_DEVICE a prerequisite for PARTITIONS, but apparently this is
not feasible. Such changes can be undertaken separate from the goal of
this series.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoMakefile: Drop include/asm directory as well as symlink
Simon Glass [Fri, 2 Jul 2021 18:36:13 +0000 (12:36 -0600)]
Makefile: Drop include/asm directory as well as symlink

At present when using 'make mrproper' on an out-of-tree build, a warning
is shown about include/asm being a directory. With old versions of U-Boot
it is a file, but more recently it has become a directory.

Remove this directory first, since that covers both cases.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoMerge branch '2021-07-28-setexpr-fmt-support'
Tom Rini [Wed, 28 Jul 2021 13:51:09 +0000 (09:51 -0400)]
Merge branch '2021-07-28-setexpr-fmt-support'

- Add a new feature (and CONFIG option) to allow setexpr to take format
  (%d, etc) arguments.

3 years agoAzureCI: Move i.MX8 builds to their own job
Tom Rini [Tue, 27 Jul 2021 21:01:28 +0000 (17:01 -0400)]
AzureCI: Move i.MX8 builds to their own job

The aarch64 catch-all job is starting to get close to or exceed the time
limit for jobs.  Move the i.MX8 boards to their own job to fix this.

Signed-off-by: Tom Rini <trini@konsulko.com>
3 years agotest: cmd: setexpr: add format string tests
Roland Gaudig [Fri, 23 Jul 2021 12:29:23 +0000 (12:29 +0000)]
test: cmd: setexpr: add format string tests

Add test cases for the setexpr format string operator.

Signed-off-by: Roland Gaudig <roland.gaudig@weidmueller.com>
[trini: Enable on sandbox]
Signed-off-by: Tom Rini <trini@konsulko.com>
3 years agodoc: usage: add description for setexpr command
Roland Gaudig [Fri, 23 Jul 2021 12:29:22 +0000 (12:29 +0000)]
doc: usage: add description for setexpr command

Add usage for the setexpr command. It has been added to describe
mainly the new setexpr format string operation.

Signed-off-by: Roland Gaudig <roland.gaudig@weidmueller.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agocmd: setexpr: add format string handling
Roland Gaudig [Fri, 23 Jul 2021 12:29:21 +0000 (12:29 +0000)]
cmd: setexpr: add format string handling

Add format string handling operator to the setexpr command.
It allows to use C or Bash like format string expressions to be
evaluated with the result being stored inside the environment variable
name.

  setexpr <name> fmt <format> [value]...

The following example

  setexpr foo fmt "%d, 0x%x" 0x100 ff

will result in $foo being set to "256, 0xff".

Signed-off-by: Roland Gaudig <roland.gaudig@weidmueller.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agocmd: printf: add helper functions from busybox
Roland Gaudig [Fri, 23 Jul 2021 12:29:20 +0000 (12:29 +0000)]
cmd: printf: add helper functions from busybox

Import the following helper functions from Busybox-1.33.1 which are
required by printf.c:

  process_escape_sequence from libbb/process_escape_sequence.c,
  skip_whitespace from libbb/skip_whitespace.c,
  overlapping_strcpy  from libbb/safe_strncpy.c

  src-url: https://git.busybox.net/busybox/
  commit bcc5b0e6caca6c7602a6a41f "Bump version to 1.33.1"
  version: 1.33.1

Signed-off-by: Roland Gaudig <roland.gaudig@weidmueller.com>