diff --git a/Ubiquitous/XiZi_AIoT/hardkernel/uart/printf.h b/Ubiquitous/XiZi_AIoT/hardkernel/uart/printf.h index 85c030650..93e207e93 100644 --- a/Ubiquitous/XiZi_AIoT/hardkernel/uart/printf.h +++ b/Ubiquitous/XiZi_AIoT/hardkernel/uart/printf.h @@ -50,6 +50,7 @@ extern "C" { #define KPrintf printf_ #define printf printf_ int printf_(const char* format, ...); +int printf_early(const char* format, ...); /** * Tiny sprintf implementation diff --git a/Ubiquitous/XiZi_AIoT/hardkernel/uart/uart_common_ope.c b/Ubiquitous/XiZi_AIoT/hardkernel/uart/uart_common_ope.c index d4a09dfa4..07130da60 100644 --- a/Ubiquitous/XiZi_AIoT/hardkernel/uart/uart_common_ope.c +++ b/Ubiquitous/XiZi_AIoT/hardkernel/uart/uart_common_ope.c @@ -895,4 +895,16 @@ int fctprintf(void (*out)(char character, void* arg), void* arg, const char* for const int ret = _vsnprintf(_out_fct, (char*)(uintptr_t)&out_fct_wrap, (size_t)-1, format, va); va_end(va); return ret; -} \ No newline at end of file +} + +/////////////////////////////////////////////////////////////////////////////// +__attribute__((weak)) void _debug_uart_putc(int ch); +int printf_early(const char* format, ...) +{ + va_list va; + va_start(va, format); + char buffer[1]; + const int ret = _vsnprintf(_debug_uart_putc, buffer, (size_t)-1, format, va); + va_end(va); + return ret; +}