@@ -457,14 +457,19 @@ static bool __attribute__((noinline)) run_code_py(safe_mode_t safe_mode, bool *s
457
457
usb_setup_with_vm ();
458
458
#endif
459
459
460
+ // Always return to root before trying to run files.
461
+ common_hal_os_chdir ("/" );
460
462
// Check if a different run file has been allocated
461
463
if (next_code_configuration != NULL ) {
462
464
next_code_configuration -> options &= ~SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET ;
463
465
next_code_options = next_code_configuration -> options ;
464
466
if (next_code_configuration -> filename [0 ] != '\0' ) {
467
+ if (next_code_configuration -> working_directory != NULL ) {
468
+ common_hal_os_chdir (next_code_configuration -> working_directory );
469
+ }
465
470
// This is where the user's python code is actually executed:
466
471
const char * const filenames [] = { next_code_configuration -> filename };
467
- found_main = maybe_run_list (filenames , MP_ARRAY_SIZE ( filenames ) );
472
+ found_main = maybe_run_list (filenames , 1 );
468
473
if (!found_main ) {
469
474
serial_write (next_code_configuration -> filename );
470
475
serial_write_compressed (MP_ERROR_TEXT (" not found.\n" ));
@@ -1105,9 +1110,6 @@ int __attribute__((used)) main(void) {
1105
1110
}
1106
1111
simulate_reset = false;
1107
1112
1108
- // Always return to root before trying to run files.
1109
- common_hal_os_chdir ("/" );
1110
-
1111
1113
if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL ) {
1112
1114
// If code.py did a fake deep sleep, pretend that we
1113
1115
// are running code.py for the first time after a hard
0 commit comments