kernel: banner: Add option to clear screen on boot

On each reboot, this option causes the serial output to start top-left
on the users terminal, simplifying (human) parsing.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
This commit is contained in:
Reto Schneider 2024-05-02 17:32:17 +02:00 committed by Anas Nashif
parent 5120744c8d
commit 1bf5af7e89
2 changed files with 15 additions and 0 deletions

View file

@ -467,6 +467,12 @@ config BOOT_DELAY
achieved by waiting for DCD on the serial port--however, not achieved by waiting for DCD on the serial port--however, not
all serial ports have DCD. all serial ports have DCD.
config BOOT_CLEAR_SCREEN
bool "Clear screen"
help
Use this option to clear the screen before printing anything else.
Using a VT100 enabled terminal on the client side is required for this to work.
config THREAD_MONITOR config THREAD_MONITOR
bool "Thread monitoring" bool "Thread monitoring"
help help

View file

@ -33,6 +33,15 @@ void boot_banner(void)
k_busy_wait(CONFIG_BOOT_DELAY * USEC_PER_MSEC); k_busy_wait(CONFIG_BOOT_DELAY * USEC_PER_MSEC);
#endif /* defined(CONFIG_BOOT_DELAY) && (CONFIG_BOOT_DELAY > 0) */ #endif /* defined(CONFIG_BOOT_DELAY) && (CONFIG_BOOT_DELAY > 0) */
#if defined(CONFIG_BOOT_CLEAR_SCREEN)
/* \x1b[ = escape sequence
* 3J = erase scrollback
* 2J = erase screen
* H = move cursor to top left
*/
printk("\x1b[3J\x1b[2J\x1b[H");
#endif /* CONFIG_BOOT_CLEAR_SCREEN */
#ifdef CONFIG_BOOT_BANNER #ifdef CONFIG_BOOT_BANNER
printk("*** " CONFIG_BOOT_BANNER_STRING " " BANNER_VERSION BANNER_POSTFIX " ***\n"); printk("*** " CONFIG_BOOT_BANNER_STRING " " BANNER_VERSION BANNER_POSTFIX " ***\n");
#endif /* CONFIG_BOOT_BANNER */ #endif /* CONFIG_BOOT_BANNER */