Skip to content

Commit 492f6e9

Browse files
authored
Merge pull request #10263 from tannewt/next_code_working_dir
Add working_directory for subsequent code file
2 parents ba69a59 + 50382b2 commit 492f6e9

File tree

20 files changed

+203
-31
lines changed

20 files changed

+203
-31
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
[submodule "ports/raspberrypi/sdk"]
174174
path = ports/raspberrypi/sdk
175175
url = https://github.com/adafruit/pico-sdk.git
176-
branch = force_inline_critical_section
176+
branch = force_inline_critical_section_2.1.1
177177
[submodule "data/nvm.toml"]
178178
path = data/nvm.toml
179179
url = https://github.com/adafruit/nvm.toml.git

extmod/vfs_fat.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
// CIRCUITPY-CHANGE: extra includes
4040
#include <string.h>
41+
#include "py/gc.h"
4142
#include "py/obj.h"
4243
#include "py/objproperty.h"
4344
#include "py/runtime.h"
@@ -342,7 +343,10 @@ static mp_obj_t fat_vfs_stat(mp_obj_t vfs_in, mp_obj_t path_in) {
342343
FRESULT res = f_stat(&self->fatfs, path, &fno);
343344
if (res != FR_OK) {
344345
// CIRCUITPY-CHANGE
345-
mp_raise_OSError_fresult(res);
346+
if (gc_alloc_possible()) {
347+
mp_raise_OSError_fresult(res);
348+
}
349+
return mp_const_none;
346350
}
347351
}
348352

main.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,14 +457,19 @@ static bool __attribute__((noinline)) run_code_py(safe_mode_t safe_mode, bool *s
457457
usb_setup_with_vm();
458458
#endif
459459

460+
// Always return to root before trying to run files.
461+
common_hal_os_chdir("/");
460462
// Check if a different run file has been allocated
461463
if (next_code_configuration != NULL) {
462464
next_code_configuration->options &= ~SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET;
463465
next_code_options = next_code_configuration->options;
464466
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+
}
465470
// This is where the user's python code is actually executed:
466471
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);
468473
if (!found_main) {
469474
serial_write(next_code_configuration->filename);
470475
serial_write_compressed(MP_ERROR_TEXT(" not found.\n"));
@@ -1105,9 +1110,6 @@ int __attribute__((used)) main(void) {
11051110
}
11061111
simulate_reset = false;
11071112

1108-
// Always return to root before trying to run files.
1109-
common_hal_os_chdir("/");
1110-
11111113
if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL) {
11121114
// If code.py did a fake deep sleep, pretend that we
11131115
// are running code.py for the first time after a hard

ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ SPI_FLASH_FILESYSTEM = 1
1010
EXTERNAL_FLASH_DEVICES = "W25Q32JVxQ"
1111
LONGINT_IMPL = MPZ
1212

13+
CIRCUITPY_CODEOP = 0
1314
CIRCUITPY_JPEGIO = 0

ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ QSPI_FLASH_FILESYSTEM = 1
1010
EXTERNAL_FLASH_DEVICES = "W25Q64JVxQ, S25FL064L"
1111
LONGINT_IMPL = MPZ
1212

13+
CIRCUITPY_I2CTARGET = 0
1314
CIRCUITPY_PS2IO = 1
1415
CIRCUITPY_JPEGIO = 0
1516
CIRCUITPY_SPITARGET = 0

ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ CHIP_FAMILY = samd51
99
QSPI_FLASH_FILESYSTEM = 1
1010
EXTERNAL_FLASH_DEVICES = "GD25Q16C, W25Q16JVxQ, W25Q16JVxM"
1111
LONGINT_IMPL = MPZ
12-
CIRCUITPY_SYNTHIO = 0
12+
13+
CIRCUITPY_I2CTARGET = 0
1314
CIRCUITPY_JPEGIO = 0
1415
CIRCUITPY_SPITARGET = 0
16+
CIRCUITPY_SYNTHIO = 0
1517
CIRCUITPY_TILEPALETTEMAPPER = 0

ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ CHIP_FAMILY = samd21
99
SPI_FLASH_FILESYSTEM = 1
1010
EXTERNAL_FLASH_DEVICES = "S25FL064L"
1111
LONGINT_IMPL = MPZ
12+
13+
CIRCUITPY_CODEOP = 0

ports/atmel-samd/boards/feather_m4_can/mpconfigboard.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ CIRCUITPY__EVE = 1
1414
CIRCUITPY_BITMAPFILTER = 0
1515
CIRCUITPY_CANIO = 1
1616
CIRCUITPY_FLOPPYIO = 0
17-
CIRCUITPY_SYNTHIO = 0
1817
CIRCUITPY_GIFIO = 0
18+
CIRCUITPY_I2CTARGET = 0
1919
CIRCUITPY_JPEGIO = 0
20+
CIRCUITPY_SYNTHIO = 0
2021

2122
CIRCUITPY_LTO_PARTITION = one
2223

ports/atmel-samd/boards/openbook_m4/mpconfigboard.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ QSPI_FLASH_FILESYSTEM = 1
1010
EXTERNAL_FLASH_DEVICES = GD25Q16C
1111
LONGINT_IMPL = MPZ
1212

13+
CIRCUITPY_FLOPPYIO = 0
14+
CIRCUITPY_I2CTARGET = 0
15+
CIRCUITPY_JPEGIO = 0
1316
CIRCUITPY_KEYPAD = 1
1417
CIRCUITPY_SYNTHIO = 0
15-
CIRCUITPY_JPEGIO = 0
16-
CIRCUITPY_FLOPPYIO = 0
1718
CIRCUITPY_TERMINALIO_VT100 = 0
1819
CIRCUITPY_TILEPALETTEMAPPER = 0

ports/atmel-samd/boards/silicognition-m4-shim/mpconfigboard.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ QSPI_FLASH_FILESYSTEM = 1
1010
EXTERNAL_FLASH_DEVICES = GD25Q16C
1111
LONGINT_IMPL = MPZ
1212

13+
CIRCUITPY_I2CTARGET = 0
1314
CIRCUITPY_JPEGIO = 0
1415
CIRCUITPY_SPITARGET = 0
1516
CIRCUITPY_SYNTHIO = 0

0 commit comments

Comments
 (0)