Skip to content

Bump tinyusb to include MAX3421E host startup-hang fix (#3748)#11093

Open
mikeysklar wants to merge 4 commits into
adafruit:mainfrom
mikeysklar:tinyusb-oscok-bump
Open

Bump tinyusb to include MAX3421E host startup-hang fix (#3748)#11093
mikeysklar wants to merge 4 commits into
adafruit:mainfrom
mikeysklar:tinyusb-oscok-bump

Conversation

@mikeysklar

Copy link
Copy Markdown
Collaborator

Advances lib/tinyusb from the October 2025 commit to current master so hathach/tinyusb#3748 (MAX3421E USB-host startup-hang fix) is available to build and test, per #10053.

c1bf19ed6 (0.18.0-748) → fcd5a0603 (0.21.0-31). API drift adapted:

  • XFER_RESULT_ABORTED enum → shared-module/usb/core/Device.c
  • usbd_control.c merged into usbd.csupervisor/supervisor.mk
  • TUD_AUDIO_EP_SIZE gained is_highspeed arg → tusb_config.h
  • CFG_TUD_CDC_EP_BUFSIZECFG_TUD_CDC_RX_EPSIZEusb_device.c

Tested: builds clean on adafruit_feather_esp32_v2 (espressif) and feather_m4_express (atmel-samd).

Known blocker — needs @FoamyGuy: nordic doesn't build yet. The same bump reorganized the USB Audio Class descriptor macros (TUD_AUDIO_DESC_*TUD_AUDIO10_/AUDIO20_DESC_*), and shared-module/usb_audio/usb_audio_descriptors.h still uses the old names. That migration is UAC 1.0/2.0-sensitive and wants USB-audio hardware to verify, so it's left for the module owner. (Verified there's no earlier bump point that includes #3748 without this reorg.)

@mikeysklar

mikeysklar commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator Author

@dhalbert -

Flashed and tested USB-host drive detection (MAX3421E FeatherWing, hot-plug SanDisk/PNY/USB-storage) on real hardware with this bump:

Board Firmware Result
Feather ESP32 V2 official CI artifact (this PR) ✅ enumerates 0781:cfcb SanDisk + 154b:005b PNY across hot-swap
Feather RP2350 local build ✅ enumerates SanDisk + PNY
Feather M4 Express local build ✅ boots (device-only; MAX3421E overflows the 512 KB flash by ~11.7 KB, so no host)
Feather nRF52840 Sense local build ✅ enumerates USB-storage + PNY

espressif and atmel-samd build clean in CI as-is.

The RP2350 and nRF52 images above are local builds with CIRCUITPY_USB_AUDIO=0 disabled.

shared-module/usb_audio/usb_audio_descriptors.h still uses under the old names. These seem to be in the process of being migrated those to the TUD_AUDIO20_DESC_* family is the (cc @FoamyGuy). #11058 and #11062

nRF52 needed one more one-liner to build: tinyusb's dcd_nrf5x.c calls nrf_clock_is_running(), but CircuitPython pins nrfx v2.0.0 which only has nrf_clock_hf_is_running(NRF_CLOCK, …). Patched that one call locally to verify the hardware; the proper fix is bumping ports/nordic/nrfx (or upstream tinyusb supporting nrfx v2.0.0).

Neither the audio-disable nor the clock patch is included in this PR.

platform-testing

proof of life

hw-verify-repl-log.txt

@dhalbert

dhalbert commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

@hathach We could use hathach/tinyusb#3748, but we are well behind in circuitpython as you can see above. @mikeysklar has made good progress. Do you have any recommendations or review comments? Thanks.

@hathach

hathach commented Jul 6, 2026

Copy link
Copy Markdown
Member

all changes look good, except the audio since we don't want to haardcode it with FS. Audio HS/FS has different way of calculating timing/samples. It is updated to not hardcored since even with highspeed capable device e.g imxrt, when plugging to FS host, still need to functio as FS audio. However, since cpy mostly work with PC, we can just use the TUD_OPT_HIGH_SPEED.

Advance lib/tinyusb c1bf19ed6 -> fcd5a0603 to pull in hathach/tinyusb#3748
(adafruit#10053), and adapt to its API drift: XFER_RESULT_ABORTED
enum, usbd_control.c merged into usbd.c, TUD_AUDIO_EP_SIZE is_highspeed arg, and
CFG_TUD_CDC_EP_BUFSIZE -> RX_EPSIZE. Builds clean on espressif and atmel-samd;
nordic still needs a usb_audio descriptor macro migration (see PR).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mikeysklar mikeysklar force-pushed the tinyusb-oscok-bump branch from dd830f1 to 894397c Compare July 6, 2026 13:51
@mikeysklar

mikeysklar commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @hathach!

Updated: both TUD_AUDIO_EP_SIZE(...) calls in supervisor/shared/usb/tusb_config.h to now pass TUD_OPT_HIGH_SPEED instead of a hardcoded false

The audio path can't be fully CI-compiled here yet.

  • the bump also reorganized the UAC descriptor macros (TUD_AUDIO_DESC_*TUD_AUDIO20_DESC_*) and shared-module/usb_audio/usb_audio_descriptors.h

  • still uses the old names, so CIRCUITPY_USB_AUDIO boards (nordic, rp2) need that descriptor migration before this compiles clean.

cc @FoamyGuy (#11058 / #11062)

mikeysklar and others added 3 commits July 9, 2026 12:51
The tinyusb bump splits the flat UAC descriptor API into version-namespaced
UAC 1.0 and UAC 2.0 variants, so shared-module/usb_audio, which targets
UAC 2.0, no longer compiles against the old names. Three layers moved:

  descriptor macros  TUD_AUDIO_DESC_IAD    -> TUD_AUDIO20_DESC_IAD
  enum constants     AUDIO_CTRL_RW         -> AUDIO20_CTRL_RW
  C types            audio_control_cur_1_t -> audio20_control_cur_1_t

AUDIO_TERM_TYPE_* is shared between UAC 1.0 and 2.0 upstream and keeps its
old name.

Two of the renames are not a literal insertion of "20":

  TUD_AUDIO_DESC_STD_AS_INT_LEN -> TUD_AUDIO20_DESC_STD_AS_LEN
      the length macro drops _INT; the emitter keeps it.

  TUD_AUDIO_DESC_FEATURE_UNIT_ONE_CHANNEL(unitid, srcid, ch0, ch1, stridx)
      -> TUD_AUDIO20_DESC_FEATURE_UNIT(unitid, srcid, stridx, ch0, ch1)
      ONE/TWO_CHANNEL collapse into one varargs macro: stridx moves from
      last to third and the per-channel controls become trailing varargs.
      The paired length macro becomes TUD_AUDIO20_DESC_FEATURE_UNIT_LEN(1),
      still 14 bytes, so the *_DESC_LEN totals are unchanged.

Verified by emitting the speaker/headset/mic descriptors before and after
(old source + old tinyusb vs new source + new tinyusb) and diffing the
bytes: identical at 132/230/132. Clean builds of adafruit_feather_rp2350
and feather_bluefruit_sense, both with CIRCUITPY_USB_AUDIO=1.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The tinyusb bump splits the STM32 fsdev driver: fsdev_core_reset,
pma_align_buffer_size and btable_set_rx_bufsize moved out of
dcd_stm32_fsdev.c into a new fsdev_common.c. Add it to SRC_C, mirroring
the dwc2 / dwc2_common.c pattern just below.

Only STM32L433xx boards take the fsdev path, so blues_cygnet was the sole
board failing to link on the three symbols above. It now builds clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The tinyusb bump grows the binary and this board was already at 100.0% of
FLASH_FIRMWARE, so it overflowed by 232 bytes. It never opted into
usb_audio; it inherited CIRCUITPY_USB_AUDIO=1 from the rp2 port default.
Turning it off frees ~9kB.

usb_audio is the USB Audio Class device (enumerating to a host as a mic or
speaker). The board's own audio path is the I2S DAC on GPIO26/27/28 driven
by audiobusio.I2SOut, which is unaffected, as are audiocore, audiomixer,
audiomp3, audiopwmio and synthio.

The non-W pimoroni_pico_dv_base has more headroom and keeps usb_audio.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mikeysklar

Copy link
Copy Markdown
Collaborator Author

3 commits pushed. CI green except nordic.

80d6cae usb_audio → TUD_AUDIO20_* / AUDIO20_* (@FoamyGuy OK'd on Discord)

  • bigger than a macro rename — 3 layers moved: macros, 23 enums, 7 C types
  • AUDIO_TERM_TYPE_* is shared across UAC 1.0/2.0, keeps its name
  • FEATURE_UNIT ONE/TWO_CHANNEL → varargs TUD_AUDIO20_DESC_FEATURE_UNIT(unitid, srcid, stridx, ...)
  • descriptor bytes diffed before/after: identical (132/230/132). No HW test yet.

d4d5ad3 stm: build fsdev_common.c for STM32L433xx

  • bump split the fsdev driver; 3 symbols moved to a new file
  • mirrors the existing dwc2_common.c pattern. blues_cygnet links.

6c8a542 pimoroni_pico_dv_base_w: disable usb_audio

  • bigger tinyusb → 232 bytes over flash; board was already at 100.0% on main
  • usb_audio = USB Audio device class, not the board's I2S line-out/HDMI audio — audiobusio.I2SOut, audiocore, synthio untouched
  • board never opted in; inherited the rp2 port default. Frees ~9kB. Non-W sibling keeps it.

Remaining: 51 nordic + the windows job (same nordic build). Not caused by this PR.

@relic-se#11102 will need a rebase after this. FEATURE_UNIT_TWO_CHANNEL becomes the same varargs macro with one extra control arg; the AUDIO_* enums and audio_*_t types need the 20 too.

@FoamyGuy — the bump deletes CFG_TUD_AUDIO_FUNC_1_DESC_LEN and _N_AS_INT (the driver walks the descriptor itself now). Both are still defined in tusb_config.h, now dead, and the comment atop usb_audio_descriptors.h is stale. usb_audio_descriptor_length() is still needed by usb_desc.c. Left as-is — clean up here, or fold into the stereo work?

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.

3 participants