Skip to content

Conversation

@Jason2866
Copy link
Owner

@Jason2866 Jason2866 commented Nov 11, 2025

Summary by CodeRabbit

  • New Features

    • Added TinyUSB host mode support alongside device mode functionality
    • Added ESP32-S3 support for 120M memory variants
  • Bug Fixes

    • Enhanced SPIFlash high-performance mode auto-detection for 120M configurations
    • Improved LCD display safety for OPI RAM builds
  • Chores

    • Updated configuration and build optimizations for ESP32-P4 and other targets

@coderabbitai
Copy link

coderabbitai bot commented Nov 11, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

PR modifies ESP32-S3 build configurations, refactors TinyUSB device controller to add host support, extracts frequency variants into build metadata, and updates compilation sources and configuration flags across multiple targets.

Changes

Cohort / File(s) Summary
Workflow and metadata
.github/workflows/parallel_build.yaml, configs/builds.json
Renamed workflow from "IDF v5.5 based build" to "IDF v5.5 S3 120M"; updated esp32s3 bootloaders and memory variants configuration (changed from dio/qio 80m variants to opi 120m variants).
Build scripts with frequency handling
build.sh, tools/copy-libs.sh, tools/copy-mem-variant.sh
Added extraction and propagation of MEM_VARIANT_FREQ from target-specific idf_libs and mem_variants data for esp32s3; updated log output and build paths to include frequency suffix.
TinyUSB host configuration
components/arduino_tinyusb/include/tusb_config.h
Enabled TinyUSB host support alongside device support; added CFG_TUH_ENABLED derived from CFG_TUD_ENABLED; configured host RHPort, enumeration buffer, hub/CDC/HID/MSC support.
TinyUSB device controller refactoring
components/arduino_tinyusb/CMakeLists.txt, components/arduino_tinyusb/src/dcd_dwc2.c
Removed espressif DWC2 source file from build; deleted entire device controller implementation including dcd_init, dcd_edpt_* functions, and interrupt handlers.
TinyUSB ESP32 DWC2 enhancements
components/arduino_tinyusb/patches/dcd_dwc2.patch
Added static FIFO accounting (_allocated_fifos, get_free_fifo) for ESP32-S2/S3; modified endpoint activation to select FIFO dynamically; reset FIFO state on USB events.
TinyUSB patch removal
tools/patch-tinyusb.sh, tools/update-components.sh, patches/dwc2_esp32_h.diff
Removed patch-tinyusb.sh script and dwc2_esp32.h header wrapper; eliminated dwc2_int_handler_wrap dispatch logic from update-components.sh.
Configuration updates
configs/defconfig.120m, configs/defconfig.common, configs/defconfig.esp32p4, configs/defconfig.esp32s3, configs/defconfig.opi_ram
Activated SPI flash HPM options for 120M config; added LIBC locks and LWIP TCP buffer settings; renamed ESP_WIFI_* to WIFI_RMT_* options for esp32p4; disabled LCD_RGB_RESTART_IN_VSYNC for esp32s3; added LCD_RGB_ISR_IRAM_SAFE for opi_ram.

Sequence Diagram

sequenceDiagram
    participant App as Application
    participant Init as TinyUSB Init
    participant Device as Device Mode<br/>(CFG_TUD_ENABLED)
    participant Host as Host Mode<br/>(CFG_TUH_ENABLED)
    participant DWC2 as DWC2 Controller<br/>(with FIFO mgmt)
    
    rect rgb(200, 220, 255)
    Note over App,Init: Initialization Phase
    App->>Init: tusb_init()
    Init->>Device: dcd_init() or equiv.
    Init->>Host: hcd_init() or equiv.
    Device->>DWC2: Enable device endpoints
    Host->>DWC2: Enable host ports
    end
    
    rect rgb(220, 200, 255)
    Note over App,Host: Device Operation (Endpoint Transfers)
    App->>Device: dcd_edpt_xfer(ep_addr, ...)
    Device->>DWC2: Allocate FIFO via get_free_fifo()
    DWC2->>DWC2: Update depctl.tx_fifo_num
    DWC2-->>Device: Transfer scheduled
    end
    
    rect rgb(255, 220, 200)
    Note over App,Host: USB Event Handling
    DWC2->>DWC2: Bus reset / suspend / unplugged
    DWC2->>DWC2: Reset _allocated_fifos = 1
    DWC2-->>Device: Event propagated
    DWC2-->>Host: Event propagated
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Key areas requiring attention:

  • TinyUSB device controller removal: Verify that removal of dcd_dwc2.c and multiple exported functions does not break existing device-mode functionality elsewhere; confirm host mode replaces this or alternative implementation exists.
  • FIFO accounting patch: Review the new static variables (_allocated_fifos) and get_free_fifo() logic for race conditions, boundary conditions (EP5 special-case), and correctness during reset/suspend/unplugged events.
  • Build script frequency handling: Trace MEM_VARIANT_FREQ extraction through build.sh, copy-libs.sh, and copy-mem-variant.sh to ensure consistency in conditional appending and path construction for esp32s3.
  • Config namespace migration: Validate that renaming CONFIG_ESP_WIFI_* to CONFIG_WIFI_RMT_* in esp32p4 config does not reference stale config names elsewhere in codebase.

Possibly related PRs

Poem

🐰 A rabbit's ode to TinyUSB's transformation

The DWC2 controller hops to host mode now,
With FIFO counting and freq-aware build somehow,
Old device-only paths fade to yesterday,
While dual-mode configs light the modern way! 🎉

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch v5.5_120_opi

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e4fcc9d and fabbc37.

📒 Files selected for processing (17)
  • .github/workflows/parallel_build.yaml (1 hunks)
  • build.sh (2 hunks)
  • components/arduino_tinyusb/CMakeLists.txt (0 hunks)
  • components/arduino_tinyusb/include/tusb_config.h (2 hunks)
  • components/arduino_tinyusb/patches/dcd_dwc2.patch (0 hunks)
  • components/arduino_tinyusb/src/dcd_dwc2.c (0 hunks)
  • configs/builds.json (1 hunks)
  • configs/defconfig.120m (1 hunks)
  • configs/defconfig.common (2 hunks)
  • configs/defconfig.esp32p4 (2 hunks)
  • configs/defconfig.esp32s3 (1 hunks)
  • configs/defconfig.opi_ram (1 hunks)
  • patches/dwc2_esp32_h.diff (0 hunks)
  • tools/copy-libs.sh (3 hunks)
  • tools/copy-mem-variant.sh (1 hunks)
  • tools/patch-tinyusb.sh (0 hunks)
  • tools/update-components.sh (0 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Jason2866 Jason2866 merged commit 8c0b5b8 into v5.5_gcc15 Nov 11, 2025
1 check was pending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants