@@ -124,7 +124,7 @@ static void reset_devices(void) {
124124}
125125
126126STATIC void start_mp (supervisor_allocation * heap , bool first_run ) {
127- autoreload_stop ();
127+ autoreload_reset ();
128128 supervisor_workflow_reset ();
129129
130130 // Stack limit should be less than real stack size, so we have a chance
@@ -329,7 +329,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re
329329 result .exception = MP_OBJ_NULL ;
330330 result .exception_line = 0 ;
331331
332- bool skip_repl ;
332+ bool skip_repl = false ;
333333 bool skip_wait = false;
334334 bool found_main = false;
335335 uint8_t next_code_options = 0 ;
@@ -389,13 +389,13 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re
389389
390390 // Print done before resetting everything so that we get the message over
391391 // BLE before it is reset and we have a delay before reconnect.
392- if (reload_requested && result .return_code == PYEXEC_EXCEPTION ) {
392+ if (result .return_code == PYEXEC_RELOAD ) {
393393 serial_write_compressed (translate ("\nCode stopped by auto-reload.\n" ));
394394 } else {
395395 serial_write_compressed (translate ("\nCode done running.\n" ));
396396 }
397397
398- // Finished executing python code. Cleanup includes a board reset.
398+ // Finished executing python code. Cleanup includes filesystem flush and a board reset.
399399 cleanup_after_vm (heap , result .exception );
400400
401401 // If a new next code file was set, that is a reason to keep it (obviously). Stuff this into
@@ -407,8 +407,10 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re
407407 next_code_options |= SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET ;
408408 }
409409
410- if (reload_requested ) {
410+ if (result . return_code & PYEXEC_RELOAD ) {
411411 next_code_stickiness_situation |= SUPERVISOR_NEXT_CODE_OPT_STICKY_ON_RELOAD ;
412+ skip_repl = true;
413+ skip_wait = true;
412414 } else if (result .return_code == 0 ) {
413415 next_code_stickiness_situation |= SUPERVISOR_NEXT_CODE_OPT_STICKY_ON_SUCCESS ;
414416 if (next_code_options & SUPERVISOR_NEXT_CODE_OPT_RELOAD_ON_SUCCESS ) {
@@ -426,7 +428,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re
426428 }
427429 }
428430 if (result .return_code & PYEXEC_FORCED_EXIT ) {
429- skip_repl = reload_requested ;
431+ skip_repl = false ;
430432 skip_wait = true;
431433 }
432434 }
@@ -473,7 +475,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re
473475 RUN_BACKGROUND_TASKS ;
474476
475477 // If a reload was requested by the supervisor or autoreload, return
476- if (reload_requested ) {
478+ if (result . return_code & PYEXEC_RELOAD ) {
477479 next_code_stickiness_situation |= SUPERVISOR_NEXT_CODE_OPT_STICKY_ON_RELOAD ;
478480 // Should the STICKY_ON_SUCCESS and STICKY_ON_ERROR bits be cleared in
479481 // next_code_stickiness_situation? I can see arguments either way, but I'm deciding
@@ -627,13 +629,14 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re
627629 }
628630 }
629631
632+ // Done waiting, start the board back up.
633+
630634 // free code allocation if unused
631635 if ((next_code_options & next_code_stickiness_situation ) == 0 ) {
632636 free_memory (next_code_allocation );
633637 next_code_allocation = NULL ;
634638 }
635639
636- // Done waiting, start the board back up.
637640 #if CIRCUITPY_STATUS_LED
638641 if (led_active ) {
639642 new_status_color (BLACK );
@@ -757,7 +760,7 @@ STATIC int run_repl(bool first_run) {
757760 usb_setup_with_vm ();
758761 #endif
759762
760- autoreload_suspend (AUTORELOAD_LOCK_REPL );
763+ autoreload_suspend (AUTORELOAD_SUSPEND_REPL );
761764
762765 // Set the status LED to the REPL color before running the REPL. For
763766 // NeoPixels and DotStars this will be sticky but for PWM or single LED it
@@ -787,7 +790,7 @@ STATIC int run_repl(bool first_run) {
787790 status_led_deinit ();
788791 #endif
789792
790- autoreload_resume (AUTORELOAD_LOCK_REPL );
793+ autoreload_resume (AUTORELOAD_SUSPEND_REPL );
791794 return exit_code ;
792795}
793796
0 commit comments