Merge pull request #405 from openmv/create_disk_file

Create hidden file for the IDE to detect OMV disk.
This commit is contained in:
Ibrahim Abd Elkader 2018-10-31 02:28:21 +02:00 committed by GitHub
commit 81eb9b6985
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {