@@ -747,8 +747,7 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
747747
748748 supervisor_allocation * heap = allocate_remaining_memory ();
749749
750- // true means this is the first set of VM's after a hard reset.
751- start_mp (heap , true);
750+ start_mp (heap );
752751
753752 #if CIRCUITPY_USB
754753 // Set up default USB values after boot.py VM starts but before running boot.py.
@@ -964,6 +963,9 @@ int __attribute__((used)) main(void) {
964963 // Record which alarm woke us up, if any.
965964 // common_hal_alarm_record_wake_alarm() should return a static, non-heap object
966965 shared_alarm_save_wake_alarm (common_hal_alarm_record_wake_alarm ());
966+ // Then reset the alarm system. It's not reset in reset_port(), because that's also called
967+ // on VM teardown, which would clear any alarm setup.
968+ alarm_reset ();
967969 #endif
968970
969971 // Reset everything and prep MicroPython to run boot.py.
@@ -1010,6 +1012,9 @@ int __attribute__((used)) main(void) {
10101012 serial_write_compressed (translate ("soft reboot\n" ));
10111013 }
10121014 if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL ) {
1015+ // If code.py did a fake deep sleep, pretend that we
1016+ // are running code.py for the first time after a hard
1017+ // reset. This will preserve any alarm information.
10131018 skip_repl = run_code_py (safe_mode , & simulate_reset );
10141019 } else {
10151020 skip_repl = false;
@@ -1018,14 +1023,10 @@ int __attribute__((used)) main(void) {
10181023 break ;
10191024 }
10201025
1021- // Either the REPL or code.py has run and finished.
1022- // If code.py did a fake deep sleep, pretend that we are running code.py for
1023- // the first time after a hard reset. This will preserve any alarm information.
1024- if (!simulate_reset ) {
1025- #if CIRCUITPY_ALARM
1026- shared_alarm_save_wake_alarm (mp_const_none );
1027- #endif
1028- }
1026+ #if CIRCUITPY_ALARM
1027+ shared_alarm_save_wake_alarm (simulate_reset ? common_hal_alarm_record_wake_alarm () : mp_const_none );
1028+ alarm_reset ();
1029+ #endif
10291030 }
10301031 mp_deinit ();
10311032 return 0 ;
0 commit comments