Create hidden file for the IDE to detect OMV disk.
@@ -235,6 +235,15 @@ void __attribute__((weak))
}
#endif
+void f_touch(const char *path)
+{
+ FIL fp;
+ if (f_stat(&vfs_fat->fatfs, path, NULL) != FR_OK) {
+ f_open(&vfs_fat->fatfs, &fp, path, FA_WRITE | FA_CREATE_ALWAYS);
+ f_close(&fp);
+ }
+}
+
void make_flash_fs()
{
FIL fp;
@@ -247,6 +256,9 @@ void make_flash_fs()
__fatal_error("Could not create LFS");
}
+ // Mark FS as OpenMV disk.
+ f_touch("/.openmv_disk");
+
// Create default main.py
f_open(&vfs_fat->fatfs, &fp, "/main.py", FA_WRITE | FA_CREATE_ALWAYS);
f_write(&fp, fresh_main_py, sizeof(fresh_main_py) - 1 /* don't count null terminator */, &n);
@@ -510,6 +522,9 @@ soft_reset:
pyb_usb_storage_medium = PYB_USB_STORAGE_MEDIUM_FLASH;
}
+ // Mark FS as OpenMV disk.
+ f_touch("/.openmv_disk");
+
// Mount the storage device (there should be no other devices mounted at this point)
// we allocate this structure on the heap because vfs->next is a root pointer.
mp_vfs_mount_t *vfs = m_new_obj_maybe(mp_vfs_mount_t);
@@ -524,9 +539,6 @@ soft_reset:
MP_STATE_VM(vfs_mount_table) = vfs;
MP_STATE_PORT(vfs_cur) = vfs;
- // set label
- f_setlabel(&vfs_fat->fatfs, "OPENMV_DISK");
-
// Parse OpenMV configuration file.
openmv_config_t openmv_config;
if (first_soft_reset) {
