Skip to content

Commit 91468ed

Browse files
committed
Don't crash on early debug print
1 parent 96f5eec commit 91468ed

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

supervisor/shared/serial.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ const mp_print_t debug_uart_print = {NULL, debug_uart_print_strn};
7373

7474
int debug_uart_printf(const char *fmt, ...) {
7575
#if defined(CIRCUITPY_DEBUG_UART_TX)
76+
// Skip prints that occur before debug serial is started. It's better than
77+
// crashing.
78+
if (common_hal_busio_uart_deinited(&debug_uart)) {
79+
return 0;
80+
}
7681
va_list ap;
7782
va_start(ap, fmt);
7883
int ret = mp_vprintf(&debug_uart_print, fmt, ap);

0 commit comments

Comments
 (0)