Skip to content

Commit 1e297c8

Browse files
committed
stm32/main: Move update_reset_mode to outside the soft-reset loop.
Running the update inside the soft-reset loop will mean that (on boards like PYBD that use a bootloader) the same reset mode is used each reset loop, eg factory reset occurs each time. Signed-off-by: Damien George <[email protected]>
1 parent b7883ce commit 1e297c8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

ports/stm32/main.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,11 @@ void stm32_main(uint32_t reset_mode) {
552552
MP_STATE_PORT(pyb_uart_obj_all)[MICROPY_HW_UART_REPL - 1] = &pyb_uart_repl_obj;
553553
#endif
554554

555+
#if !MICROPY_HW_USES_BOOTLOADER
556+
// check if user switch held to select the reset mode
557+
reset_mode = update_reset_mode(1);
558+
#endif
559+
555560
soft_reset:
556561

557562
#if defined(MICROPY_HW_LED2)
@@ -564,11 +569,6 @@ void stm32_main(uint32_t reset_mode) {
564569
led_state(3, 0);
565570
led_state(4, 0);
566571

567-
#if !MICROPY_HW_USES_BOOTLOADER
568-
// check if user switch held to select the reset mode
569-
reset_mode = update_reset_mode(1);
570-
#endif
571-
572572
// Python threading init
573573
#if MICROPY_PY_THREAD
574574
mp_thread_init();
@@ -776,5 +776,8 @@ void stm32_main(uint32_t reset_mode) {
776776

777777
gc_sweep_all();
778778

779+
// Set reset_mode to normal boot.
780+
reset_mode = 1;
781+
779782
goto soft_reset;
780783
}

0 commit comments

Comments
 (0)