Skip to content

Commit f7483ea

Browse files
committed
Fixes uart logging locks
1 parent ff46d36 commit f7483ea

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cores/esp32/esp32-hal-uart.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -767,12 +767,14 @@ int log_printfv(const char *format, va_list arg)
767767
return 0;
768768
}
769769
}
770+
/*
771+
// This causes dead locks with logging in specific cases and also with C++ constructors that may send logs
770772
#if !CONFIG_DISABLE_HAL_LOCKS
771773
if(s_uart_debug_nr != -1 && _uart_bus_array[s_uart_debug_nr].lock){
772774
xSemaphoreTake(_uart_bus_array[s_uart_debug_nr].lock, portMAX_DELAY);
773775
}
774776
#endif
775-
777+
*/
776778
#if CONFIG_IDF_TARGET_ESP32C3
777779
vsnprintf(temp, len+1, format, arg);
778780
ets_printf("%s", temp);
@@ -782,15 +784,19 @@ int log_printfv(const char *format, va_list arg)
782784
ets_write_char_uart(temp[i]);
783785
}
784786
#endif
785-
787+
/*
788+
// This causes dead locks with logging and also with constructors that may send logs
786789
#if !CONFIG_DISABLE_HAL_LOCKS
787790
if(s_uart_debug_nr != -1 && _uart_bus_array[s_uart_debug_nr].lock){
788791
xSemaphoreGive(_uart_bus_array[s_uart_debug_nr].lock);
789792
}
790793
#endif
794+
*/
791795
if(len >= sizeof(loc_buf)){
792796
free(temp);
793797
}
798+
// flushes TX - make sure that the log message is completely sent.
799+
if(s_uart_debug_nr != -1) while(!uart_ll_is_tx_idle(UART_LL_GET_HW(s_uart_debug_nr)));
794800
return len;
795801
}
796802

0 commit comments

Comments
 (0)