[PATCH] bootm: add fitimage command line to bootargs
Ahmad Fatoum
a.fatoum at pengutronix.de
Thu Aug 27 07:16:53 PDT 2026
Hello Thomas,
On 8/27/26 2:16 PM, Thomas Bonnefille wrote:
> Since FIT image specification v0.9, it is now possible to pass command
> line arguments for the next boot stage in FIT images.
>
> Add parsing of the cmdline optional property when reading the fitimage.
> This create a `linux.bootargs.fit` global variable that will be appended
> to the command line when CONFIG_FLEXIBLE_BOOTARGS is enabled.
Thanks for your patch! I find this much cleaner than the current way of
injecting command-line arguments via FIT (set fdt /chosen/bootargs and
set global.linux.bootargs_append=1).
It appears to me barebox would be the first user of this? I couldn't
find an implementation in U-Boot. I guess most people are happy with
setting bootargs in their boot scripts instead.
Some comments below.
> +static void bootm_fit_config_cmdline(struct device_node *config)
> +{
> + const char *cmdline;
if (!IS_ENABLED(CONFIG_FLEXIBLE_BOOTARGS))
return;
I never had a project without it myself, but just so the pr_info below
is skipped.
> +
> + if (of_property_read_string(config, "cmdline", &cmdline))
> + return;
> +
> + globalvar_add_simple("linux.bootargs.fit", cmdline);
Once you set a global variable, it stays set for the duration of
barebox's execution. So if you have global.boot.default="fit recovery"
and the fit boot aborts prematurely, you may end up with fit's
command-line while your recovery target runs.
Variables that start with linux.bootargs.dyn. workaround this: They are
reset if a boot target fails (or returns because it's a dry run).
Another thing you need to account for here is the order of bootargs. All
bootargs are concatenated lexicographically, but what would a user
expect that points a bootloader spec or extlinux file at a FIT?
I think it makes more sense that bootloader spec would take precedence
over FIT as it's easier to change by the user.
So my idea is that you would set the global variable
linux.bootargs.dyn.bootentries.fit instead.
This should then be naturally concatenated before
linux.bootargs.dyn.bootentries.
This also takes care of possible compatibility problems. We wouldn't
want to clobber a linux.bootargs.dyn.fit (especially without an entry in
the migration notes) that an out-of-tree boot script is setting, but I
think the namespace linux.bootargs.dyn.bootentries.* is fair game,
because barebox has been using it for years already.
It also should be fairly easy to add a test for this:
In ./test/testdata/*.its add a cmdline property and then in
test_fit.py::test_fit add a check for /chosen/bootargs inside the with:
clause.
Above test doesn't verify signatures though and I believe it would
actually break. You can verify by setting global.bootm.verify=signature
after having built with CONFIG_CRYPTO_BUILTIN_DEVELOPMENT_KEYS=y.
I will Cc you on a RFC patch shortly.
Cheers,
Ahmad
> +
> + pr_info("Using command line from FIT configuration: %s\n", cmdline);
> +}
> +
> static enum filetype bootm_fit_update_os_header(struct image_data *data)
> {
> size_t size;
> @@ -146,6 +159,8 @@ int bootm_open_fit(struct image_data *data, bool override)
> goto err;
> }
>
> + bootm_fit_config_cmdline(fit_config);
> +
> loadable_from_fit_os(data, fit, fit_config);
> if (override)
> data->is_override.os = true;
>
> ---
> base-commit: df1055a2e0ddd3f96939327f2f0eb9db13a2bdc6
> change-id: 20260827-add-cmdline-fitimage-42f6b2e930c1
>
> Best regards,
> --
> Thomas Bonnefille <thomas.bonnefille at bootlin.com>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list