mirror of
https://github.com/micropython/micropython.git
synced 2025-07-21 04:51:12 +02:00
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>
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
4
ports/zephyr/qstrdefsport.h
Normal file
4
ports/zephyr/qstrdefsport.h
Normal file
@@ -0,0 +1,4 @@
|
||||
// qstrs specific to this port
|
||||
// *FORMAT-OFF*
|
||||
Q(/flash/lib)
|
||||
Q(/sd/lib)
|
Reference in New Issue
Block a user