boot: add CONFIG_BOOT_DELAY option
Introduce a configurable boot delay option (defaulting to none) that happens right after printing a boot delay banner, #before calling main() in kernel/init.c:_main(), before taking timestamps for _main() and once all the infrastructure is in place. Move also the boot banner to happen after this delay. The rationale for this is some boards will boot really fast and print out some test case output in the serial port before the system that is monitoring the serial port is able to read from the serial port. This happens in MCUs whose serial port is embedded in a USB connection which also is used to power the MCU board. When powering it on by powering the USB port, there is a time it takes the host system to detect the USB connection, enumerate the serial port, configure it and load, start and read from the serial port. At this time, it might have printed the output of the serial port. While manually it is possible to press a reset button, on automation setups this adds a lot of overhead and cabling or modifications to the MCU that are easier (and cheaper) to overcome with this delay. Other options (like using a separate serial line) might not be possible or add a lot of cabling and cost, plus it'd also add extra build configuration. Change-Id: I2f4d1ba356de6cefa19b4ef5c9f19f87885d4dfd Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
This commit is contained in:
parent
8f5555bd9f
commit
c51f73f77f
2 changed files with 32 additions and 3 deletions
|
@ -204,6 +204,20 @@ config BOOT_BANNER
|
|||
This option outputs a banner to the console device during boot up. It
|
||||
also embeds a date & time stamp in the kernel and in each USAP image.
|
||||
|
||||
config BOOT_DELAY
|
||||
int "milliseconds to delay boot"
|
||||
prompt "Boot delay"
|
||||
default 0
|
||||
help
|
||||
This option delays bootup for the specified amount of
|
||||
milliseconds. This is used to allow serial ports to get ready
|
||||
before starting to print information on them during boot, as
|
||||
some systems might boot to fast for a receiving endpoint to
|
||||
detect the new USB serial bus, enumerate it and get ready to
|
||||
receive before it actually gets data. A similar effect can be
|
||||
achieved by waiting for DCD on the serial port--however, not
|
||||
all serial ports have DCD.
|
||||
|
||||
config BUILD_TIMESTAMP
|
||||
bool
|
||||
prompt "Build Timestamp"
|
||||
|
|
|
@ -37,7 +37,17 @@ const char * const build_timestamp = BUILD_TIMESTAMP;
|
|||
|
||||
/* boot banner items */
|
||||
|
||||
#define BOOT_BANNER "BOOTING ZEPHYR OS v" KERNEL_VERSION_STRING
|
||||
static const unsigned int boot_delay;
|
||||
#if defined(CONFIG_BOOT_DELAY) && CONFIG_BOOT_DELAY > 0
|
||||
#define BOOT_DELAY_BANNER " (delayed boot " \
|
||||
STRINGIFY(CONFIG_BOOT_DELAY) "ms)"
|
||||
static const unsigned int boot_delay = CONFIG_BOOT_DELAY;
|
||||
#else
|
||||
#define BOOT_DELAY_BANNER ""
|
||||
static const unsigned int boot_delay;
|
||||
#endif
|
||||
#define BOOT_BANNER "BOOTING ZEPHYR OS v" \
|
||||
KERNEL_VERSION_STRING BOOT_DELAY_BANNER
|
||||
|
||||
#if !defined(CONFIG_BOOT_BANNER)
|
||||
#define PRINT_BOOT_BANNER() do { } while (0)
|
||||
|
@ -200,6 +210,13 @@ static void _main(void *unused1, void *unused2, void *unused3)
|
|||
|
||||
_init_static_threads();
|
||||
|
||||
if (boot_delay > 0) {
|
||||
printk("***** delaying boot " STRINGIFY(CONFIG_BOOT_DELAY)
|
||||
"ms (per build configuration) *****\n");
|
||||
k_sleep(CONFIG_BOOT_DELAY);
|
||||
}
|
||||
PRINT_BOOT_BANNER();
|
||||
|
||||
#ifdef CONFIG_BOOT_TIME_MEASUREMENT
|
||||
/* record timestamp for kernel's _main() function */
|
||||
extern u64_t __main_time_stamp;
|
||||
|
@ -360,8 +377,6 @@ FUNC_NORETURN void _Cstart(void)
|
|||
|
||||
/* display boot banner */
|
||||
|
||||
PRINT_BOOT_BANNER();
|
||||
|
||||
switch_to_main_thread();
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue