dmikushin / RK3328_Uboot_SPI

Tutorial for Booting NanoPi R2S from SPI Flash
GNU General Public License v3.0
0 stars 2 forks source link

Add parameter to control the countdown duration #1

Closed dmikushin closed 1 year ago

dmikushin commented 1 year ago

Develop a U-boot patch to set the duration of autoboot countdown, for example to 10 seconds:

Hit any key to stop autoboot: 0

I should be able to do from the U-boot CLI:

setenv autoboot_countdown_sec 10
saveenv

Upon the next boot, countdown should be 10 seconds.

Do not allow setting countdown less or equal to 0.

If this feature already exists, just explain how to use it.

ognjenMarinkovic27 commented 1 year ago

There should exist an environment variable bootdelay with this functionality.

According to the U-Boot reference manual, if the bootdelay is set to 0, the autoboot happens immediately after U-Boot starts. To stop the process and enter the monitor, press a key as soon as the first U-Boot output lines appear.

Reference: http://www.learningaboutelectronics.com/Articles/How-to-increase-or-decrease-the-boot-delay-u-boot-before-automatic-boot-process.php

dmikushin commented 1 year ago

There should exist an environment variable bootdelay with this functionality.

According to the U-Boot reference manual, if the bootdelay is set to 0, the autoboot happens immediately after U-Boot starts. To stop the process and enter the monitor, press a key as soon as the first U-Boot output lines appear.

Reference: http://www.learningaboutelectronics.com/Articles/How-to-increase-or-decrease-the-boot-delay-u-boot-before-automatic-boot-process.php

Thanks, so by typing setenv bootdelay 10; saveenv; we can change the boot delay from within the working U-boot.

But what is the way to hard code the default value of boot delay into the U-boot firmware?

ognjenMarinkovic27 commented 1 year ago

Lines 453 and 454 of autoboot.c

s = env_get("bootdelay");
bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY;

The default value can be changed with CONFIG_BOOTDELAY

dmikushin commented 1 year ago

Excellent, thank you for your solution, @ognjenMarinkovic27 !