[PATCH v3 0/2] bootstd: New bootmeth for RAUC A/B systems
Martin Schwan
M.Schwan at phytec.de
Thu Jun 26 15:47:00 CEST 2025
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Hi everyone,
On Fri, 2025-06-06 at 06:59 +0000, Martin Schwan wrote:
> Hi Simon,
>
> On Thu, 2025-06-05 at 11:29 -0600, Simon Glass wrote:
> > Hi Martin,
> >
> > On Wed, 4 Jun 2025 at 06:16, Martin Schwan <m.schwan at phytec.de>
> > wrote:
> > >
> > > This series implements a new bootmeth for RAUC A/B systems. RAUC
> > > (Robust
> > > Auto Update Controller) is a lightweight update client, providing
> > > "Safe
> > > and Secure OTA Updates for Embedded Linux". See the following
> > > links
> > > for
> > > more information about RAUC:
> > >
> > > https://rauc.io/
> > > https://rauc.readthedocs.io/en/latest/
> > >
> > > PHYTEC uses RAUC in its Yocto based distribution "Ampliphy" as
> > > the
> > > default way of updating embedded devices based on PHYTEC
> > > hardware.
> > > So
> > > far, the logic selecting the correct partitions and files to boot
> > > was
> > > being implemented in the U-Boot environment. While this is a
> > > straightforward way to do it, adding and supporting new platforms
> > > became
> > > somewhat tedious and is platform-specific. The introduction of U-
> > > Boot's
> > > "Standard Boot" provided a convincing alternative, promising a
> > > simpler
> > > and more portable way of booting, even for RAUC systems. This led
> > > me to
> > > implement a new bootmeth supporting RAUC A/B systems. Note, that
> > > this
> > > new bootmeth is not proprietary to PHYTEC products and is
> > > designed
> > > to
> > > work on other hardware with a RAUC A/B system, too.
> > >
> > > The bootmeth currently only supports symmetric A/B partitioning
> > > layouts.
> > > E.g. A/rescue is not (yet) supported. The partition indexes and
> > > default
> > > slot tries can be specified via configuration options.
> > >
> > > For now, the bootmeth_rauc uses a similar approach for loading
> > > the
> > > Kernel and device tree as the bootmeth_script, in that it
> > > requires
> > > a FIT
> > > containing a U-Boot script loading the desired distro. It could
> > > be
> > > possible to support booting without a script and load the Kernel
> > > and DT
> > > directly with this bootmeth, but I found the script method to be
> > > very
> > > flexible for now, in letting the distro decide what to load.
> > >
> > > The bootmeth_rauc was tested on a phyBOARD-Pollux i.MX8M Plus [1]
> > > with
> > > BSP-Yocto-Ampliphy-i.MX8MP-PD24.1.2 [2].
> > >
> > > Supported boot devices are currently only MMC devices, but it
> > > should be
> > > possible to add SPI flashes in the future.
> > >
> > > To test this patch stack with PHYTEC's phyBOARD-Pollux i.MX8M
> > > Plus
> > > board, you need to adjust the boot files to include the
> > > boot.scr.uimg
> > > containing the distro's boot script and set "optargs" to
> > > "${raucargs}"
> > > in it. Also disable any legacyboot in the U-Boot environment and
> > > simply
> > > boot with Standard Boot:
> > >
> > > bootmeth order rauc
> > > bootflow scan -lb
> > >
> > > Regards,
> > > Martin
> > >
> > > [1]:
> > > https://www.phytec.eu/en/produkte/single-board-computer/phyboard-pollux/
> > > [2]:
> > > https://download.phytec.de/Software/Linux/BSP-Yocto-i.MX8MP/BSP-Yocto-Ampliphy-i.MX8MP-PD24.1.2/
> > >
> > > ---
> > > Changes in v3:
> > > - Invert if-statement check for setting default value of
> > > BOOT_*_LEFT env
> > > variables. This would falsely trigger an error message before.
> > > - Link to v2:
> > > https://lore.kernel.org/r/20250602-wip-bootmeth-rauc-v2-0-9d2384131486@phytec.de
> > >
> > > Changes in v2:
> > > - Remove LOG_DEBUG from boot/bootmeth_rauc.c
> > > - Reorder asm/cache.h include to be last
> > > - Do not check for RAUC-specific files in the rootfs anymore.
> > > This
> > > does
> > > not work on encrypted root filesystems and is not a stable
> > > indicator
> > > for a functioning RAUC system.
> > > - Add a description of the term "slot" in the corresponding
> > > private
> > > struct.
> > > - Remove boot tries left from struct distro_rauc_slot. The boot
> > > tries
> > > are read directly from the environment, as that's the only
> > > correct
> > > source RAUC is relying on.
> > > - Remove the current boot_order from struct distro_rauc_priv, for
> > > the
> > > same reason as above (env is correct source).
> > > - Add function for retrieving a slot struct, to ease finding the
> > > right
> > > one when e.g. iterating or getting by name.
> > > - Fix multiline comments.
> > > - Fix various if-statements which were explicitly comparing to 0
> > > or
> > > NULL.
> > > - Free various, temporary instances of allocated string lists.
> > > - Set default env values for BOOT_ORDER and associated
> > > BOOT_*_LEFT
> > > variables. These variables are mandatory for RAUC to work.
> > > - Use calloc() instead of malloc() for allocating the private
> > > slots.
> > > - Use config options for configuring the partitions and default
> > > boot
> > > order, instead of setting them via the U-Boot env.
> > > - Use bootstd_get_prefixes()'s return value and check all
> > > available
> > > prefixes for the boot script.
> > > - Add a proper boot order selection logic for the rauc bootmeth,
> > > similar
> > > to the previous environment scripting, with fallbacks and slot
> > > try
> > > checks.
> > > - Introduce config option for resetting all slot tries in case
> > > they
> > > are
> > > all zero. This may prevent a system from locking up in the
> > > bootloader.
> > > - Rename env variable "mmcroot" to "distro_rootpart", to be in
> > > line
> > > with
> > > "distro_bootpart".
> > > - Change the bootmeth flag to "global", as the rauc bootmeth does
> > > not
> > > work for individual partitions.
> > > - Update documentation accordingly.
> > > - Link to v1:
> > > https://lore.kernel.org/r/20250129-wip-bootmeth-rauc-v1-0-6308e732f314@phytec.de
> > >
> > > ---
> > > Martin Schwan (2):
> > > bootstd: Add implementation for bootmeth rauc
> > > doc: Add description for bootmeth rauc
> > >
> > > boot/Kconfig | 51 +++++
> > > boot/Makefile | 1 +
> > > boot/bootmeth_rauc.c | 432
> > > +++++++++++++++++++++++++++++++++++++++
> > > doc/develop/bootstd/index.rst | 1 +
> > > doc/develop/bootstd/overview.rst | 1 +
> > > doc/develop/bootstd/rauc.rst | 56 +++++
> > > 6 files changed, 542 insertions(+)
> > > ---
> > > base-commit: b22a276f039f818d5564bec6637071cfc8a7e432
> > > change-id: 20250129-wip-bootmeth-rauc-03b5e2dd88f4
> > >
> > > Best regards,
> > > --
> > > Martin Schwan <m.schwan at phytec.de>
> > >
> >
> > Great to see this. Could you please add a test, e.g. to
> > test/boot/bootflow.c ? Let me know if you need help.
>
> Thank you! :)
>
> I will have a look into adding a test for it. Sorry, that I didn't
> make
> it for the first iteration, as you mentioned it previously. Will it
> be
> okay, if I add this in a separate patch?
>
> I'll probably not have time for this until end of June, as I'm on
> vacation the next two weeks. But I definitely have it on my agenda.
I actually could use some help here. I had a look at U-Boot unit tests,
but cannot quite get how to run the particular bootstd tests. With
"make check", there are way to many checks being run, most of which
don't seem to work on my workstation.
What I also tried:
Installed dependencies for testing:
python -m venv venv
source venv/bin/activate
pip install -r test/py/requirements.txt
Built the U-Boot sandbox:
make sandbox_defconfig all
Ran sandbox tests for bootstd manually:
./u-boot -c "ut bootstd"
But that also doesn't seem to produce the desired output:
...
test/boot/bootflow.c:1358, bootstd_images(): 0 ==
bootstd_get_priv(&std): Expected 0x0 (0), got 0xffffffed (-19)
Test 'bootstd_images' failed 1 times
Test: expo_base: expo.c (flat tree)
test/boot/expo.c:90, expo_base(): 0 ==
uclass_first_device_err(UCLASS_VIDEO, &dev): Expected 0x0 (0), got
0xffffffed (-19)
Test 'expo_base' failed 1 times
Test: expo_object: expo.c (flat tree)
Test: expo_object_attr: expo.c (flat tree)
test/boot/expo.c:304, expo_object_attr(): ofnode_valid(node)
Test 'expo_object_attr' failed 1 times
Test: expo_object_menu: expo.c (flat tree)
Test: expo_render_image: expo.c (flat tree)
test/boot/expo.c:474, expo_render_image(): 0 ==
uclass_first_device_err(UCLASS_VIDEO, &dev): Expected 0x0 (0), got
0xffffffed (-19)
Test 'expo_render_image' failed 1 times
Test: expo_scene: expo.c (flat tree)
Test: expo_scene_no_id: expo.c (flat tree)
Test: expo_test_build: expo.c (flat tree)
test/boot/expo.c:785, expo_test_build(): ofnode_valid(node)
Test 'expo_test_build' failed 1 times
Test: test_bootflow_cmdline_set: bootflow.c
Test: test_image_phase: image.c
Test: vbe_test_fixup_norun: skipped as it is manual (use -f to run it)
Tests run: 58, 102 ms, average: 1 ms, skipped: 2, failures: 55
Even the examples provide in
https://docs.u-boot.org/en/latest/develop/tests_sandbox.html#running-sandbox-tests-directly
do not run correctly:
$ ./u-boot -T -c "ut dm gpio"
Bloblist at 100 not found (err=-2)
U-Boot 2025.07-rc4-00510-g5b4924d8b731-dirty (Jun 26 2025 - 15:34:27
+0200)
Reset Status: WARM Reset Status: COLD
Model: sandbox
DRAM: 256 MiB
using memory 0x1b528000-0x1f52a000 for malloc()
Core: 256 devices, 87 uclasses, devicetree: board
MMC: Can't map file 'mmc1.img': Invalid argument
mmc1: Unable to map file 'mmc1.img'
Can't map file 'mmc1.img': Invalid argument
mmc1: Unable to map file 'mmc1.img'
mmc1 - probe failed: -1
mmc2: 2 (SD)Can't map file 'mmc1.img': Invalid argument
mmc1: Unable to map file 'mmc1.img'
, mmc0: 0 (SD)
Loading Environment from nowhere... OK
In: serial,cros-ec-keyb,usbkbd
Out: serial,vidconsole
Err: serial,vidconsole
Model: sandbox
Net: eth0: eth at 10002000, eth5: eth at 10003000, eth3: sbe5, eth6:
eth at 10004000, eth8: phy-test-eth, eth4: dsa-test-eth, eth2: lan0, eth7:
lan1
Test 'gpio' not found
Tests run: 0, failures: 0
In short: What's the usual, correct way to individually test a bootstd
logic/unit test? I have the feeling I'm doing something fundamentally
wrong here. Before I go into implementing a new test in
test/boot/bootflow.c...
Regards,
Martin
>
> Regards,
> Martin
>
> >
> > Regards,
> > Simon
-----BEGIN PGP SIGNATURE-----
iHUEARYKAB0WIQTh9jc8NBVKmMG9gxNR3YU452eTAQUCaF1PUwAKCRBR3YU452eT
ARldAQDZNIWhaDhMgRvoTOzt8Bp8S6UBeouOI3jho2INjPVC/AD/bMrAfeqF/Nas
9fM5fvMMu9SXJILK59Sck7Z/11LHzAE=
=DnBy
-----END PGP SIGNATURE-----
More information about the U-Boot
mailing list