Autobooting Linux from U-Boot Print


The Linux autoboot sequence in U-Boot is controlled by the two environment variables called bootdelay and bootcmd.

The bootdelay variable defines a delay, in seconds, before running the autoboot command defined by bootcmd. During the bootdelay countdown, you can interrupt the autobooting by pressing any key. This will let you enter the U-Boot command line interface.

The bootcmd variable defines a command executed by U-Boot automatically after the bootdelay countdown is over. Typically, this would be run netboot to boot Linux from TFTP during development or run mmcboot to boot Linux from the SD Card on deployed units. The latter is how bootcmd is set on the modules at the factory.

In deployed configurations, where boot time to the service provided by your embedded device is critical, you will probably want to set bootdelay to 0:

STM32H7-EVAL U-Boot > setenv bootdelay 0
STM32H7-EVAL U-Boot > saveenv
Saving Environment to MMC... Writing to MMC(0)... OK
STM32H7-EVAL U-Boot >

This will make sure that on each power on / reset U-Boot immediately executes the command defined by bootcmd, typically booting Linux from the SD Card.

With bootdelay set to 0 the U-Boot countdown is disabled, so there is a question how you enter the U-Boot command monitor, should you need that for some reason. To do so, push the Ctrl-C keys down on the serial console and don't release them until you have hit the reset button on the baseboard. This will interrupt the U-Boot bootcmd sequence and let you enter the U-Boot command monitor:

U-Boot 2019.04- (Aug 09 2023 - 10:31:06 +0000) Model: STMicroelectronics STM32H753i-EVAL board DRAM: 32 MiB Flash: 2 MiB MMC: STM32 SDMMC2: 0 Loading Environment from MMC... OK In: serial@40011000 Out: serial@40011000 Err: serial@40011000 Net: eth0: ethernet@40028000 Hit any key to stop autoboot: 0 STM32H7-EVAL U-Boot > <INTERRUPT>

From the command monitor, you would be able to set bootdelay to whatever value makes sense to you.