How to disable serial console(non-kernel) in u-boot
Solution 1
I'm getting back to this issue almost a year later, now I've managed to find a proper solution.
The board I was working on had a reasonably new u-boot in its BSP. To disable the serial console I had to do the following:
-
Add the following defines to the board's config header(located in include/configs/board.h):
#define CONFIG_DISABLE_CONSOLE #define CONFIG_SILENT_CONSOLE #define CONFIG_SYS_DEVICE_NULLDEV
-
Check if your board has early_init_f enabled in the same file:
#define CONFIG_BOARD_EARLY_INIT_F 1
-
Find the arch file(Something like arch/x86/cpu/architecture/architecture.c) and add this call to its early_init_f function. It actually modifies board's global data variable to have these flags:
gd->flags |= (GD_FLG_SILENT | GD_FLG_DISABLE_CONSOLE);
-
My board did not have one, so I had to add the whole function
int board_early_init_f(void) { gd->flags |= (GD_FLG_SILENT | GD_FLG_DISABLE_CONSOLE); return 0; }
Example: If you are looking for board_early_init_f of Orange Pi 4B it is in /build/cache/sources/u-boot/v2020.10/board/rockchip/evb_rk3399/evb-rk3399.c
That's it. Hope this helps someone else!
see also
Solution 2
Setting the u-boot environment variable bootdelay
to -2
disables the ability for the UART to interrupt the boot process on U-Boot 2017.01
release. It appears that -1
is a special case.
See common/autoboot.c
from your U-Boot source tree for details.
About U-Boot Environment Variables
Solution 3
There's no way to do this, without modifying the source (configuration) of U-Boot.
To disable the serial console in U-Boot, you need to reconfigure U-Boot. The documentation from the master branch of U-Boot: Readme.silent
According to that one, you need to set:
CONFIG_SILENT_CONSOLE
CONFIG_SILENT_CONSOLE_UPDATE_ON_SET
CONFIG_SYS_DEVICE_NULLDEV
CONFIG_SILENT_U_BOOT_ONLY
is also needed if you want only U-Boot to be silent.
You might also need to test with CONFIG_SILENT_CONSOLE_UPDATE_ON_RELOC
and possibly adding silent 1
to CONFIG_EXTRA_ENV_SETTINGS
.
== UPDATE ==
See the following options for a possible workaround:
CONFIG_ZERO_BOOTDELAY_CHECK
CONFIG_AUTOBOOT_KEYED
CONFIG_AUTOBOOT_KEYED_CTRLC
CONFIG_AUTOBOOT_PROMPT
CONFIG_AUTOBOOT_DELAY_STR
CONFIG_AUTOBOOT_STOP_STR
These options will at least give you a way of requiring a magic string to stop the boot. It might be enough to help you. See README.autoboot
Solution 4
As told by Kyle you can set the bootdelay u-boot environment variable to -2.
This can even be done from a booted system using the fw_setenv
utility.
On my mender raspberry pi image this utility was preinstalled.
Using sudo fw_printenv bootdelay
showed it was set to 2, i set it to -2 with sudo fw_setenv bootdelay -- -2
(note the --
before the value, so -2
is interpreted as the value, not an option).
In my case it was a similar issue than the OP, with a LoraWAN node on a raspberry pi connected over the serial port that interrupted the boot.
So
- remove the serial device causing issue
- set bootdelay either from the booted system or from the bootloader
- shutdown and add the serial device back
Egor
Updated on June 13, 2022Comments
-
Egor almost 2 years
I am building a Yocto image for Intel Edison.
One of the image's components is u-boot with an Edison-specific patch. By default, Edison's UART port is used for u-boot console. I want to disable this feature, but only on the serial interface(u-boot also listens on USB and that needs to stay).
My main concern is the "Press any key to stop autoboot" feature on the UART port. I need this port to connect an accessory that might send something during the boot process of the main device.
How do I approach this problem? Is there an environment variable for this, or do I need to modify the sources?
Thanks in advance!
-
Egor over 8 yearsThanks for the feedback! I've seen the docs on the silent mode, but this method has one flaw - while the console's output is now turned off, the console's input(Press any key to stop autoboot) actually works and you can stop the device from booting. I need to set the UART port free to use it with an accessory. I'll update my question to address this issue