aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSean Anderson <sean.anderson@seco.com>2022-05-19 18:26:05 -0400
committerTom Rini <trini@konsulko.com>2022-06-06 18:01:21 -0400
commitba9aa40bb387385b8ef8b6594661a97ddcb8d04c (patch)
tree9686a914e4337f3d78c8b324729774f74fc9ce05 /test
parentf2ebaaa9f38dddddefaf2e616a9fc489fe8b4021 (diff)
downloadu-boot-ba9aa40bb387385b8ef8b6594661a97ddcb8d04c.zip
u-boot-ba9aa40bb387385b8ef8b6594661a97ddcb8d04c.tar.gz
u-boot-ba9aa40bb387385b8ef8b6594661a97ddcb8d04c.tar.bz2
bootm: Fix Linux silent console on newer kernels
Linux determines its console based on several sources: 1. the console command line parameter 2. device tree (e.g. /chosen/stdout-path) 3. various other board- and arch-specific sources If the console parameter specifies a real console (e.g. ttyS0) then that is used as /dev/console. However, if it does not specify a real console (e.g. ttyDoesntExist) then *nothing* will be used as /dev/console. Reading/writing it will return ENODEV. Additionally, no other source will be used as a console source. Linux commit ab4af56ae250 ("printk/console: Allow to disable console output by using console="" or console=null") recently changed the semantics of the parameter. Previously, specifying console="" would be treated like specifying some other bad console. This commit changed things so that it added /dev/ttynull as a console (if available). However, it also allows for other console sources. If the device tree specifies a console (such as if U-Boot and Linux share a device tree), then it will be used in addition to /dev/ttynull. This can result in a non-silent console. To avoid this, explicitly set ttynull as the console. This will disable other console sources. If CONFIG_NULL_TTY is disabled, then this will have the same behavior as in the past (no output, and writing /dev/console returns ENODEV). [1] and [2] have additional background on this kernel change. [1] https://lore.kernel.org/all/20201006025935.GA597@jagdpanzerIV.localdomain/ [2] https://lore.kernel.org/all/20201111135450.11214-1-pmladek@suse.com/ Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Diffstat (limited to 'test')
-rw-r--r--test/bootm.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/test/bootm.c b/test/bootm.c
index 8528982..7d03e1e 100644
--- a/test/bootm.c
+++ b/test/bootm.c
@@ -83,12 +83,12 @@ static int bootm_test_silent(struct unit_test_state *uts)
ut_assertok(env_set("silent_linux", "yes"));
ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SILENT));
- ut_asserteq_str("console=", buf);
+ ut_asserteq_str("console=ttynull", buf);
/* Empty buffer should still add the string */
*buf = '\0';
ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SILENT));
- ut_asserteq_str("console=", buf);
+ ut_asserteq_str("console=ttynull", buf);
/* Check nothing happens when do_silent is false */
*buf = '\0';
@@ -97,21 +97,21 @@ static int bootm_test_silent(struct unit_test_state *uts)
/* Not enough space */
*buf = '\0';
- ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, 8, BOOTM_CL_SILENT));
+ ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, 15, BOOTM_CL_SILENT));
/* Just enough space */
*buf = '\0';
- ut_assertok(bootm_process_cmdline(buf, 9, BOOTM_CL_SILENT));
+ ut_assertok(bootm_process_cmdline(buf, 16, BOOTM_CL_SILENT));
/* add at end */
strcpy(buf, "something");
ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SILENT));
- ut_asserteq_str("something console=", buf);
+ ut_asserteq_str("something console=ttynull", buf);
/* change at start */
strcpy(buf, CONSOLE_STR " something");
ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SILENT));
- ut_asserteq_str("console= something", buf);
+ ut_asserteq_str("console=ttynull something", buf);
return 0;
}
@@ -210,12 +210,12 @@ static int bootm_test_subst_var(struct unit_test_state *uts)
{
env_set("bootargs", NULL);
ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT));
- ut_asserteq_str("console=", env_get("bootargs"));
+ ut_asserteq_str("console=ttynull", env_get("bootargs"));
ut_assertok(env_set("var", "abc"));
ut_assertok(env_set("bootargs", "some${var}thing"));
ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT));
- ut_asserteq_str("some${var}thing console=", env_get("bootargs"));
+ ut_asserteq_str("some${var}thing console=ttynull", env_get("bootargs"));
return 0;
}
@@ -227,12 +227,12 @@ static int bootm_test_subst_both(struct unit_test_state *uts)
ut_assertok(env_set("silent_linux", "yes"));
env_set("bootargs", NULL);
ut_assertok(bootm_process_cmdline_env(BOOTM_CL_ALL));
- ut_asserteq_str("console=", env_get("bootargs"));
+ ut_asserteq_str("console=ttynull", env_get("bootargs"));
ut_assertok(env_set("bootargs", "some${var}thing " CONSOLE_STR));
ut_assertok(env_set("var", "1234567890"));
ut_assertok(bootm_process_cmdline_env(BOOTM_CL_ALL));
- ut_asserteq_str("some1234567890thing console=", env_get("bootargs"));
+ ut_asserteq_str("some1234567890thing console=ttynull", env_get("bootargs"));
return 0;
}