Skip to content

Commit 5229a24

Browse files
committed
Revert "ports/stm32: Fix thread-safe print() for Zephyr threading."
This reverts commit 8741591.
1 parent 8741591 commit 5229a24

File tree

2 files changed

+0
-31
lines changed

2 files changed

+0
-31
lines changed

ports/stm32/main.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,6 @@ void micropython_main_thread_entry(void *p1, void *p2, void *p3) {
329329
for (;;) {}
330330
}
331331

332-
// Initialize stdio mutex for thread-safe print()
333-
extern void mp_hal_stdio_init(void);
334-
mp_hal_stdio_init();
335-
336332
// THEN enable SysTick interrupt now that threading is fully initialized
337333
extern void mp_zephyr_arch_enable_systick_interrupt(void);
338334
mp_zephyr_arch_enable_systick_interrupt();

ports/stm32/mphalport.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,6 @@
88
#include "usb.h"
99
#include "uart.h"
1010

11-
#if MICROPY_PY_THREAD
12-
#include "py/mpthread.h"
13-
14-
// Mutex to protect UART/stdio from concurrent thread access
15-
static mp_thread_mutex_t stdio_mutex;
16-
static bool stdio_mutex_initialized = false;
17-
18-
void mp_hal_stdio_init(void) {
19-
if (!stdio_mutex_initialized) {
20-
mp_thread_mutex_init(&stdio_mutex);
21-
stdio_mutex_initialized = true;
22-
}
23-
}
24-
#endif
25-
2611
// this table converts from HAL_StatusTypeDef to POSIX errno
2712
const byte mp_hal_status_to_errno_table[4] = {
2813
[HAL_OK] = 0,
@@ -73,13 +58,6 @@ MP_WEAK int mp_hal_stdin_rx_chr(void) {
7358
}
7459

7560
MP_WEAK mp_uint_t mp_hal_stdout_tx_strn(const char *str, size_t len) {
76-
#if MICROPY_PY_THREAD
77-
// Protect UART/stdio access from concurrent threads
78-
// Mutex should be initialized during startup, but check just in case
79-
mp_hal_stdio_init();
80-
mp_thread_mutex_lock(&stdio_mutex, 1);
81-
#endif
82-
8361
mp_uint_t ret = len;
8462
bool did_write = false;
8563
if (MP_STATE_PORT(pyb_stdio_uart) != NULL) {
@@ -94,11 +72,6 @@ MP_WEAK mp_uint_t mp_hal_stdout_tx_strn(const char *str, size_t len) {
9472
did_write = true;
9573
ret = MIN((mp_uint_t)dupterm_res, ret);
9674
}
97-
98-
#if MICROPY_PY_THREAD
99-
mp_thread_mutex_unlock(&stdio_mutex);
100-
#endif
101-
10275
return did_write ? ret : 0;
10376
}
10477

0 commit comments

Comments
 (0)