platform/kernel/u-boot.git
18 months agoMerge tag 'efi-2023-01-rc1-4' of https://source.denx.de/u-boot/custodians/u-boot-efi
Tom Rini [Sun, 6 Nov 2022 12:51:44 +0000 (07:51 -0500)]
Merge tag 'efi-2023-01-rc1-4' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request for efi-2023-01-rc1-4

Documentation:

* Provide a document about security issue handling.

UEFI:

* Let networking support depend on NETDEVICES.
* Discover if no efi_system_partition is set.

Other:

* MAINTAINERS: add arch/arm/lib/*_efi.* to EFI_PAYLOAD.

18 months agoefi_loader: AllocateAddress requires page address
Heinrich Schuchardt [Sun, 6 Nov 2022 00:52:13 +0000 (01:52 +0100)]
efi_loader: AllocateAddress requires page address

AllocatePages() can be called with Type=AllocateAddress. Such a call can
only succeed if *Memory points to the address of an unallocated page range.

A call with *Memory being an address that is not page aligned must not
succeed. The UEFI specification requires returning EFI_OUT_OF_RESOURCES
if the requested pages cannot be allocated.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
18 months agotest/py: efi_secboot: Remove unnecessary cert-to-efi-hash-list option
Masahisa Kojima [Mon, 3 Oct 2022 07:12:15 +0000 (16:12 +0900)]
test/py: efi_secboot: Remove unnecessary cert-to-efi-hash-list option

'cert-to-efi-hash-list -t 0' does not work as expected, it produces
indeterminate timestamp.

  $ cert-to-efi-hash-list -t 0 -s 256 db.crt dbx_hash.crl
  TimeOfRevocation is 0-113-0 00:00:255

If we need the CRL revoked for all the time, just don't specify
'-t' option.

  $ cert-to-efi-hash-list -s 256 db.crt dbx_hash.crl
  TimeOfRevocation is 0-0-0 00:00:00

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
18 months agoefi_loader: discover if no efi_system_partition is set
Heinrich Schuchardt [Fri, 21 Oct 2022 06:33:44 +0000 (08:33 +0200)]
efi_loader: discover if no efi_system_partition is set

Variable efi_system_partition holds the efi_system_partition. Currently it
is initialized as:

    {
      .uclass_id = 0 = UCLASS_ROOT,
      .denum = 0,
      .part = 0,
    }

This indicates that host 0:0 is the efi_system_partition and we see output
like:

    => bootefi hello
    ** Bad device specification host 0 **
    Couldn't find partition host 0:0

To identify that no EFI system partition has been set use UCLASS_INVALID.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
18 months agoefi_loader: remove CONFIG_EFI_SETUP_EARLY
AKASHI Takahiro [Fri, 21 Oct 2022 03:01:57 +0000 (12:01 +0900)]
efi_loader: remove CONFIG_EFI_SETUP_EARLY

Since the commit a9bf024b2933 ("efi_loader: disk: a helper function to
create efi_disk objects from udevice"), CONFIG_EFI_SETUP_EARLY option is
by default on and will never be turned off.

So just remove this option.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
18 months agoefi_loader: Let networking support depend on NETDEVICES
Jan Kiszka [Fri, 14 Oct 2022 16:10:06 +0000 (18:10 +0200)]
efi_loader: Let networking support depend on NETDEVICES

CONFIG_NET does not imply that there are actually network devices
available, only CONFIG_NETDEVICES does. Changing to this dependency
obsoletes the check in Kconfig because NETDEVICES means DM_ETH.

Fixes: 0efe1bcf5c2c ("efi_loader: Add network access support")
Suggested-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
18 months agoMAINTAINERS: add arch/arm/lib/*_efi.* to EFI_PAYLOAD
Heinrich Schuchardt [Sun, 6 Nov 2022 09:23:55 +0000 (10:23 +0100)]
MAINTAINERS: add arch/arm/lib/*_efi.* to EFI_PAYLOAD

The files arch/arm/lib/*_efi.* are only relevant for the UEFI sub-system.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
18 months agodocs: Add a basic security document
Tom Rini [Thu, 3 Nov 2022 18:25:44 +0000 (14:25 -0400)]
docs: Add a basic security document

Based loosely on the Linux kernel
Documentation/admin-guide/security-bugs.rst file, create a basic
security document for U-Boot.  In sum, security issues should be
disclosed in public on the mailing list if at all possible as an initial
position.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
18 months agodoc: update sbi command example
Heinrich Schuchardt [Fri, 28 Oct 2022 20:28:09 +0000 (22:28 +0200)]
doc: update sbi command example

The output of the sbi command has been changed since the last release of
the man-page. Update the example.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
18 months agoMerge https://source.denx.de/u-boot/custodians/u-boot-usb
Tom Rini [Fri, 4 Nov 2022 15:19:58 +0000 (11:19 -0400)]
Merge https://source.denx.de/u-boot/custodians/u-boot-usb

- 3 important fixes

18 months agousb: storage: continue probe on "Invalid device"
Janne Grunau [Fri, 4 Nov 2022 07:38:59 +0000 (08:38 +0100)]
usb: storage: continue probe on "Invalid device"

Fixes a crash during probing of sd card readers without medium present.
Seen with the device below but reported for many other devices.

  idVendor           0x0bda Realtek Semiconductor Corp.
  idProduct          0x0326 Card reader
  bcdDevice           11.24
  iManufacturer           1 Realtek
  iProduct                2 USB3.0 Card Reader
  iSerial                 3 201404081410

Link: https://github.com/AsahiLinux/linux/issues/44
Link: https://lists.denx.de/pipermail/u-boot/2022-July/489717.html
Signed-off-by: Janne Grunau <j@jannau.net>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
18 months agoMerge tag 'mips-pull-2022-11-03' of https://source.denx.de/u-boot/custodians/u-boot...
Tom Rini [Fri, 4 Nov 2022 00:23:27 +0000 (20:23 -0400)]
Merge tag 'mips-pull-2022-11-03' of https://source.denx.de/u-boot/custodians/u-boot-mips

- MIPS: convert CONFIG_SYS_MIPS_TIMER_FREQ to Kconfig
- MIPS: mtmips: fix incorrectly converted default value for CONFIG_SPL_PAD_TO

18 months agousb: Add 1ms delay after first Get Descriptor request
Marek Vasut [Sun, 30 Oct 2022 22:38:35 +0000 (23:38 +0100)]
usb: Add 1ms delay after first Get Descriptor request

Logitech Unifying Receiver 046d:c52b bcdDevice 12.10 seems
sensitive about the first Get Descriptor request. If there
are any other requests in the same microframe, the device
reports bogus data, first of the descriptor parts is not
sent to the host. Wait over one microframe duration before
issuing subsequent requests to avoid probe failure with
this device, since it can be used to connect USB keyboards.

Signed-off-by: Marek Vasut <marex@denx.de>
Tested-by: Janne Grunau <j@jannau.net>
18 months agousb: ohci: Use a flexible array member for portstatus
Samuel Holland [Mon, 31 Oct 2022 04:15:12 +0000 (23:15 -0500)]
usb: ohci: Use a flexible array member for portstatus

The struct is only used to overlay the MMIO region, so the behavior is
the same. This obsoletes the Kconfig option for the number of ports.

Signed-off-by: Samuel Holland <samuel@sholland.org>
18 months agoMerge branch '2022-11-02-assorted-updates'
Tom Rini [Thu, 3 Nov 2022 12:29:10 +0000 (08:29 -0400)]
Merge branch '2022-11-02-assorted-updates'

- Improve arm semihosting, NPCM8xx pinctrl driver, SP804 uclass timer
  driver (and enable on relevant platforms), pvblock cleanup, eeprom cmd
  bugfix, add RTI watchdog nodes to k3-am64-main, evb-ast2500 config
  updates.

18 months agoMerge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-riscv
Tom Rini [Thu, 3 Nov 2022 12:27:44 +0000 (08:27 -0400)]
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-riscv

18 months agoriscv: Update Microchip MPFS Icicle Kit support
Padmarao Begari [Thu, 27 Oct 2022 06:02:02 +0000 (11:32 +0530)]
riscv: Update Microchip MPFS Icicle Kit support

This patch updates Microchip MPFS Icicle Kit support. For now,
add Microchip QSPI driver and a small 4MB reservation is
made at the end of 32-bit DDR to provide some memory for
the HSS to use.

Signed-off-by: Padmarao Begari <padmarao.begari@microchip.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Rick Chen <rick@andestech.com>
18 months agospi: Add Microchip PolarFire SoC QSPI driver
Padmarao Begari [Thu, 27 Oct 2022 06:02:01 +0000 (11:32 +0530)]
spi: Add Microchip PolarFire SoC QSPI driver

Add QSPI driver code for the Microchip PolarFire SoC.
This driver supports the QSPI standard, dual and quad
mode interfaces.

Co-developed-by: Naga Sureshkumar Relli <nagasuresh.relli@microchip.com>
Signed-off-by: Naga Sureshkumar Relli <nagasuresh.relli@microchip.com>
Signed-off-by: Padmarao Begari <padmarao.begari@microchip.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
18 months agoriscv: dts: Add QSPI NAND device node
Padmarao Begari [Thu, 27 Oct 2022 06:02:00 +0000 (11:32 +0530)]
riscv: dts: Add QSPI NAND device node

Add QSPI NAND device node to the Microchip PolarFire SoC
Icicle kit device tree.

The Winbond NAND flash memory can be connected to the
Icicle Kit by using the Mikroe Flash 5 click board and
the Pi 3 Click shield.

Signed-off-by: Padmarao Begari <padmarao.begari@microchip.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Rick Chen <rick@andestech.com>
18 months agoriscv: dts: Update memory configuration
Padmarao Begari [Thu, 27 Oct 2022 06:01:59 +0000 (11:31 +0530)]
riscv: dts: Update memory configuration

In the v2022.10 Icicle reference design, the seg registers have been
changed, resulting in a required change to the memory map.
A small 4MB reservation is made at the end of 32-bit DDR to provide some
memory for the HSS to use, so that it can cache its payload between
reboots of a specific context.

Co-developed-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Padmarao Begari <padmarao.begari@microchip.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Rick Chen <rick@andestech.com>
18 months agoriscv: Rename Andes PLIC to PLICSW
Yu Chien Peter Lin [Tue, 25 Oct 2022 15:03:50 +0000 (23:03 +0800)]
riscv: Rename Andes PLIC to PLICSW

As PLICSW is used to trigger the software interrupt, we should rename
Andes PLIC configuration and file name to reflect the usage. This patch
also updates PLMT and PLICSW compatible strings to be consistent with
OpenSBI fdt driver.

Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
Reviewed-by: Rick Chen <rick@andestech.com>
18 months agomips: mtmips: spl/Kconfig: Set CONFIG_SPL_PAD_TO to 0x0 for ARCH_MTMIPS
Stefan Roese [Fri, 28 Oct 2022 12:46:29 +0000 (14:46 +0200)]
mips: mtmips: spl/Kconfig: Set CONFIG_SPL_PAD_TO to 0x0 for ARCH_MTMIPS

It was noticed that while converting CONFIG_SPL_PAD_TO to Kconfig its
value for the MIPS MT762x/8x targets got not ported correctly. Its
default is not 0x10000 instead of 0x0. This patch fixes this issue.

Fixes: ca8a329a1b7f ("Convert CONFIG_SPL_PAD_TO et al to Kconfig")
Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Ruben Winters <Ruben.Winters@gooiland-elektro.nl>
Cc: Weijie Gao <weijie.gao@mediatek.com>
Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Cc: Tom Rini <trini@konsulko.com>
18 months agoMIPS: convert CONFIG_SYS_MIPS_TIMER_FREQ to Kconfig
Daniel Schwierzeck [Sun, 10 Jul 2022 15:15:14 +0000 (17:15 +0200)]
MIPS: convert CONFIG_SYS_MIPS_TIMER_FREQ to Kconfig

This converts the following to Kconfig:
    CONFIG_SYS_MIPS_TIMER_REQ

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
18 months agoMIPS: mscc: remove unused CPU_CLOCK_RATE
Daniel Schwierzeck [Sun, 10 Jul 2022 15:15:13 +0000 (17:15 +0200)]
MIPS: mscc: remove unused CPU_CLOCK_RATE

CPU_CLOCK_RATE is just used once for CONFIG_SYS_MIPS_TIMER_FREQ
which is migrated to Kconfig in the next patch.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
18 months agoMIPS: remove CONFIG_SYS_MHZ
Daniel Schwierzeck [Sun, 10 Jul 2022 15:15:12 +0000 (17:15 +0200)]
MIPS: remove CONFIG_SYS_MHZ

Resolve all uses of CONFIG_SYS_MHZ with the currently defined value.
Remove code which depends on CONFIG_SYS_MHZ but where no board configs
actually use that code.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
18 months agoMIPS: remove deprecated TARGET_VCT option
Daniel Schwierzeck [Sun, 10 Jul 2022 15:15:11 +0000 (17:15 +0200)]
MIPS: remove deprecated TARGET_VCT option

This board has been removed a long time ago.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
18 months agoled: led_pwm: typo 'iverted' on code comment
Nylon Chen [Thu, 27 Oct 2022 06:25:37 +0000 (14:25 +0800)]
led: led_pwm: typo 'iverted' on code comment

change iverted to inverted.

Signed-off-by: Nylon Chen <nylon.chen@sifive.com>
18 months agoconfigs: evb-ast2500: Set environment in SPI flash
Cédric Le Goater [Wed, 26 Oct 2022 13:11:15 +0000 (15:11 +0200)]
configs: evb-ast2500: Set environment in SPI flash

We now have a SPI flash driver. Let's use it.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Joel Stanley <joel@jms.id.au>
18 months agoconfigs: evb-ast2500: Add support for FIT format
Cédric Le Goater [Wed, 26 Oct 2022 13:11:14 +0000 (15:11 +0200)]
configs: evb-ast2500: Add support for FIT format

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Joel Stanley <joel@jms.id.au>
18 months agoconfigs: evb-ast2500: Adjust boot command
Cédric Le Goater [Wed, 26 Oct 2022 13:11:13 +0000 (15:11 +0200)]
configs: evb-ast2500: Adjust boot command

Loading a kernel image is enough.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Joel Stanley <joel@jms.id.au>
18 months agoconfigs: evb-ast2500: Remove MMC support from default settings
Cédric Le Goater [Wed, 26 Oct 2022 13:11:12 +0000 (15:11 +0200)]
configs: evb-ast2500: Remove MMC support from default settings

This saves ~50K in the resulting u-boot.bin file which is important to
fit in the U-Boot partition defined in the flash layout of upstream Linux.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
18 months agoarm: dts: ti: k3-am64-main: Add RTI watchdog nodes
Christian Gmeiner [Wed, 26 Oct 2022 11:15:55 +0000 (13:15 +0200)]
arm: dts: ti: k3-am64-main: Add RTI watchdog nodes

Add the needed bus mappings for the two main RTI memory ranges and
the required device tree nodes in the main domain.

Same as kernel commit 6dd8457dc20693e2ba9054c171499b22664fd4e7

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
18 months agotreewide: Remove the unnecessary space before semicolon
Bin Meng [Wed, 26 Oct 2022 04:40:07 +0000 (12:40 +0800)]
treewide: Remove the unnecessary space before semicolon

%s/return ;/return;

Signed-off-by: Bin Meng <bmeng@tinylab.org>
18 months agocmd: eeprom: don't truncate target address at 32-bit
Baruch Siach [Sun, 23 Oct 2022 09:28:12 +0000 (12:28 +0300)]
cmd: eeprom: don't truncate target address at 32-bit

On 64-bit platforms where int is 32-bit wide, the eeprom command
parse_numeric_param() routine truncates the memory address parameter to
the lower 32-bit. Make parse_numeric_param() return long to allow
read/write of addresses beyond the lower 4GB.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
18 months agoxen: pvblock: Use uclass_probe_all
Michal Suchanek [Sat, 22 Oct 2022 14:33:05 +0000 (16:33 +0200)]
xen: pvblock: Use uclass_probe_all

Also eliminate useless code and variables.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
18 months agohighbank: switch to use the Arm SP804 DM_TIMER driver
Andre Przywara [Thu, 20 Oct 2022 22:10:25 +0000 (23:10 +0100)]
highbank: switch to use the Arm SP804 DM_TIMER driver

So far the Calxeda machines were using the CONFIG_SYS_TIMER_* macros to
simply hardcode the address of the counter register of the SP804 timer.
This method is deprecated and scheduled for removal.

Use the newly introduced SP804 DM_TIMER driver to provide timer
functionality on Highbank and Midway machines. The base address and base
frequency are taken from the devicetree.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
18 months agohighbank: scan into hb_sregs DT subnodes
Andre Przywara [Thu, 20 Oct 2022 22:10:24 +0000 (23:10 +0100)]
highbank: scan into hb_sregs DT subnodes

The DT used for Calxeda Highbank and Midway systems exposes a "system
registers" block, modeled as a DT subnode.
This includes several clocks, including the two fixed clocks for the
main oscillator and timer.

So far U-Boot was ignorant of this special construct (a "clocks" node
within the "hb-sregs" node), as it didn't need the PLL clocks in there.
But that also meant we lost the fixed clocks, which form the base for
the UART baudrate generator and also the SP804 timer.

To allow the generic PL011 and SP804 driver to read the clock rate,
add a simple bus driver, which triggers the DT node discovery inside this
special node. As we only care about the fixed clocks (we don't have
drivers for the PLLs anyway), just ignore the address translation (for
now).

The binding is described in bindings/arm/calxeda/hb-sregs.yaml, the DT
snippet in question looks like:

=======================
sregs@fff3c000 {
compatible = "calxeda,hb-sregs";
reg = <0xfff3c000 0x1000>;

clocks {
#address-cells = <1>;
#size-cells = <0>;

osc: oscillator {
#clock-cells = <0>;
compatible = "fixed-clock";
clock-frequency = <33333000>;
};
....
};
};
=======================

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
18 months agotimer: add SP804 UCLASS timer driver
Andre Przywara [Thu, 20 Oct 2022 22:10:23 +0000 (23:10 +0100)]
timer: add SP804 UCLASS timer driver

The "Arm Ltd. Dual-Timer Module (SP804)" is a simple 32-bit count-down
timer IP with interrupt functionality, and is used in some SoCs from
various vendors.

Add a simple DM compliant timer driver, to allow users of the SP804 to
switch to DM_TIMER.

This relies on the input clock to be accessible via the DM clock
framework, which should be fine as we probably look at fixed-clock's
here anyway.
We re-program the control register in the probe() function, but keep
the divider in place, in case this has been set to something on purpose
before.

The TRM for the timer IP can be found here:
https://developer.arm.com/documentation/ddi0271/latest

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
18 months agopinctrl: nuvoton: Add NPCM8xx pinctrl driver
Jim Liu [Tue, 11 Oct 2022 08:09:13 +0000 (16:09 +0800)]
pinctrl: nuvoton: Add NPCM8xx pinctrl driver

Add Nuvoton BMC NPCM845 Pinmux and Pinconf support.

Signed-off-by: Jim Liu <JJLIU0@nuvoton.com>
Signed-off-by: Stanley Chu <yschu@nuvoton.com>
18 months agoarm: smh: Allow semihosting trap calls to be inlined
Andre Przywara [Wed, 5 Oct 2022 16:38:49 +0000 (17:38 +0100)]
arm: smh: Allow semihosting trap calls to be inlined

Currently our semihosting trap function is somewhat fragile: we rely
on the current compiler behaviour to assign the second inline assembly
argument to the next free register (r1/x1), which happens to be the
"addr" argument to the smh_trap() function (per the calling convention).
I guess this is also the reason for the noinline attribute.

Make it explicit what we want: the "addr" argument needs to go into r1,
so we add another register variable. This allows to drop the "noinline"
attribute, so now the compiler beautifully inlines just the trap
instruction directly into the calling function.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
18 months agoarm: smh: Make semihosting trap calls more robust
Andre Przywara [Wed, 5 Oct 2022 16:38:48 +0000 (17:38 +0100)]
arm: smh: Make semihosting trap calls more robust

Commit f4b540e25c5c("arm: smh: Fix uninitialized parameters with newer
GCCs") added a memory clobber to the semihosting inline assembly trap
calls, to avoid too eager GCC optimisation: when passing a pointer, newer
compilers couldn't be bothered to actually fill in the structure that it
pointed to, as this data would seemingly never be used (at least from the
compiler's point of view).
But instead of the memory clobber we need to tell the compiler that we are
passing an *array* instead of some generic pointer, this forces the
compiler to actually populate the data structure.
This involves some rather hideous cast, which is best hidden in a macro.

But regardless of that, we actually need the memory clobber, but for two
different reasons: explain them in comments.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
18 months agoarm: smh: specify Thumb trap instruction
Andre Przywara [Wed, 5 Oct 2022 16:38:47 +0000 (17:38 +0100)]
arm: smh: specify Thumb trap instruction

The ARM semihosting interface uses different trap instructions for
different architectures and instruction sets. So far we were using
AArch64 and ARMv7-M, and had an untested v7-A entry. The latter does
not work when building for Thumb, as can be verified by using
qemu_arm_defconfig, then enabling SEMIHOSTING and SYS_THUMB_BUILD:
==========
{standard input}:35: Error: invalid swi expression
{standard input}:35: Error: value of 1193046 too large for field of 2 bytes at 0
==========

Fix this by providing the recommended instruction[1] for Thumb, and
using the ARM instruction only when not building for Thumb. This also
removes some comment, as QEMU for ARM allows to now test this case.
Also use the opportunity to clean up the inline assembly, and just define
the actual trap instruction inside #ifdef's, to improve readability.

[1] https://developer.arm.com/documentation/dui0471/g/Semihosting/The-semihosting-interface?lang=en

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
18 months agoMerge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-watchdog
Tom Rini [Wed, 2 Nov 2022 13:10:30 +0000 (09:10 -0400)]
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-watchdog

- cyclic: get rid of (the need for) cyclic_init() (Rasmus)

18 months agoMerge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-spi.git
Tom Rini [Wed, 2 Nov 2022 13:09:57 +0000 (09:09 -0400)]
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-spi.git

- NPCM PSPI controller (Jim)

18 months agocyclic: get rid of cyclic_init()
Rasmus Villemoes [Fri, 28 Oct 2022 11:50:54 +0000 (13:50 +0200)]
cyclic: get rid of cyclic_init()

Currently, we must call cyclic_init() at some point before
cyclic_register() becomes possible. That turns out to be somewhat
awkward, especially with SPL, and has resulted in a watchdog callback
not being registered, thus causing the board to prematurely reset.

We already rely on gd->cyclic reliably being set to NULL by the asm
code that clears all of gd. Now that the cyclic list is a hlist, and
thus an empty list is represented by a NULL head pointer, and struct
cyclic_drv has no other members, we can just as well drop a level of
indirection and put the hlist_head directly in struct
global_data. This doesn't increase the size of struct global_data,
gets rid of an early malloc(), and generates slightly smaller code.

But primarily, this avoids having to call cyclic_init() early; the cyclic
infrastructure is simply ready to register callbacks as soon as we
enter C code.

We can still end up with schedule() being called from asm very early,
so we still need to check that gd itself has been properly initialized
[*], but once it has, gd->cyclic_list is perfectly fine to access, and
will just be an empty list.

As for cyclic_uninit(), it was never really the opposite of
cyclic_init() since it didn't free the struct cyclic_drv nor set
gd->cyclic to NULL. Rename it to cyclic_unregister_all() and use that
in test/, and also insert a call at the end of the board_init_f
sequence so that gd->cyclic_list is a fresh empty list before we enter
board_init_r().

A small piece of ugliness is that I had to add a cast in
cyclic_get_list() to silence a "discards 'volatile' qualifier"
warning, but that is completely equivalent to the existing handling of
the uclass_root_s list_head member.

[*] I'm not really sure where we guarantee that the register used for
gd contains 0 until it gets explicitly initialized, but that must be
the case, otherwise testing gd for being NULL would not make much sense.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>
Tested-by: Tim Harvey <tharvey@gateworks.com> # imx8mm-venice-*
18 months agocyclic: switch to using hlist instead of list
Rasmus Villemoes [Fri, 28 Oct 2022 11:50:53 +0000 (13:50 +0200)]
cyclic: switch to using hlist instead of list

A hlist is headed by just a single pointer, so can only be traversed
forwards, and insertions can only happen at the head (or before/after
an existing list member). But each list node still consists of two
pointers, so arbitrary elements can still be removed in O(1).

This is precisely what we need for the cyclic_list - we never need to
traverse it backwards, and the order the callbacks appear in the list
should really not matter.

One advantage, and the main reason for doing this switch, is that an
empty list is represented by a NULL head pointer, so unlike a
list_head, it does not need separate C code to initialize - a
memset(,0,) of the containing structure is sufficient.

This is mostly mechanical:

- The iterators are updated with an h prefix, and the type of the
  temporary variable changed to struct hlist_node*.

- Adding/removing is now just hlist_add_head (and not tail) and
  hlist_del().

- struct members and function return values updated.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>
Tested-by: Tim Harvey <tharvey@gateworks.com> # imx8mm-venice-*
18 months agolist.h: synchronize hlist_for_each_entry* iterators with linux
Rasmus Villemoes [Fri, 28 Oct 2022 11:50:52 +0000 (13:50 +0200)]
list.h: synchronize hlist_for_each_entry* iterators with linux

All the way back in 2013, the linux kernel updated the four
hlist_for_each_entry* iterators to require one less auxiliary
variable:

  commit b67bfe0d42cac56c512dd5da4b1b347a23f4b70a
  Author: Sasha Levin <sasha.levin@oracle.com>
  Date:   Wed Feb 27 17:06:00 2013 -0800

      hlist: drop the node parameter from iterators

Currently, there is only one "user" of any of these, namely in
fs/ubifs/super.c, but that actually uses the "new-style" form, and
is (obviously, or it wouldn't have built) inside #ifndef __UBOOT__.

Before adding actual users of these, import the version as of linux
v6.1-rc1, including the hlist_entry_safe() helper used by the new
versions.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>
Tested-by: Tim Harvey <tharvey@gateworks.com> # imx8mm-venice-*
18 months agocyclic: drop redundant cyclic_ready flag
Rasmus Villemoes [Fri, 28 Oct 2022 11:50:51 +0000 (13:50 +0200)]
cyclic: drop redundant cyclic_ready flag

We're already relying on gd->cyclic being NULL before cyclic_init() is
called - i.e., we're relying on all of gd being zeroed before entering
any C code. And when we do populate gd->cyclic, its ->cyclic_ready
member is automatically set to true. So we can actually just rely on
testing gd->cyclic itself.

The only wrinkle is that cyclic_uninit() actually did set
->cyclic_ready to false. However, since it doesn't free gd->cyclic,
the cyclic infrastructure is actually still ready (i.e., the list_head
is properly initialized as an empty list).

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>
Tested-by: Tim Harvey <tharvey@gateworks.com> # imx8mm-venice-*
18 months agocyclic: use a flag in gd->flags for recursion protection
Rasmus Villemoes [Fri, 28 Oct 2022 11:50:50 +0000 (13:50 +0200)]
cyclic: use a flag in gd->flags for recursion protection

As a preparation for future patches, use a flag in gd->flags rather
than a separate member in (the singleton) struct cyclic_drv to keep
track of whether we're already inside cyclic_run().

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>
Tested-by: Tim Harvey <tharvey@gateworks.com> # imx8mm-venice-*
18 months agoMerge branch '2022-10-31-FWU-add-FWU-multi-bank-update-feature-support'
Tom Rini [Tue, 1 Nov 2022 13:32:21 +0000 (09:32 -0400)]
Merge branch '2022-10-31-FWU-add-FWU-multi-bank-update-feature-support'

To quote the author:
The patchset adds support for the FWU Multi Bank Update[1]
feature. Certain aspects of the Dependable Boot[2] specification have
also been implemented.

The FWU multi bank update feature is used for supporting multiple
sets(also called banks) of firmware image(s), allowing the platform to
boot from a different bank, in case it fails to boot from the active
bank. This functionality is supported by keeping the relevant
information in a structure called metadata, which provides information
on the images. Among other parameters, the metadata structure contains
information on the currect active bank that is being used to boot
image(s).

Functionality is being added to work with the UEFI capsule driver in
u-boot. The metadata is read to gather information on the update bank,
which is the bank to which the firmware images would be flashed to. On
a successful completion of the update of all components, the active
bank field in the metadata is updated, to reflect the bank from which
the platform will boot on the subsequent boots.

Currently, the feature is being enabled on the STM32MP157C-DK2 and
Synquacer boards. The DK2 board boots a FIP image from a uSD card
partitioned with the GPT partioning scheme, while the Synquacer board
boots a FIP image from a MTD partitioned SPI NOR flash device.

This feature also requires changes in a previous stage of
bootloader, which parses the metadata and selects the bank to boot the
image(s) from. Support has being added in tf-a(BL2 stage) for the
STM32MP157C-DK2 board to boot the active bank images. These changes
have been merged to the upstream tf-a repository.

The patch for adding a python test for the feature has been developed,
and was sent in the version 5 of the patches[3]. However, the test
script depends on adding support for the feature on MTD SPI NOR
devices, and that is being done as part of the Synquacer
patches. Hence these set of patches do not have the test script for
the feature. That will be added through the patches for adding support
for the feauture on Synquacer platform.

[1] - https://developer.arm.com/documentation/den0118/a
[2] - https://git.codelinaro.org/linaro/dependable-boot/mbfw/uploads/6f7ddfe3be24e18d4319e108a758d02e/mbfw.pdf
[3] - https://lists.denx.de/pipermail/u-boot/2022-June/485992.html

18 months agoFWU: doc: Add documentation for the FWU feature
Sughosh Ganu [Fri, 21 Oct 2022 12:46:08 +0000 (18:16 +0530)]
FWU: doc: Add documentation for the FWU feature

Add documentation for the FWU Multi Bank Update feature. The document
describes the steps needed for setting up the platform for the
feature, as well as steps for enabling the feature on the platform.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
18 months agomkeficapsule: Add support for setting OEM flags in capsule header
Sughosh Ganu [Fri, 21 Oct 2022 12:46:07 +0000 (18:16 +0530)]
mkeficapsule: Add support for setting OEM flags in capsule header

Add support for setting OEM flags in the capsule header. As per the
UEFI specification, bits 0-15 of the flags member of the capsule
header can be defined per capsule GUID.

The oemflags will be used for the FWU Multi Bank update feature, as
specified by the Dependable Boot specification[1]. Bit
15 of the flags member will be used to determine if the
acceptance/rejection of the updated images is to be done by the
firmware or an external component like the OS.

[1] - https://git.codelinaro.org/linaro/dependable-boot/mbfw/uploads/6f7ddfe3be24e18d4319e108a758d02e/mbfw.pdf

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
18 months agomkeficapsule: Add support for generating empty capsules
Sughosh Ganu [Fri, 21 Oct 2022 12:46:06 +0000 (18:16 +0530)]
mkeficapsule: Add support for generating empty capsules

The Dependable Boot specification[1] describes the structure of the
firmware accept and revert capsules. These are empty capsules which
are used for signalling the acceptance or rejection of the updated
firmware by the OS. Add support for generating these empty capsules.

[1] - https://git.codelinaro.org/linaro/dependable-boot/mbfw/uploads/6f7ddfe3be24e18d4319e108a758d02e/mbfw.pdf

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
18 months agotest: dm: Add test cases for FWU Metadata uclass
Sughosh Ganu [Fri, 21 Oct 2022 12:46:05 +0000 (18:16 +0530)]
test: dm: Add test cases for FWU Metadata uclass

Add test cases for accessing the FWU Metadata on the sandbox
platform. The sandbox platform also uses the metadata access driver
for GPT partitioned block devices.

The FWU feature will be tested on the sandbox64 variant with a raw
capsule. Remove the FIT capsule testing from sandbox64 defconfig --
the FIT capsule test will be run on the sandbox_flattree variant.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
18 months agoFWU: cmd: Add a command to read FWU metadata
Sughosh Ganu [Fri, 21 Oct 2022 12:46:04 +0000 (18:16 +0530)]
FWU: cmd: Add a command to read FWU metadata

Add a command to read the metadata as specified in the FWU
specification and print the fields of the metadata.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
18 months agoFWU: Add support for the FWU Multi Bank Update feature
Sughosh Ganu [Fri, 21 Oct 2022 12:46:03 +0000 (18:16 +0530)]
FWU: Add support for the FWU Multi Bank Update feature

The FWU Multi Bank Update feature supports updating firmware images
to one of multiple sets(also called banks) of images. The firmware
images are clubbed together in banks, with the system booting images
from the active bank. Information on the images such as which bank
they belong to is stored as part of the metadata structure, which is
stored on the same storage media as the firmware images on a dedicated
partition.

At the time of update, the metadata is read to identify the bank to
which the images need to be flashed(update bank). On a successful
update, the metadata is modified to set the updated bank as active
bank to subsequently boot from.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
18 months agoFWU: Add boot time checks as highlighted by the FWU specification
Sughosh Ganu [Fri, 21 Oct 2022 12:46:02 +0000 (18:16 +0530)]
FWU: Add boot time checks as highlighted by the FWU specification

The FWU Multi Bank Update specification requires the Update Agent to
carry out certain checks at the time of platform boot. The Update
Agent is the component which is responsible for updating the firmware
components and maintaining and keeping the metadata in sync.

The spec requires that the Update Agent perform the following checks
at the time of boot
* Sanity check of both the metadata copies maintained by the platform.
* Get the boot index passed to U-Boot by the prior stage bootloader
  and use this value for metadata bookkeeping.
* Check if the system is booting in Trial State. If the system boots
  in the Trial State for more than a specified number of boot counts,
  change the Active Bank to be booting the platform from.

Call these checks through the main loop event at the time of platform
boot.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
18 months agoevent: Add an event for main_loop
Sughosh Ganu [Fri, 21 Oct 2022 12:46:01 +0000 (18:16 +0530)]
event: Add an event for main_loop

Add an event type EVT_MAIN_LOOP that can be used for registering
events that need to be run after the platform has been initialised and
before the main_loop function is called.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
18 months agoFWU: STM32MP1: Add support to read boot index from backup register
Sughosh Ganu [Fri, 21 Oct 2022 12:46:00 +0000 (18:16 +0530)]
FWU: STM32MP1: Add support to read boot index from backup register

The FWU Multi Bank Update feature allows the platform to boot the
firmware images from one of the partitions(banks). The first stage
bootloader(fsbl) passes the value of the boot index, i.e. the bank
from which the firmware images were booted from to U-Boot. On the
STM32MP157C-DK2 board, this value is passed through one of the SoC's
backup register. Add a function to read the boot index value from the
backup register.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
18 months agoFWU: Add helper functions for accessing FWU metadata
Sughosh Ganu [Fri, 21 Oct 2022 12:45:59 +0000 (18:15 +0530)]
FWU: Add helper functions for accessing FWU metadata

Add weak functions for getting the update index value and dfu
alternate number needed for FWU Multi Bank update
functionality.

The current implementation for getting the update index value is for
platforms with 2 banks. If a platform supports more than 2 banks, it
can implement it's own function. The function to get the dfu alternate
number has been added for platforms with GPT partitioned storage
devices. Platforms with other storage partition scheme need to
implement their own function.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
18 months agostm32mp1: Add image information for capsule updates
Sughosh Ganu [Fri, 21 Oct 2022 12:45:58 +0000 (18:15 +0530)]
stm32mp1: Add image information for capsule updates

Enabling capsule update functionality on the platform requires
populating information on the images that are to be updated using the
functionality. Do so for the DK2 board.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
18 months agostm32mp1: Add a node for the FWU metadata device
Sughosh Ganu [Fri, 21 Oct 2022 12:45:57 +0000 (18:15 +0530)]
stm32mp1: Add a node for the FWU metadata device

The FWU metadata structure is accessed through the driver model
interface. On the stm32mp157c dk2 and ev1 boards, the FWU metadata is
stored on the uSD card. Add the fwu-mdata node on the u-boot specifc
dtsi file for accessing the metadata structure.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
18 months agoFWU: Add FWU metadata access driver for GPT partitioned block devices
Sughosh Ganu [Fri, 21 Oct 2022 12:45:56 +0000 (18:15 +0530)]
FWU: Add FWU metadata access driver for GPT partitioned block devices

In the FWU Multi Bank Update feature, the information about the
updatable images is stored as part of the metadata, on a separate
partition. Add a driver for reading from and writing to the metadata
when the updatable images and the metadata are stored on a block
device which is formatted with GPT based partition scheme.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
18 months agoFWU: Add FWU metadata structure and driver for accessing metadata
Sughosh Ganu [Fri, 21 Oct 2022 12:45:55 +0000 (18:15 +0530)]
FWU: Add FWU metadata structure and driver for accessing metadata

In the FWU Multi Bank Update feature, the information about the
updatable images is stored as part of the metadata, which is stored on
a dedicated partition. Add the metadata structure, and a driver model
uclass which provides functions to access the metadata. These are
generic API's, and implementations can be added based on parameters
like how the metadata partition is accessed and what type of storage
device houses the metadata.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
18 months agodt/bindings: Add bindings for GPT based FWU Metadata storage device
Sughosh Ganu [Fri, 21 Oct 2022 12:45:54 +0000 (18:15 +0530)]
dt/bindings: Add bindings for GPT based FWU Metadata storage device

Add bindings needed for accessing the FWU metadata partitions. These
include the compatible string which point to the access method and the
actual device which stores the FWU metadata.

The current patch adds basic bindings needed for accessing the
metadata structure on GPT partitioned block devices.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
18 months agoMerge branch '2022-10-31-vbe-implement-the-full-firmware-flow'
Tom Rini [Mon, 31 Oct 2022 18:43:04 +0000 (14:43 -0400)]
Merge branch '2022-10-31-vbe-implement-the-full-firmware-flow'

To quote Simon:
This series provides an implementation of VBE from TPL through to U-Boot
proper, using VBE to load the relevant firmware stages. It buils a single
image.bin file containing all the phases:

   TPL - initial phase, loads VPL using binman symbols
   VPL - main firmware phase, loads SPL using VBE parameters
   SPL - loads U-Boot proper using VBE parameters
   U-Boot - final firmware phase, where OS booting is processed

This series does not include the OS-booting phase. That will be the
subject of a future series.

The implementation is entirely handled by sandbox. It should be possible
to enable this on a real board without much effort, but that is also the
subject of a future series.

18 months agovbe: Add a test for the VBE flow into U-Boot proper
Simon Glass [Fri, 21 Oct 2022 00:23:20 +0000 (18:23 -0600)]
vbe: Add a test for the VBE flow into U-Boot proper

Add a test which checks that VBE boots correctly from TPL through to
U-Boot proper.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agovbe: Add a command to show the VBE state
Simon Glass [Fri, 21 Oct 2022 00:23:19 +0000 (18:23 -0600)]
vbe: Add a command to show the VBE state

Add a VBE comment which shows the current state. Currently this is just
the phases which booted via VBE.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agovbe: Record which phases loaded using VBE
Simon Glass [Fri, 21 Oct 2022 00:23:18 +0000 (18:23 -0600)]
vbe: Record which phases loaded using VBE

We expect VPL and SPL to load using VBE. Add a record of this so we can
check it in U-Boot proper.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agovbe: Use a manual test
Simon Glass [Fri, 21 Oct 2022 00:23:17 +0000 (18:23 -0600)]
vbe: Use a manual test

Use a manual test for the VBE test, so we can make the pytest and the
C unit test work together properly.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agovpl: Allow signature verification
Simon Glass [Fri, 21 Oct 2022 00:23:16 +0000 (18:23 -0600)]
vpl: Allow signature verification

Add the required Kconfig option so that signatures can be verified when
loading a configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agosandbox: Add an image for VPL
Simon Glass [Fri, 21 Oct 2022 00:23:15 +0000 (18:23 -0600)]
sandbox: Add an image for VPL

Use binman to build an image which includes all the U-Boot phases so that
a full VBE boot can take place with just that image.bin file. Attach the
image file to mmc2 so it can be loaded.

VBE is used to load images in two phases:

   - In VPL, VBE decides which SPL image to load
   - In SPL, VBE decides which U-Boot image to load

The latter should really be determined by VPL, since it does the full
signature verification on the selected configuration. However, we have
separate configurations for SPL and U-Boot proper, so for now we keep it
simple and have SPL do its own verification. This will need to be
tidied up later.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agovbe: Add info about the VBE device to the fwupd node
Simon Glass [Fri, 21 Oct 2022 00:23:14 +0000 (18:23 -0600)]
vbe: Add info about the VBE device to the fwupd node

At present we put the driver in the /chosen node in U-Boot. This is a bit
strange, since U-Boot doesn't normally use that node itself. It is better
to put it under the bootstd node.

To make this work we need to copy create the node under /chosen when
fixing up the device tree. Copy over all the properties so that fwupd
knows what to do.

Update the sandbox device tree accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agovbe: Add Kconfig options for VPL
Simon Glass [Fri, 21 Oct 2022 00:23:13 +0000 (18:23 -0600)]
vbe: Add Kconfig options for VPL

Enable the various features needed in VPL, by adding Kconfig options.

Update the defconfig for sandbox_vpl so that the build for each phase
includes what is needed. Drop LZMA for now and make sure partition support
is omitted in SPL, since it is not needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agovbe: Drop the U-Boot prefix from the version
Simon Glass [Fri, 21 Oct 2022 00:23:12 +0000 (18:23 -0600)]
vbe: Drop the U-Boot prefix from the version

We don't need the U-Boot prefix on the version and in fact it is harmful
since pytest gets confused seeing the U-Boot banner bring displayed when
the version is printed.

Drop the prefix from the string.

We could produce an entirely new string from the component parts, but this
adds to the rodata size and would break the use of version_string as the
only thing which holds this information.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agovbe: Move OS implementation into a separate file
Simon Glass [Fri, 21 Oct 2022 00:23:11 +0000 (18:23 -0600)]
vbe: Move OS implementation into a separate file

Move this into its own file so it can be built only by U-Boot proper.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agovbe: Support reading the next SPL phase via VBE
Simon Glass [Fri, 21 Oct 2022 00:23:10 +0000 (18:23 -0600)]
vbe: Support reading the next SPL phase via VBE

Add an SPL loader to obtain the next-phase binary from a FIT provided
by the VBE driver.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agovbe: Support selecting operations by SPL phase
Simon Glass [Fri, 21 Oct 2022 00:23:09 +0000 (18:23 -0600)]
vbe: Support selecting operations by SPL phase

VBE supports booting firmware during the SPL phases, i.e. so that VPL can
start SPL and SPL can start U-Boot.

It also supports booting an OS, when in U-Boot.

As a first step towards these features, add functions to indicate the
current VBE phase. The firmware selection is done in VPL and the OS
selection is done in U-Boot proper.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agosandbox: Support obtaining the next phase from an image
Simon Glass [Fri, 21 Oct 2022 00:23:08 +0000 (18:23 -0600)]
sandbox: Support obtaining the next phase from an image

At present sandbox runs the next phase from discrete executables, so for
example u-boot-tpl runs u-boot-vpl to get to the next phase.

In some cases the phases are all built into a single firmware image, as is
done for real boards. Add support for this to sandbox.

Make it higher priority so that it takes precedence over the existing
method.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agospl: Allow multiple loaders of the same time
Simon Glass [Fri, 21 Oct 2022 00:23:07 +0000 (18:23 -0600)]
spl: Allow multiple loaders of the same time

At present we only support a single loader of each time. Extra ones are
ignored. This means that only one BOOT_DEVICE_BOARD can be used in the SPL
image.

This is inconvenient since we sometimes want to provide several
board-specific drivers, albeit at different priorties. Add support for
this.

This should have no functional change for existing boards.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agovbe: Use a warning for a failed requests
Simon Glass [Fri, 21 Oct 2022 00:23:06 +0000 (18:23 -0600)]
vbe: Use a warning for a failed requests

Optional requests should present a warning rather than an error. Update
the log call.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agovbe: Rename vbe_fixup to vbe_request
Simon Glass [Fri, 21 Oct 2022 00:23:05 +0000 (18:23 -0600)]
vbe: Rename vbe_fixup to vbe_request

The vbe_fixup file handles device tree fixups, but these are called OS
requests in VBE. Rename the file to reflect its wider purpose.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agoimage: Allow loading a FIT image for a particular phase
Simon Glass [Fri, 21 Oct 2022 00:23:04 +0000 (18:23 -0600)]
image: Allow loading a FIT image for a particular phase

Add support for filtering out FIT images by phase. Rather than adding yet
another argument to this already overloaded function, use a composite
value, where the phase is only added in if needed.

The FIT config is still selected (and verified) as normal, but the images
are selected based on the phase.

Tests for this come in a little later, as part of the updated VPL test.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agoimage: Add the concept of a phase to FIT
Simon Glass [Fri, 21 Oct 2022 00:23:03 +0000 (18:23 -0600)]
image: Add the concept of a phase to FIT

We want to be able to mark an image as related to a phase, so we can
easily load all the images for SPL or for U-Boot proper.

Add this to the FIT specification, along with some access functions.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agosandbox: Add a way to specify the sandbox executable
Simon Glass [Fri, 21 Oct 2022 00:23:02 +0000 (18:23 -0600)]
sandbox: Add a way to specify the sandbox executable

At present the sandbox executable is assumed to be arg[0] but this only
works for a single jump (e.g. from SPL to U-Boot). Add a new arg to solve
this issue, along with a detailed comment.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agosandbox: Generalise SPL booting
Simon Glass [Fri, 21 Oct 2022 00:23:01 +0000 (18:23 -0600)]
sandbox: Generalise SPL booting

At present sandbox only supports jumping to a file, to get to the next
U-Boot phase. We want to support other methods, so update the code to
use an enum for the method. Also use the

Use board_boot_order() to set the order, so we can add more options.
Also add the MMC methods into the BOOT_DEVICE enum so that booting
from MMC can be supported.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agoimage: Move comment for fit_conf_find_compat()
Simon Glass [Fri, 21 Oct 2022 00:23:00 +0000 (18:23 -0600)]
image: Move comment for fit_conf_find_compat()

Move this comment to the header file, where the APIs should be defined.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agosandbox: Drop message about writing sandbox state
Simon Glass [Fri, 21 Oct 2022 00:22:59 +0000 (18:22 -0600)]
sandbox: Drop message about writing sandbox state

This happens every time sandbox moves to the next phase so is not very
interesting. Display the message only when debugging.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
18 months agodm: mmc: Allow sandbox emulator to build without writes
Simon Glass [Fri, 21 Oct 2022 00:22:58 +0000 (18:22 -0600)]
dm: mmc: Allow sandbox emulator to build without writes

When MMC_WRITE is disabled this driver produced a build error. Fix this.

Also update a comment while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
18 months agodm: blk: mmc: Tidy up some Makefile rules for SPL
Simon Glass [Fri, 21 Oct 2022 00:22:57 +0000 (18:22 -0600)]
dm: blk: mmc: Tidy up some Makefile rules for SPL

Use the correct SPL_TPL_ variable so that these features can be enabled in
TPL and VPL as needed.

Disable it by default in TPL to avoid any code-size increase. No boards
are actually using it since the Makefile rules don't allow including
drivers/block/ with TPL_DM enabled. It can be manually enabled as needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
18 months agobloblist: Drop debugging
Simon Glass [Fri, 21 Oct 2022 00:22:56 +0000 (18:22 -0600)]
bloblist: Drop debugging

Disable debugging by default since this implementation is stable now.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agousb: Update the test to cover reading and writing
Simon Glass [Fri, 21 Oct 2022 00:22:55 +0000 (18:22 -0600)]
usb: Update the test to cover reading and writing

Add test coverage for blk_write() as well.

The blk_erase() is not tested for now as the USB stor interface does not
support erase.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agodm: blk: Add udevice functions
Simon Glass [Fri, 21 Oct 2022 00:22:54 +0000 (18:22 -0600)]
dm: blk: Add udevice functions

At present we have functions called blk_dread(), etc., which take a
struct blk_desc * to refer to the block device. Add some functions which
use udevice instead, since this is more in keeping with how driver model
is supposed to work.

Update one of the tests to use this.

Note that it would be nice to update the functions in disk-uclass.c to use
these new functions. However they are not quite the same. For example,
disk_blk_read() adds the partition offset to 'start' when calling the
cache read/fill functions, but does not with part_blk_read(), which does
the addition itself. So as designed the code is duplicated.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agodisk: Rename block_dev to desc
Simon Glass [Fri, 21 Oct 2022 00:22:53 +0000 (18:22 -0600)]
disk: Rename block_dev to desc

The use of 'block_dev' in this context is confusing, since it is not a
pointer to a device, just to some information about it. Rename this to
'desc', as is more commonly used, since it is a block descriptor.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heinrich Schuchardt <xypron.glplk@gmx.de>
18 months agodisk: Rename block functions
Simon Glass [Fri, 21 Oct 2022 00:22:52 +0000 (18:22 -0600)]
disk: Rename block functions

Use the uclass type as the first part of the function name, to be
consistent with the methods in other block drivers.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agobootstd: Add a way to set up a bootflow
Simon Glass [Fri, 21 Oct 2022 00:22:51 +0000 (18:22 -0600)]
bootstd: Add a way to set up a bootflow

Add a function to init a bootflow, to reduce code duplication.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agotest: Support tests which can only be run manually
Simon Glass [Fri, 21 Oct 2022 00:22:50 +0000 (18:22 -0600)]
test: Support tests which can only be run manually

At present we normally write tests either in Python or in C. But most
Python tests end up doing a lot of checks which would be better done in C.
Checks done in C are orders of magnitude faster and it is possible to get
full access to U-Boot's internal workings, rather than just relying on
the command line.

The model is to have a Python test set up some things and then use C code
(in a unit test) to check that they were done correctly. But we don't want
those checks to happen as part of normal test running, since each C unit
tests is dependent on the associate Python tests, so cannot run without
it.

To acheive this, add a new UT_TESTF_MANUAL flag to use with the C 'check'
tests, so that they can be skipped by default when the 'ut' command is
used. Require that tests have a name ending with '_norun', so that pytest
knows to skip them.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agotest: Update tests to use the skip feature
Simon Glass [Fri, 21 Oct 2022 00:22:49 +0000 (18:22 -0600)]
test: Update tests to use the skip feature

Some tests currently return 0 when they want to be skipped. Update them to
return -EAGAIN instead, so they are counted as skipped.

A few tests are in two parts, with the latter part being skipped in
certain situations. Split these into two and use the correct condition for
the second part.

Signed-off-by: Simon Glass <sjg@chromium.org>
18 months agotest: Report skippped tests
Simon Glass [Fri, 21 Oct 2022 00:22:48 +0000 (18:22 -0600)]
test: Report skippped tests

At present it is possible for a test to skip itself by returning -EAGAIN
but this is not recorded. An existing example is in test_pre_run() with
the "Console recording disabled" check.

Keep a track of skipped tests and report the total at the end.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
18 months agobinman: Support writing symbols into ELF files
Simon Glass [Fri, 21 Oct 2022 00:22:47 +0000 (18:22 -0600)]
binman: Support writing symbols into ELF files

In some cases the ELF version of SPL builds may be packaged, rather
than a binary .bin file. Add support for this.

Signed-off-by: Simon Glass <sjg@chromium.org>