From 923e1b60e779cd8706c5c9a83b0b0fbbd67ef3d5 Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Sun, 19 Aug 2018 10:58:06 -0700 Subject: [PATCH] misc/printk: Make the default char_out routine weak Architecture init code and/or HAL layers often have a working "putchar" routine available long before the Zephyr driver layer is initialized. Make the default printk() output a weak symbol, so it can be overridden on these platforms. Also remove the kconfig depedency on CONSOLE_HAS_DRIVER, as this is a non-driver mechanism. Signed-off-by: Andy Ross --- misc/printk.c | 7 +++++-- subsys/debug/Kconfig | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/misc/printk.c b/misc/printk.c index 212a7cfca80..b4cf2cb09ed 100644 --- a/misc/printk.c +++ b/misc/printk.c @@ -40,9 +40,12 @@ static void _printk_hex_ulong(out_func_t out, void *ctx, * @brief Default character output routine that does nothing * @param c Character to swallow * + * Note this is defined as a weak symbol, allowing architecture code + * to override it where possible to enable very early logging. + * * @return 0 */ -static int _nop_char_out(int c) + __attribute__((weak)) int z_arch_printk_char_out(int c) { ARG_UNUSED(c); @@ -50,7 +53,7 @@ static int _nop_char_out(int c) return 0; } -static int (*_char_out)(int) = _nop_char_out; +int (*_char_out)(int) = z_arch_printk_char_out; /** * @brief Install the character output routine for printk diff --git a/subsys/debug/Kconfig b/subsys/debug/Kconfig index a7adb570e5d..3a61f33f31d 100644 --- a/subsys/debug/Kconfig +++ b/subsys/debug/Kconfig @@ -104,7 +104,6 @@ config STACK_SENTINEL config PRINTK bool "Send printk() to console" - depends on CONSOLE_HAS_DRIVER default y help This option directs printk() debugging output to the supported