espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.84k stars 7.32k forks source link

Combine file_server and tusb_msc (IDFGH-11908) #12990

Open diplfranzhoepfinger opened 10 months ago

diplfranzhoepfinger commented 10 months ago

Answers checklist.

General issue report

Hi,

using https://github.com/espressif/esp-idf/releases/tag/v5.1.2

i want to combine: Simple HTTP File Server Example https://github.com/espressif/esp-idf/tree/master/examples/protocols/http_server/file_serving

and TinyUSB Mass Storage Device Example https://github.com/espressif/esp-idf/tree/master/examples/peripherals/usb/device/tusb_msc

i must say in addition: i want both to use the same Partition as Data.

so USB and File Server should show same Files.

I face the following Problem:

https://github.com/espressif/esp-idf/blob/b3f7e2c8a4d354df8ef8558ea7caddc07283a57b/examples/peripherals/usb/device/tusb_msc/partitions.csv#L6

https://github.com/espressif/esp-idf/blob/b3f7e2c8a4d354df8ef8558ea7caddc07283a57b/examples/protocols/http_server/file_serving/partitions_example.csv#L6

As i understood: first, we must change the File-Server Example to fatfs, instead of spiffs.

this is quite easy: https://github.com/diplfranzhoepfinger/file_serving

but then it comes to the Line: tinyusb_msc_storage_init_spiflash

and there it gives a Crash. E (1332) tinyusb_msc_storage: tinyusb_msc_storage_mount(293): Failed _mount

diplfranzhoepfinger commented 10 months ago

Hi, @nopnop2002

file_serving example only supports SD cards or SPIFFS.

https://github.com/diplfranzhoepfinger/file_serving/blob/main/file_serving/main/mount.c

yes, true, but i changed it to FAT, and it runs fine.

see here: https://github.com/diplfranzhoepfinger/file_serving/blob/7abcde520c2cabd8233685884aca0893aaf84cf6/file_serving/main/mount.c#L141C39-L141C39

nopnop2002 commented 10 months ago

file_serving example only supports SD cards or SPIFFS File System.

TinyUSB only supports FAT. Data is read/written from/to SPI Flash through wear-levelling APIs.

diplfranzhoepfinger commented 10 months ago

look:

https://github.com/espressif/esp-idf/blob/b3f7e2c8a4d354df8ef8558ea7caddc07283a57b/examples/storage/wear_levelling/main/wear_levelling_example_main.c#L68C1-L80C6

and:

https://github.com/diplfranzhoepfinger/file_serving/blob/7abcde520c2cabd8233685884aca0893aaf84cf6/file_serving/main/mount.c#L133C1-L142C25

same code.

nopnop2002 commented 10 months ago

If you mount the USB memory with tinyusb_msc_storage_mount(), I don't think any other mounting is necessary.

There is no need to perform example_mount_storage().

diplfranzhoepfinger commented 10 months ago

yes, good idea ...

i will check it.

i understood it is only Mounted if it is plugged into PC.

so this will then not work. but i will check it ... OK. Thanks.

Am Mi., 17. Jan. 2024 um 13:27 Uhr schrieb nopnop2002 < @.***>:

If you mount the USB memory with tinyusb_msc_storage_mount(), I don't think any other mounting is necessary.

— Reply to this email directly, view it on GitHub https://github.com/espressif/esp-idf/issues/12990#issuecomment-1895709340, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJAHMXKGCECRYQII7TWIFKDYO67URAVCNFSM6AAAAABB5UXYPCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJVG4YDSMZUGA . You are receiving this because you authored the thread.Message ID: @.***>

-- Diplom-Informatiker Franz Höpfinger e.K. Reibersdorf 16a 84419 Schwindegg

diplfranzhoepfinger commented 10 months ago

If you mount the USB memory with tinyusb_msc_storage_mount(), I don't think any other mounting is necessary.

There is no need to perform example_mount_storage().

yes, approved, and working. 

the only thing is now: it seems the USB takes storage exclusively, not shared by the Application.

diplfranzhoepfinger commented 10 months ago

https://github.com/espressif/esp-idf/tree/master/examples/peripherals/usb/device/tusb_msc

well described here: will this change in Future ?