@@ -447,11 +447,17 @@ STATIC bool run_code_py(safe_mode_t safe_mode) {
447
447
FIL * boot_output_file ;
448
448
449
449
STATIC void __attribute__ ((noinline )) run_boot_py (safe_mode_t safe_mode ) {
450
- // If not in safe mode, run boot before initing USB and capture output in a
451
- // file.
452
- if (filesystem_present () && safe_mode == NO_SAFE_MODE && MP_STATE_VM (vfs_mount_table ) != NULL ) {
453
- static const char * const boot_py_filenames [] = STRING_LIST ("settings.txt" , "settings.py" , "boot.py" , "boot.txt" );
450
+ // If not in safe mode, run boot before initing USB and capture output in a file.
454
451
452
+ // There is USB setup to do even if boot.py is not actually run.
453
+ const bool ok_to_run = filesystem_present ()
454
+ && safe_mode == NO_SAFE_MODE
455
+ && MP_STATE_VM (vfs_mount_table ) != NULL ;
456
+
457
+ static const char * const boot_py_filenames [] = STRING_LIST ("settings.txt" , "settings.py" , "boot.py" , "boot.txt" );
458
+ bool skip_boot_output = false;
459
+
460
+ if (ok_to_run ) {
455
461
new_status_color (BOOT_RUNNING );
456
462
457
463
#ifdef CIRCUITPY_BOOT_OUTPUT_FILE
@@ -463,8 +469,6 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
463
469
464
470
bool have_boot_py = first_existing_file_in_list (boot_py_filenames ) != NULL ;
465
471
466
- bool skip_boot_output = false;
467
-
468
472
// If there's no boot.py file that might write some changing output,
469
473
// read the existing copy of CIRCUITPY_BOOT_OUTPUT_FILE and see if its contents
470
474
// match the version info we would print anyway. If so, skip writing CIRCUITPY_BOOT_OUTPUT_FILE.
@@ -505,15 +509,20 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
505
509
#endif
506
510
507
511
filesystem_flush ();
508
- supervisor_allocation * heap = allocate_remaining_memory ();
509
- start_mp (heap );
512
+ }
510
513
511
- #if CIRCUITPY_USB
512
- // Set up default USB values after boot.py VM starts but before running boot.py.
513
- usb_set_defaults ();
514
- #endif
514
+ // Do USB setup even if boot.py is not run.
515
+
516
+ supervisor_allocation * heap = allocate_remaining_memory ();
517
+ start_mp (heap );
518
+
519
+ #if CIRCUITPY_USB
520
+ // Set up default USB values after boot.py VM starts but before running boot.py.
521
+ usb_set_defaults ();
522
+ #endif
515
523
516
- // TODO(tannewt): Re-add support for flashing boot error output.
524
+ // TODO(tannewt): Re-add support for flashing boot error output.
525
+ if (ok_to_run ) {
517
526
bool found_boot = maybe_run_list (boot_py_filenames , NULL );
518
527
(void ) found_boot ;
519
528
@@ -524,29 +533,28 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
524
533
}
525
534
boot_output_file = NULL ;
526
535
#endif
536
+ }
527
537
528
538
529
- #if CIRCUITPY_USB
530
-
531
- // Some data needs to be carried over from the USB settings in boot.py
532
- // to the next VM, while the heap is still available.
533
- // Its size can vary, so save it temporarily on the stack,
534
- // and then when the heap goes away, copy it in into a
535
- // storage_allocation.
539
+ #if CIRCUITPY_USB
536
540
537
- size_t size = usb_boot_py_data_size ();
538
- uint8_t usb_boot_py_data [size ];
539
- usb_get_boot_py_data (usb_boot_py_data , size );
540
- #endif
541
+ // Some data needs to be carried over from the USB settings in boot.py
542
+ // to the next VM, while the heap is still available.
543
+ // Its size can vary, so save it temporarily on the stack,
544
+ // and then when the heap goes away, copy it in into a
545
+ // storage_allocation.
541
546
542
- cleanup_after_vm (heap );
547
+ size_t size = usb_boot_py_data_size ();
548
+ uint8_t usb_boot_py_data [size ];
549
+ usb_get_boot_py_data (usb_boot_py_data , size );
550
+ #endif
543
551
544
- #if CIRCUITPY_USB
545
- // Now give back the data we saved from the heap going away.
546
- usb_return_boot_py_data (usb_boot_py_data , size );
547
- #endif
552
+ cleanup_after_vm (heap );
548
553
549
- }
554
+ #if CIRCUITPY_USB
555
+ // Now give back the data we saved from the heap going away.
556
+ usb_return_boot_py_data (usb_boot_py_data , size );
557
+ #endif
550
558
}
551
559
552
560
STATIC int run_repl (void ) {
0 commit comments