esp32usb is an ESP-IDF component that provides an alternative for the ESP-IDF TinyUSB component. This code uses https://github.com/hathach/tinyusb rather than https://github.com/espressif/tinyusb.
This component depends on ESP-IDF v4.4 and should work for both ESP32-S2 and ESP32-S3 but does not have exhaustive testing of all functionality. Testing is generally limited to CDC and MSC.
NOTE It is highly recommended to use the ESP-IDF tinyusb component instead of this component.
In your project, add this as a submodule to your components/
directory.
git submodule add https://github.com/atanisoft/esp32usb.git
git submodule update --recursive --init -- esp32usb
The library can be configured via idf.py menuconfig
under TinyUSB (esp32usb)
.
In the app_main()
method you should have code similar to the following:
void app_main() {
init_usb_subsystem();
configure_usb_descriptor_str(USB_DESC_MANUFACTURER, "esp32usb");
configure_usb_descriptor_str(USB_DESC_PRODUCT, "esp32usb Device");
configure_usb_descriptor_str(USB_DESC_SERIAL_NUMBER, "1234567890");
start_usb_task();
.... rest of application code
}
If you are configuring a virtual disk you will need to configure it prior to calling start_usb_task()
:
static const char * const readme_txt =
"This is esp32usb's MassStorage Class demo.\r\n\r\n"
"If you find any bugs or get any questions, feel free to file an\r\n"
"issue at github.com/atanisoft/esp32usb"
void app_main() {
init_usb_subsystem();
configure_usb_descriptor_str(USB_DESC_MANUFACTURER, "esp32usb");
configure_usb_descriptor_str(USB_DESC_PRODUCT, "esp32usb Device");
configure_usb_descriptor_str(USB_DESC_SERIAL_NUMBER, "1234567890");
configure_virtual_disk("esp32usb", 0x0100);
add_readonly_file_to_virtual_disk("readme.txt", readme_txt, strlen(readme_txt));
add_partition_to_virtual_disk("spiffs", "spiffs.bin");
add_firmware_to_virtual_disk();
start_usb_task();
- The virtual disk support is currently limited to around 4MiB in size but may be configurable in the future.
- Adding the firmware to the virtual disk is currently limited to showing only two OTA partitions (current and previous/next). If more than two OTA partitions are in use it is recommended to use
add_partition_to_virtual_disk
instead ofadd_firmware_to_virtual_disk
so more images can be displayed.