@@ -747,8 +747,7 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
747
747
748
748
supervisor_allocation * heap = allocate_remaining_memory ();
749
749
750
- // true means this is the first set of VM's after a hard reset.
751
- start_mp (heap , true);
750
+ start_mp (heap );
752
751
753
752
#if CIRCUITPY_USB
754
753
// Set up default USB values after boot.py VM starts but before running boot.py.
@@ -964,6 +963,9 @@ int __attribute__((used)) main(void) {
964
963
// Record which alarm woke us up, if any.
965
964
// common_hal_alarm_record_wake_alarm() should return a static, non-heap object
966
965
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 ();
967
969
#endif
968
970
969
971
// Reset everything and prep MicroPython to run boot.py.
@@ -1010,6 +1012,9 @@ int __attribute__((used)) main(void) {
1010
1012
serial_write_compressed (translate ("soft reboot\n" ));
1011
1013
}
1012
1014
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.
1013
1018
skip_repl = run_code_py (safe_mode , & simulate_reset );
1014
1019
} else {
1015
1020
skip_repl = false;
@@ -1018,14 +1023,10 @@ int __attribute__((used)) main(void) {
1018
1023
break ;
1019
1024
}
1020
1025
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
1029
1030
}
1030
1031
mp_deinit ();
1031
1032
return 0 ;
0 commit comments