* [PATCH] bootm: add fitimage command line to bootargs
@ 2026-08-27 12:16 Thomas Bonnefille
2026-08-27 14:16 ` Ahmad Fatoum
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Bonnefille @ 2026-08-27 12:16 UTC (permalink / raw)
To: Sascha Hauer, open list:BAREBOX
Cc: Thomas Petazzoni, Miquèl Raynal, Hervé Codina,
Thomas Bonnefille
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.
Signed-off-by: Thomas Bonnefille <thomas.bonnefille@bootlin.com>
---
common/bootm-fit.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/common/bootm-fit.c b/common/bootm-fit.c
index f7742b8717..313d12ca74 100644
--- a/common/bootm-fit.c
+++ b/common/bootm-fit.c
@@ -3,6 +3,7 @@
#include <bootm.h>
#include <image-fit.h>
#include <bootm-fit.h>
+#include <globalvar.h>
#include <memory.h>
#include <string.h>
#include <zero_page.h>
@@ -97,6 +98,18 @@ static bool bootm_fit_config_valid(struct fit_handle *fit,
return !!fit_has_image(fit, config, "kernel");
}
+static void bootm_fit_config_cmdline(struct device_node *config)
+{
+ const char *cmdline;
+
+ if (of_property_read_string(config, "cmdline", &cmdline))
+ return;
+
+ globalvar_add_simple("linux.bootargs.fit", cmdline);
+
+ 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@bootlin.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] bootm: add fitimage command line to bootargs
2026-08-27 12:16 [PATCH] bootm: add fitimage command line to bootargs Thomas Bonnefille
@ 2026-08-27 14:16 ` Ahmad Fatoum
2026-08-27 15:08 ` Ahmad Fatoum
0 siblings, 1 reply; 3+ messages in thread
From: Ahmad Fatoum @ 2026-08-27 14:16 UTC (permalink / raw)
To: Thomas Bonnefille, Sascha Hauer, open list:BAREBOX
Cc: Thomas Petazzoni, Miquèl Raynal, Hervé Codina
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@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 |
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] bootm: add fitimage command line to bootargs
2026-08-27 14:16 ` Ahmad Fatoum
@ 2026-08-27 15:08 ` Ahmad Fatoum
0 siblings, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2026-08-27 15:08 UTC (permalink / raw)
To: Thomas Bonnefille, Sascha Hauer, open list:BAREBOX
Cc: Thomas Petazzoni, Miquèl Raynal, Hervé Codina
Hi,
On 8/27/26 4:16 PM, Ahmad Fatoum wrote:
> On 8/27/26 2:16 PM, Thomas Bonnefille wrote:
> 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.
No patch for me, but a FIT spec issue:
https://github.com/open-source-firmware/flat-image-tree/issues/60
The spec appears to be inconsistent.
Thanks!
Ahmad
>
> 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@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 |
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-27 15:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-27 12:16 [PATCH] bootm: add fitimage command line to bootargs Thomas Bonnefille
2026-08-27 14:16 ` Ahmad Fatoum
2026-08-27 15:08 ` Ahmad Fatoum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox