How to resume fopen() functionality after SD used by USB MSC

chriscckan
Posts: 6
Joined: Tue Sep 05, 2023 8:51 am

How to resume fopen() functionality after SD used by USB MSC

Postby chriscckan » Tue Sep 05, 2023 9:50 am

using ESP32-S3, I have setup the SD card and USB MSC using following API sequence at boot time:

esp_vfs_fat_sdmmc_mount();
tinyusb_msc_storage_init_sdmmc();
tinyusb_msc_storage_mount();
tinyusb_driver_install();

before it was plugged into PC, fopen() and all file operation is working fine. when plugged into PC, a USB MSC drive is form successfully, however, after unplugged from PC, all file operation (e.g. fopen()) still not working, looks like SD card is being occupied by TinyUSB MSC code. How can I resume the file operation in my app_main()? I have tried tinyusb_msc_storage_unmount() but it does not help.

chriscckan
Posts: 6
Joined: Tue Sep 05, 2023 8:51 am

Re: How to resume fopen() functionality after SD used by USB MSC

Postby chriscckan » Tue Sep 05, 2023 3:09 pm

I do according to the README of USB MSC device example code, using self power flag and VBUS monitor IO, however it totally not help.
After doing more reading on the "tusb_msc_storage.h" comment, I try to call tinyusb_msc_storage_mount(BASE_PATH) when unpluged, I found this API will disconnect the MSC from host PC, and now the fopen() file operation become working again.
But I would expect using self power flag and VBUS monitor IO it SHOULD be able to do it automatically in the ESP-IDF code instead of let user do it under such non-documented situation.

Who is online

Users browsing this forum: No registered users and 350 guests