Code Monkey home page Code Monkey logo

esp32usb's Introduction

What is esp32usb

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.

How to use

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).

Integrating esp32usb with your project

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
}

Integrating a virtual disk drive

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();

Virtual Disk limitations

  1. The virtual disk support is currently limited to around 4MiB in size but may be configurable in the future.
  2. 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 of add_firmware_to_virtual_disk so more images can be displayed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.