summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2025-06-23 12:53:49 +1000
committerDamien George <damien@micropython.org>2025-07-08 10:10:16 +1000
commit6b82eb75bef70d44ef583385301b7c483ac9ae94 (patch)
tree41ff82da81b70efb0c5aad029f5013c8f4610829
parentd9b4327c66d455f4654ab4f223067f3e20440333 (diff)
zephyr/main: Add /flash/lib or /sd/lib to sys.path on start up.
If there is a filesystem available, this change makes sure there is a "lib" in `sys.path`, eg so that "mip install" works correctly. Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--ports/zephyr/CMakeLists.txt4
-rw-r--r--ports/zephyr/main.c4
-rw-r--r--ports/zephyr/qstrdefsport.h4
3 files changed, 12 insertions, 0 deletions
diff --git a/ports/zephyr/CMakeLists.txt b/ports/zephyr/CMakeLists.txt
index debf2bd2c..0ae4b26ac 100644
--- a/ports/zephyr/CMakeLists.txt
+++ b/ports/zephyr/CMakeLists.txt
@@ -70,6 +70,10 @@ set(MICROPY_SOURCE_SHARED
)
list(TRANSFORM MICROPY_SOURCE_SHARED PREPEND ${MICROPY_DIR}/shared/)
+set(MICROPY_QSTRDEFS_PORT
+ ${MICROPY_PORT_DIR}/qstrdefsport.h
+)
+
set(MICROPY_SOURCE_LIB
oofatfs/ff.c
oofatfs/ffunicode.c
diff --git a/ports/zephyr/main.c b/ports/zephyr/main.c
index 9addd7d6c..eaef34a78 100644
--- a/ports/zephyr/main.c
+++ b/ports/zephyr/main.c
@@ -99,6 +99,7 @@ static void vfs_init(void) {
mp_obj_t bdev = NULL;
mp_obj_t mount_point;
const char *mount_point_str = NULL;
+ qstr path_lib_qstr = MP_QSTRnull;
int ret = 0;
#ifdef CONFIG_DISK_DRIVER_SDMMC
@@ -109,15 +110,18 @@ static void vfs_init(void) {
#endif
bdev = MP_OBJ_TYPE_GET_SLOT(&zephyr_disk_access_type, make_new)(&zephyr_disk_access_type, ARRAY_SIZE(args), 0, args);
mount_point_str = "/sd";
+ path_lib_qstr = MP_QSTR__slash_sd_slash_lib;
#elif defined(CONFIG_FLASH_MAP) && FIXED_PARTITION_EXISTS(storage_partition)
mp_obj_t args[] = { MP_OBJ_NEW_SMALL_INT(FIXED_PARTITION_ID(storage_partition)), MP_OBJ_NEW_SMALL_INT(4096) };
bdev = MP_OBJ_TYPE_GET_SLOT(&zephyr_flash_area_type, make_new)(&zephyr_flash_area_type, ARRAY_SIZE(args), 0, args);
mount_point_str = "/flash";
+ path_lib_qstr = MP_QSTR__slash_flash_slash_lib;
#endif
if ((bdev != NULL)) {
mount_point = mp_obj_new_str_from_cstr(mount_point_str);
ret = mp_vfs_mount_and_chdir_protected(bdev, mount_point);
+ mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(path_lib_qstr));
// TODO: if this failed, make a new file system and try to mount again
}
}
diff --git a/ports/zephyr/qstrdefsport.h b/ports/zephyr/qstrdefsport.h
new file mode 100644
index 000000000..66819e432
--- /dev/null
+++ b/ports/zephyr/qstrdefsport.h
@@ -0,0 +1,4 @@
+// qstrs specific to this port
+// *FORMAT-OFF*
+Q(/flash/lib)
+Q(/sd/lib)