Verified Commit 32681478 authored by Rahix's avatar Rahix
Browse files

fix(serial): Perform serial prints in a critical section

Sometimes during initialization, one `log_msg()` intercepts another one,
leading to a whole lot of weird issues in other modules (like I2C).  I
suspect this to be memory corruption of some kind.  The issues can be
fixed by performing serial prints in a critical section, thus ensuring
atomicity of prints.  Note that this does not mean log messages will not

The CDC-ACM and BLE-Serial writes cannot be put into a critical section
and are thus a point where this code can still fail.  For now, however,
this fix ensures the race-conditions during startup, where USB and BLE
are not yet running, don't happen anymore.

Signed-off-by: Rahix's avatarRahix <>
parent 61599d4d
Pipeline #3347 passed with stages
in 47 seconds
......@@ -27,7 +27,21 @@ static QueueHandle_t read_queue;
void epic_uart_write_str(const char *str, intptr_t length)
uint32_t basepri = __get_BASEPRI();
if (xPortIsInsideInterrupt()) {
} else {
UART_Write(ConsoleUart, (uint8_t *)str, length);
if (xPortIsInsideInterrupt()) {
} else {
cdcacm_write((uint8_t *)str, length);
ble_uart_write((uint8_t *)str, length);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment