diff --git a/ports/stm32/machine_uart.c b/ports/stm32/machine_uart.c
index f5f56c703ed7ff443e9ae8db4e351f31a706a2db..1a21ff8f4b12bfb84258905c460db36764640efc 100644
--- a/ports/stm32/machine_uart.c
+++ b/ports/stm32/machine_uart.c
@@ -161,6 +161,11 @@ STATIC mp_obj_t pyb_uart_init_helper(pyb_uart_obj_t *self, size_t n_args, const
     mp_arg_parse_all(n_args, pos_args, kw_args,
         MP_ARRAY_SIZE(allowed_args), allowed_args, (mp_arg_val_t*)&args);
 
+    // static UARTs are used for internal purposes and shouldn't be reconfigured
+    if (self->is_static) {
+        mp_raise_ValueError("UART is static and can't be init'd");
+    }
+
     // baudrate
     uint32_t baudrate = args.baudrate.u_int;
 
diff --git a/ports/stm32/main.c b/ports/stm32/main.c
index f14176efa9e4c77915a4627c51d6840c5f752dfc..62cba5434568a3c8394142011ba9eeac661ee7fc 100644
--- a/ports/stm32/main.c
+++ b/ports/stm32/main.c
@@ -518,6 +518,7 @@ void stm32_main(uint32_t reset_mode) {
     #if MICROPY_HW_ENABLE_RTC
     rtc_init_start(false);
     #endif
+    uart_init0();
     spi_init0();
     #if MICROPY_PY_PYB_LEGACY && MICROPY_HW_ENABLE_HW_I2C
     i2c_init0();
@@ -586,7 +587,6 @@ soft_reset:
     pin_init0();
     extint_init0();
     timer_init0();
-    uart_init0();
 
     // Define MICROPY_HW_UART_REPL to be PYB_UART_6 and define
     // MICROPY_HW_UART_REPL_BAUD in your mpconfigboard.h file if you want a
diff --git a/ports/stm32/uart.c b/ports/stm32/uart.c
index 9d93bc1e5eb9fc54a0e29fc5ee0c67778bb8f29f..ff1e860041d2514cf74dfe548afaab8637d0ea40 100644
--- a/ports/stm32/uart.c
+++ b/ports/stm32/uart.c
@@ -64,18 +64,15 @@ void uart_init0(void) {
         __fatal_error("HAL_RCCEx_PeriphCLKConfig");
     }
     #endif
-
-    for (int i = 0; i < MP_ARRAY_SIZE(MP_STATE_PORT(pyb_uart_obj_all)); i++) {
-        MP_STATE_PORT(pyb_uart_obj_all)[i] = NULL;
-    }
 }
 
 // unregister all interrupt sources
 void uart_deinit_all(void) {
     for (int i = 0; i < MP_ARRAY_SIZE(MP_STATE_PORT(pyb_uart_obj_all)); i++) {
         pyb_uart_obj_t *uart_obj = MP_STATE_PORT(pyb_uart_obj_all)[i];
-        if (uart_obj != NULL) {
+        if (uart_obj != NULL && !uart_obj->is_static) {
             uart_deinit(uart_obj);
+            MP_STATE_PORT(pyb_uart_obj_all)[i] = NULL;
         }
     }
 }
diff --git a/ports/stm32/uart.h b/ports/stm32/uart.h
index bc50248c1a0fe4dd86fbaf016873eeb49f24bf86..285277515a6ec48a5e82919f3bde529292a547cb 100644
--- a/ports/stm32/uart.h
+++ b/ports/stm32/uart.h
@@ -46,6 +46,7 @@ typedef struct _pyb_uart_obj_t {
     USART_TypeDef *uartx;
     IRQn_Type irqn;
     pyb_uart_t uart_id : 8;
+    bool is_static : 1;
     bool is_enabled : 1;
     bool attached_to_repl;              // whether the UART is attached to REPL
     byte char_width;                    // 0 for 7,8 bit chars, 1 for 9 bit chars