How to disable serial console(non-kernel) in u-boot
Asked Answered
D

5

13

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!

Defrayal answered 18/12, 2015 at 13:28 Comment(0)
D
16

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

Defrayal answered 1/11, 2016 at 19:39 Comment(0)
C
8

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

Clupeoid answered 7/2, 2019 at 0:3 Comment(0)
K
4

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

Kryska answered 21/12, 2015 at 6:18 Comment(1)
Thanks 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 issueDefrayal
B
2

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
Bleat answered 16/9, 2021 at 20:57 Comment(0)
C
0

Here is the video where it is explained step by step how to prevent U-boot console from interrupting autoboot and sending debug messages on UART on Raspberry Pi - it should work similarly for other boards, provided they use U-boot. You will however need to find the right config files for your board in u-boot source folder. I know links only answers are frowned upon, so here' s a quick breakdown of a solution:

Install the dependencies

sudo apt install git make gcc gcc-aarch64-linux-gnu bison flex

Git clone the official u-boot repository. Alternatively you can git clone my fork of repository, where I already have the necessary changes for silent autoboot - but if you need the latest version, then you need to clone the official repository and make changes yourself.

git clone --depth 1 git://git.denx.de/u-boot.git

cd u-boot

Find your board config files - they depend on the model, e.g. rpi_3_defconfig for Raspberry Pi 3, rpi_4_defconfig for Raspberry Pi 4 and so on. Add the following lines to the end of the file

CONFIG_BOOTDELAY=-2
CONFIG_SILENT_CONSOLE=y
CONFIG_SYS_DEVICE_NULLDEV=y
CONFIG_SILENT_CONSOLE_UPDATE_ON_SET=y
CONFIG_SILENT_U_BOOT_ONLY=y

The first line removes the boot delay, so autoboot will not be interrupted by messages sent on UART interface. Next four lines enable silent boot, so U-boot will not send any messages on UART itself, because the messages might in turn confuse your device. One more little thing left, set silent boot environmental variable. Change the header file for your board (for raspberry pi it is include/configs/rpi.h ) by adding the following:

#define CONFIG_EXTRA_ENV_SETTINGS \
    "dhcpuboot=usb start; dhcp u-boot.uimg; bootm\0" \
    "silent=1\0" \
    ENV_DEVICE_SETTINGS \
    ENV_DFU_SETTINGS \
    ENV_MEM_LAYOUT_SETTINGS \
    BOOTENV

Now configure with

make rpi_3_defconfig

from repository main folder And build with

make CROSS_COMPILE=aarch64-linux-gnu-

When the build process finishes you will have a u-boot.bin file, which you need to rename (uboot_rpi_3.bin for Raspberry Pi 3) and copy to Raspberry Pi SD card at /boot/firmware/. Now you Raspberry Pi will not be disturbed by any messages on UART during boot. The UART functionality after boot will not be affected.

Relevant docs: https://gitlab.denx.de/u-boot/u-boot/blob/HEAD/doc/README.autoboot https://gitlab.denx.de/u-boot/u-boot/blob/HEAD/doc/README.silent https://wiki.ubuntu.com/ARM/RaspberryPi

Comatose answered 29/10, 2020 at 2:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.