File transfer over USB
File transfer over USB
I am using an ESP32-S3 module in a product that is going to take a number of pictures and other data, store it in jpg and txt files in FLASH memory. Eventually, the product will export the files over BLE to a smartphone. For now, though, I want to connect a PC to the USB port and export the files over USB. Can anyone point me in the right direction of how to best do this? Is there any example code that I can look at?
Thanks so much!
Thanks so much!
Re: File transfer over USB
Hi jmadsenee,
We don't have an example of USB device MSC class yet, sorry about that.
I happen to have something similar in this personal project: https://github.com/igrr/esp32s2-wasm-de ... mware/main
If you ignore the WebAssembly parts of that application, essentially it allows using a partition in SPI Flash either from the PC (via USB MSC) or from the firmware. The example was made for the ESP32-S2, but should be easy to convert to S3.
We don't have an example of USB device MSC class yet, sorry about that.
I happen to have something similar in this personal project: https://github.com/igrr/esp32s2-wasm-de ... mware/main
If you ignore the WebAssembly parts of that application, essentially it allows using a partition in SPI Flash either from the PC (via USB MSC) or from the firmware. The example was made for the ESP32-S2, but should be easy to convert to S3.
Re: File transfer over USB
Hi ESP_igrr,
Thanks so much for your reply!
I'm not really looking to make it an MSC device. What I want to do is be able to talk to it in a command/response kind of way. Some examples are:
I suppose I can make the ESP32-S3 a CDC ACM device and make up a protocol and a custom program on my PC to talk to it (say using LabView), but that has a limited data rate.
I seems that there should be a better way to do it. Like put it into USB-OTG mode as a device using some class (I don't know what that is...).
Do you have any thoughts?
Thanks so much for your reply!
I'm not really looking to make it an MSC device. What I want to do is be able to talk to it in a command/response kind of way. Some examples are:
- Request and receive a data file
- Request and receive a jpg file
- Set a parameter and receive a response
- Send a command and receive a response
I suppose I can make the ESP32-S3 a CDC ACM device and make up a protocol and a custom program on my PC to talk to it (say using LabView), but that has a limited data rate.
I seems that there should be a better way to do it. Like put it into USB-OTG mode as a device using some class (I don't know what that is...).
Do you have any thoughts?
Re: File transfer over USB
Why not build composite device, MSC + CDC-ACM?
Re: File transfer over USB
Does this also work with the tinyusb supplied within ESP-IDF 5.0?ESP_igrr wrote: ↑Wed Sep 28, 2022 7:32 amHi jmadsenee,
We don't have an example of USB device MSC class yet, sorry about that.
I happen to have something similar in this personal project: https://github.com/igrr/esp32s2-wasm-de ... mware/main
If you ignore the WebAssembly parts of that application, essentially it allows using a partition in SPI Flash either from the PC (via USB MSC) or from the firmware. The example was made for the ESP32-S2, but should be easy to convert to S3.
Re: File transfer over USB
The example will probably need some adaptation to IDF v5.0 due to some breaking changes in that version. However it should work, overall. I'll revisit the example once the final v5.0 version is released.
Re: File transfer over USB
@ESP_igrr That would be awesome! Do you think it's possible to use an attached sd-mmc card or chip to redirect to USB? I'm looking for a nice solution to put data on a card or chip and read out by USB. Was also looking at a hardware solution like the MAX14500/14502, but it seems this chip is outdated and I didn't find a replacement yet. Also it adds to cost.
Re: File transfer over USB
Yes, it should be very similar to that example, except that you would call sdmmc_write_sectors instead of wear_levilling functions.
Re: File transfer over USB
Unfortunately, I am far from being a USB expert, so please forgive my ignorance. I am trying to understand the ESP32-S3 USB. I am using only the internal USB PHY. Depending on where I look, I get conflicting information. The API Guides>>USB OTG Console states:
Where I'm going with this -
However, the TRF states:By default, USB_SERIAL_JTAG module is connected to the internal PHY of the ESP32-S3, while USB_OTG peripheral can be used only if the external USB PHY is connected. Since CDC console is provided via USB_OTG peripheral, it cannot be used through the internal PHY in this configuration.
The TRF goes on to talk about fuses and flags (such as RTC_CNTL_SW _USB_PHY_SEL_CFG) for connection switching. If USB OTG and USB Serial/JTAG are TDMed, do I have to be setting/clearing flags to switch between them?These two USB controllers can utilize the integrated internal transceiver by time-division multiplexing...When only internal transceiver is used, it is shared by USB OTG and USB Serial/JTAG.
Where I'm going with this -
USB Serial/JTAG is a CDC implementation, correct? I've implemented a console based on the examples>system>console examples (using esp_console_new_repl_usb_serial_jtag()). If I want to make a composite device, do I need to switch to USB OTG mode and use the tiny USB driver as in examples>peripherals>usb>tusb_console, then try to figure out ESP_iggr's project to make the MSC part? Or, can I keep my USB Serial/JTAG console and implement a USB OTG MSC device?chegewara wrote:Why not build composite device, MSC + CDC-ACM?
Re: File transfer over USB
Yes, for composite device you have to switch to tinyUSB.
This is quite old code, but i think you may find it useful:
https://github.com/espressif/esp-idf/pull/5355/files
https://github.com/espressif/esp-idf/pu ... c48d5bdd6e
https://github.com/espressif/esp-idf/pu ... abbe68fee1
This is quite old code, but i think you may find it useful:
https://github.com/espressif/esp-idf/pull/5355/files
https://github.com/espressif/esp-idf/pu ... c48d5bdd6e
https://github.com/espressif/esp-idf/pu ... abbe68fee1
Who is online
Users browsing this forum: No registered users and 218 guests