diff --git a/src/omv/ports/stm32/main.c b/src/omv/ports/stm32/main.c index bf25486b9..dbf6a2ce2 100644 --- a/src/omv/ports/stm32/main.c +++ b/src/omv/ports/stm32/main.c @@ -624,12 +624,6 @@ soft_reset: usbdbg_wait_for_command(1000); } - #if MICROPY_PY_LWIP - // Must call GC sweep here to close open sockets. - gc_sweep_all(); - systick_disable_dispatch(SYSTICK_DISPATCH_LWIP); - #endif - // soft reset storage_flush(); @@ -639,6 +633,9 @@ soft_reset: #if MICROPY_PY_BLUETOOTH mp_bluetooth_deinit(); #endif + #if MICROPY_PY_LWIP + systick_disable_dispatch(SYSTICK_DISPATCH_LWIP); + #endif mod_network_deinit(); timer_deinit(); i2c_deinit_all(); @@ -654,6 +651,10 @@ soft_reset: py_audio_deinit(); #endif imlib_deinit_all(); + + gc_sweep_all(); + mp_deinit(); + first_soft_reset = false; goto soft_reset; }