Hi He,
On 2026-10-13T13:02:35, He Yong <[email protected]> wrote:
> bootstd: Add a bootmeth for scripts in raw partitions
>
> Some disk layouts store a U-Boot script image directly in a named
> partition, without a filesystem. Add a script_raw bootmeth to find these
> images without a board-specific bootcmd.
>
> Read the image size from the first block and bound it by the partition
> size and configured limit. Support legacy scripts and FIT scripts with
> embedded data, using the shared script parser and execution handler.
> Validate the FIT structure and reject external data before verification.
>
> Keep raw-partition scanning independently selectable from filesystem
> script lookup. Document the configuration and self-contained FIT policy.
> Enable the method for sandbox and test it in C, using a generated GPT disk
> with valid images and malformed or unsupported images.
>
> Signed-off-by: He Yong <[email protected]>
>
> MAINTAINERS | 1 +
> arch/sandbox/dts/test.dts | 12 +++
> boot/Kconfig | 26 +++++
> boot/Makefile | 1 +
> boot/bootmeth_script.c | 4 +-
> boot/bootmeth_script_raw.c | 183
> ++++++++++++++++++++++++++++++++++
> configs/sandbox_defconfig | 1 +
> doc/develop/bootstd/index.rst | 1 +
> doc/develop/bootstd/script_raw.rst | 51 ++++++++++
> doc/device-tree-bindings/bootmeth.txt | 1 +
> include/bootmeth.h | 12 +++
> test/boot/bootflow.c | 84 +++++++++++++++-
> test/boot/bootmeth.c | 31 +++++-
> test/py/img/__init__.py | 2 +
> test/py/img/script_raw.py | 107 ++++++++++++++++++++
> test/py/tests/test_ut.py | 9 ++
> 16 files changed, 518 insertions(+), 8 deletions(-)
> diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
> @@ -187,6 +188,10 @@
> +
> + script_raw {
> + compatible = "u-boot,script-raw";
> + };
Adding the bootmeth to the bootstd node means every existing bootstd
test sees it, which is why this patch has to touch
bootmeth_cmd_list(), bootmeth_cmd_order(), bootflow_iter(),
bootflow_iter_glob(), bootflow_iter_disable() and
bootflow_cmd_scan_e(). Please can you follow bootflow_rauc() instead?
That test binds the bootmeth with device_bind() and DM_DRIVER_REF()
inside the test itself, so the other tests stay as they are and the
new test can run on its own.
> diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
> @@ -222,7 +222,10 @@ static int bootflow_cmd_scan_e(struct unit_test_state
> *uts)
> - ut_assertok(run_command("bootflow scan -aleGH", 0));
> + /* Exercise the filesystem methods without global-method scanning. */
> + ut_assertok(bootmeth_set_order(IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) ?
> + "extlinux efi bls" : "extlinux efi"));
> + ut_assertok(run_command("bootflow scan -aleH", 0));
This drops the only coverage of the -G flag on 'bootflow scan'. With
the approach above, this change is no longer needed.
> diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
> @@ -1948,4 +1975,57 @@ static int bootdev_hunt_fallthrough(struct
> unit_test_state *uts)
> + static const int errors[] = {
> + 0, 0, -EOPNOTSUPP, -EINVAL, -EINVAL, -E2BIG,
> + -ENOENT, -ENOEXEC, -EINVAL, -E2BIG, -EINVAL, -EINVAL,
> + };
This table is tied to the order of 'CASES' in 'script_raw.py' but
nothing says so. Please can you add a comment giving the case name for
each entry, so the two can be kept in sync?
> diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
> @@ -1948,4 +1975,57 @@ static int bootdev_hunt_fallthrough(struct
> unit_test_state *uts)
> +BOOTSTD_TEST(bootflow_script_raw, UTF_DM | UTF_SCAN_FDT | UTF_CONSOLE);
> +#endif
Please keep the /* CONFIG_SANDBOX */ comment on the #endif
> diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py
> @@ -760,6 +761,14 @@ def test_ut_dm_init_bootstd(ubman):
> [email protected]('sandbox')
> [email protected]('bootmeth_script_raw')
> [email protected]('sgdisk')
> +def test_ut_dm_init_script_raw(ubman):
> + """Prepare the disk used by the raw script C bootflow test."""
> + setup_script_raw_image(ubman)
If sgdisk is not installed, this setup is skipped but the C test still
runs and fails because 'mmc12.img' does not exist. The other bootstd
images use sfdisk (via 'fs_helper') and are created from
test_ut_dm_init_bootstd(), so please can you do the same here? That
avoids a new tool requirement and a separate init step.
Regards,
Simon