From a327fec8cfd70e6d9193a94562a2b0e1a910b9c0 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Wed, 31 Oct 2018 02:19:48 +0200 Subject: [PATCH] Create hidden file for the IDE to detect OMV disk. --- src/omv/main.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/omv/main.c b/src/omv/main.c index 9f9f80a75..8c06b4a75 100644 --- a/src/omv/main.c +++ b/src/omv/main.c @@ -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) {