From 91468ed36b5b698d157b665af2774ea73fb3103c Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 8 Mar 2022 17:55:21 -0800 Subject: [PATCH] Don't crash on early debug print --- supervisor/shared/serial.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/supervisor/shared/serial.c b/supervisor/shared/serial.c index 7f948a8199..87c4fca14d 100644 --- a/supervisor/shared/serial.c +++ b/supervisor/shared/serial.c @@ -73,6 +73,11 @@ const mp_print_t debug_uart_print = {NULL, debug_uart_print_strn}; int debug_uart_printf(const char *fmt, ...) { #if defined(CIRCUITPY_DEBUG_UART_TX) + // Skip prints that occur before debug serial is started. It's better than + // crashing. + if (common_hal_busio_uart_deinited(&debug_uart)) { + return 0; + } va_list ap; va_start(ap, fmt); int ret = mp_vprintf(&debug_uart_print, fmt, ap);