In a custom L1 board, I have microSD card configured with FATFS SDIO. At the power-on-reset, FATFS is initialized by
memset(&fs32, 0, sizeof(FATFS));
res = f_mount(0, &fs32);
memset(&fil, 0, sizeof(FIL));
16KB Sensor Buffer is filling with sensor data (sampling rate 10ms). A file is left open at the beginning of loop (f_open), FATFS write occurs in every 15sec and syncing files (f_sync) in every 30min. Upon connecting USB cable, Sensor write stops, close file (f_close) and USB MSC initiates. It worked for a week. The custom board didnot have any battery protection(circuit or code). Probably for low battery (or any software issue), USB MSC is not recognizing microSD card anymore. In a test board, it happened and was solved by removing and reinserting SD card. My current board is sealed and only USB DFU mode is available for firmware upload. Can unmount/formatting card using FATFS commands solve this issue? I'm using FATFS R0.09.
I request your kind suggestion to solve this issue.