I am using the ESP32-S2-Wrover.
I have tested the two examples "wear_levelling" (from ESP-IDF) and "cdc_msc_freertos" (from github: tinyusb/examples/device/cdc_msc/src/) and are running.
In the example "cdc_msc_freertos" the disk is unfortunately mapped in the RAM.
I would now like to create a partition with FATFS in the SPI flash that I can access via USB MSC.
I can generate the FATFS as in the "wear-leveling" example. However, I now have the problem of how do I access this FATFS block-oriented to read and write. The data between the USB host (Windows PC) and the USB device (ESP32-S2) are exchanged in blocks.
Does anyone have a tip on how I can do that?
Is there possibly a sample code for this.
Thank you for your support.
ESP32-S2 USB MSC FATFS SPI-Flash
Re: ESP32-S2 USB MSC FATFS SPI-Flash
Hi E_SCH,
There doesn't seem to be an example which combines wear levelling and USB MSC yet. Could you explain, what do you expect from such an example? I think concurrent access to the same partition from the app (via FATFS library) and from USB (via MSC) is tricky. You would need to decide somehow who is allowed to modify the partition at any given time — the application running on ESP, or the host. Allowing both to access the partition at the same time will likely result in data corruption.
There doesn't seem to be an example which combines wear levelling and USB MSC yet. Could you explain, what do you expect from such an example? I think concurrent access to the same partition from the app (via FATFS library) and from USB (via MSC) is tricky. You would need to decide somehow who is allowed to modify the partition at any given time — the application running on ESP, or the host. Allowing both to access the partition at the same time will likely result in data corruption.
Re: ESP32-S2 USB MSC FATFS SPI-Flash
I think there is few problems with accessing raw data and wear leveling (at least i got such problems and quit that usage).
1. MSC read/write raw data, sector by sector
2. wear leveling is adding extra sectors and host OSs dont know how to deal with it
3. i didnt find API to read raw sectors to bridge between MSC and flash; i know we can use regular API to read/write partitions, but that excludes wear leveling i suppose
1. MSC read/write raw data, sector by sector
2. wear leveling is adding extra sectors and host OSs dont know how to deal with it
3. i didnt find API to read raw sectors to bridge between MSC and flash; i know we can use regular API to read/write partitions, but that excludes wear leveling i suppose
Re: ESP32-S2 USB MSC FATFS SPI-Flash
I think you can use wl_read, wl_write functions for this purpose. Basically, if the host asks for sector N, you don't read physical sector N, instead you call wl_read(handle, N * sector_size, ...) to read the logical sector that is managed by wear_levelling.chegewara wrote: 3. i didnt find API to read raw sectors to bridge between MSC and flash; i know we can use regular API to read/write partitions, but that excludes wear leveling i suppose
This way the host operations will go through the wear_levelling layer.
Re: ESP32-S2 USB MSC FATFS SPI-Flash
It seems to work more or less, and by more or less i mean FAT sector is read and recognized by ubuntu properly, but thats it.ESP_igrr wrote: I think you can use wl_read, wl_write functions for this purpose. Basically, if the host asks for sector N, you don't read physical sector N, instead you call wl_read(handle, N * sector_size, ...) to read the logical sector that is managed by wear_levelling.
This way the host operations will go through the wear_levelling layer.
System shows expected disk size etc. I can see also files that do not exist:
To mount VFS i am using this function:
https://docs.espressif.com/projects/esp ... l_handle_t
FFat partition and whole code are arduino.
Re: ESP32-S2 USB MSC FATFS SPI-Flash
I found this code useful. No need to use low level API (like wl_read/wl_write):
https://github.com/espressif/esp-iot-so ... tusb_msc.c
Now i have only issue with WL sector size under arduino, which is 4096 bytes and tinyusb is configured to work with 512 bytes buffer.
https://github.com/espressif/esp-iot-so ... tusb_msc.c
Now i have only issue with WL sector size under arduino, which is 4096 bytes and tinyusb is configured to work with 512 bytes buffer.
Who is online
Users browsing this forum: No registered users and 275 guests