From 7481632b192f61b5bcb028c885a460d8b9c2731c Mon Sep 17 00:00:00 2001 From: Piotr Kubik Date: Fri, 24 Nov 2023 17:30:46 +0100 Subject: bootm: Fix flags used for bootargs string substitution Commit 51bb33846ad2 ("bootm: Support string substitution in bootargs") introduced a feature of bootargs string substitution and changed a flag used in bootm_process_cmdline_env() call to be either true or false. With this flag value, condition in bootm_process_cmdline() `if (flags & BOOTM_CL_SUBST)` is never true and process_subst() is never called. Add a simple test to verify if substitution works OK. Signed-off-by: Piotr Kubik Reviewed-by: Simon Glass --- test/py/tests/test_fit.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test') diff --git a/test/py/tests/test_fit.py b/test/py/tests/test_fit.py index 04f64fd4bc6..8f9c4b26411 100755 --- a/test/py/tests/test_fit.py +++ b/test/py/tests/test_fit.py @@ -339,6 +339,14 @@ def test_fit(u_boot_console): 'U-Boot loaded FDT from offset %#x, FDT is actually at %#x' % (fit_offset, real_fit_offset)) + # Check if bootargs strings substitution works + output = cons.run_command_list([ + 'env set bootargs \\\"\'my_boot_var=${foo}\'\\\"', + 'env set foo bar', + 'bootm prep', + 'env print bootargs']) + assert 'bootargs="my_boot_var=bar"' in output, "Bootargs strings not substituted" + # Now a kernel and an FDT with cons.log.section('Kernel + FDT load'): params['fdt_load'] = 'load = <%#x>;' % params['fdt_addr'] -- cgit v1.3.1 From 921f63e5723880bbbaf65429564e5638b7bbd002 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 29 Nov 2023 10:31:19 -0700 Subject: bootflow: Allow setting a cmdline arg with no value This is supposed to be supported by the 'bootflow cmd' command, at least according to the help. There is a 'bootflow cmd clear' but it is often more intuitive to use 'bootcmd cmd set' with an empty value. Update the command to pass BOOTFLOWCL_EMPTY in this case. Signed-off-by: Simon Glass --- cmd/bootflow.c | 4 ++-- test/boot/bootflow.c | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/cmd/bootflow.c b/cmd/bootflow.c index 4a47265ebd5..cc6dfae1668 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -543,9 +543,9 @@ static int do_bootflow_cmdline(struct cmd_tbl *cmdtp, int flag, int argc, op = argv[1]; arg = argv[2]; if (*op == 's') { - if (argc < 4) + if (argc < 3) return CMD_RET_USAGE; - val = argv[3]; + val = argv[3] ?: (const char *)BOOTFLOWCL_EMPTY; } switch (*op) { diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index f3e5a839da4..a9b555c7794 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -1095,6 +1095,10 @@ static int bootflow_cmdline(struct unit_test_state *uts) ut_asserteq(0, run_command("bootflow cmdline get mary", 0)); ut_assert_nextline_empty(); + ut_asserteq(0, run_command("bootflow cmdline set mary abc", 0)); + ut_asserteq(0, run_command("bootflow cmdline set mary", 0)); + ut_assert_nextline_empty(); + ut_assert_console_end(); return 0; -- cgit v1.3.1