diff --git a/kernel/Kconfig b/kernel/Kconfig index f68f1874d7a..828631f1b5d 100644 --- a/kernel/Kconfig +++ b/kernel/Kconfig @@ -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" diff --git a/kernel/init.c b/kernel/init.c index 236d2775693..c409cfd95f2 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -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(); /*