Replace both ESP tinyusb component and ASF4 USB stack with TinyUSB 0.20.0 submodule#371
Draft
SukuWc wants to merge 32 commits into
Draft
Replace both ESP tinyusb component and ASF4 USB stack with TinyUSB 0.20.0 submodule#371SukuWc wants to merge 32 commits into
SukuWc wants to merge 32 commits into
Conversation
Split the monolithic grid_esp32_usb.c into separate files by USB class:
- grid_esp32_usb_acm.c/h CDC-ACM serial, migrated from tinyusb_cdcacm
high-level API to native tud_cdc_* callbacks
- grid_esp32_usb_hid.c/h HID (keyboard, mouse, gamepad)
- grid_esp32_usb_midi.c/h MIDI RX/TX
grid_esp32_usb.c now contains only USB descriptors and init.
grid_esp32_usb.h is an umbrella header that includes all subsystems.
The ACM migration to native callbacks removes the esp_tinyusb cdcacm
layer while keeping identical behaviour: tud_cdc_line_state_cb sets
usb_tx_ready on DTR, tud_cdc_tx_complete_cb clears the busy flag.
Also removes the stale #include "tinyusb_cdc_acm.h" from grid_esp32s3.c.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Pin upstream hathach/tinyusb at tag 0.19.0 (331c263) as a git submodule. Update common/.gitignore allowlist to include dep/tinyusb. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…B submodule
Use hathach/tinyusb 0.19.0 (common/dep/tinyusb submodule) directly instead
of the espressif/esp_tinyusb managed component.
Changes:
- Add esp32s3/components/tinyusb/ local component:
- CMakeLists.txt: compiles TinyUSB source files from the submodule,
sets CFG_TUSB_MCU via compile flag for ESP32-S2/S3
- include/tusb_config.h: hand-written config with CDC=1, MIDI=1, HID=1,
slave/IRQ mode (no DMA), FREERTOS OS abstraction
- Rewrite grid_esp32_usb.c:
- Drop tinyusb_driver_install() / TINYUSB_DEFAULT_CONFIG()
- Add static tusb_desc_device_t with IAD class (CDC present)
- Add tud_descriptor_device_cb(), tud_descriptor_configuration_cb(),
tud_descriptor_string_cb() (TinyUSB descriptor callbacks)
- Replace driver install with usb_new_phy() + FreeRTOS task calling
tusb_rhport_init() + tud_task()
- Replace #include "tinyusb.h" with #include "tusb.h" everywhere:
grid_esp32_usb_acm.c, _hid.c, _hid.h, _midi.c,
grid_esp32_port.c, main/grid_esp32s3.c
- Update CMakeLists REQUIRES:
- grid_esp32_usb: esp_tinyusb -> tinyusb + esp_hw_support
- grid_esp32_port: esp_tinyusb -> tinyusb
- Remove espressif/esp_tinyusb from main/idf_component.yml
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
common/dep/tinyusb is now a submodule; add submodules: recursive to the checkout step so the TinyUSB source is available during the build. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Synopsys (the IP vendor behind the DWC2 USB core) would otherwise be flagged as a misspelling of synopsis. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace the Atmel START / ASF4 composite USB stack on the SAMD51
firmware with the same upstream TinyUSB submodule already used by
the ESP32-S3 target (common/dep/tinyusb, pinned to tag 0.19.0).
Key changes:
- d51n20a/grid/d51/tusb_config.h (new): TinyUSB config for SAMD51
OPT_OS_NONE + OPT_MCU_SAMD51, CDC/MIDI/HID enabled.
CFG_TUSB_RHPORT0_MODE = full-speed device.
- d51n20a/gcc/Makefile: swap ASF4 USB sources for TinyUSB sources
(tusb.c, usbd.c, cdc/midi/hid class drivers, dcd_samd.c).
Remove old ASF4 USB include paths; add common/dep/tinyusb/src.
- d51n20a/grid/d51/grid_d51_usb.h: strip ASF4 includes; expose
TinyUSB-based platform API.
- d51n20a/grid/d51/grid_d51_usb.c: full rewrite — USB descriptors,
SAMD51 IRQ handlers (USB_0–3_Handler → dcd_int_handler),
tud_cdc_rx/tx callbacks, MIDI via tud_midi_packet_read,
HID via tud_hid_keyboard/mouse_report.
Stub usb_d_init() so driver_init.c USB clock/pin-mux init
still runs; TinyUSB takes over the peripheral in tusb_init().
- d51n20a/atmel_start.h: remove #include "usb_start.h" (ASF4 USB).
- d51n20a/atmel_start.c: remove usb_init() call (now handled by
grid_d51_usb_init() via tusb_init()).
- d51n20a/grid_d51n20a.c: tud_task() in main loop; tud_mounted()
replaces usb_d_get_frame_num(); grid_d51_midi_rx_poll() replaces
grid_d51_midi_bulkout_poll().
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
SukuWc
commented
May 25, 2026
Member
Author
There was a problem hiding this comment.
Just remove the comment, not need to keep it for documentation
Member
Author
There was a problem hiding this comment.
Just remove the comment, not need to keep it for documentation
Member
Author
There was a problem hiding this comment.
Remove all the added comments
Member
Author
There was a problem hiding this comment.
Separate to 3 files based on the interfaces similar to how it is done for the ESP32S3 firmware variant: CDC, MIDI, HID
- grid_d51_usb.c now only contains descriptors, IRQ handlers, and init
- grid_d51_usb_acm.{c,h}: CDC/ACM platform API and TinyUSB callbacks
- grid_d51_usb_midi.{c,h}: MIDI platform API and TinyUSB callbacks
- grid_d51_usb_hid.{c,h}: HID platform API, TinyUSB callbacks, websocket stubs
- Remove explanatory comments from atmel_start.c and atmel_start.h
- Matches ESP32-S3 per-interface file structure
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… append Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ui_page_read Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes