summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
37 hoursvendor: remove the obsolete host vendor driverhathach
vendor_host.c/.h implemented a CFG_TUH_VENDOR class driver that no example, board or test ever enabled: usbh's driver table entry was compiled out everywhere, and the six tusb_config.h files that mentioned the macro all set it to 0. Maintainer call - dead code, not a shrinking of supported classes. Removes the sources, the usbh driver-table entry, the CFG_TUH_VENDOR default in tusb_option.h, the tusb.h include, both build-system source lists, the rp2040 family.cmake entry and the IAR project template rows.
3 daysMerge pull request #3833 from hathach/claude/ci-hs-set-address-orderHa Thach
dcd(ci_hs): stage the device address before priming the status stage
3 daysdcd(ci_hs): stage the device address before priming the status stagehathach
IMXRT1060RM 42.7.23 and UM10503 Table 478 both ask for the DEVICEADDR write with USBADRA=1 to happen after the SET_ADDRESS data phase and before the prime of the status stage, so the controller loads USBADR from its holding register when the status stage is ACKed. The driver did it the other way round, leaving a window between the ENDPTPRIME store and the DEVICEADDR store: an IN answered inside that window ACKs with USBADRA still 0, so the holding register is never consulted and the device keeps answering on address 0 while the host has moved to the new one. Instruction timing alone cannot open that window, but dcd_set_address() runs in task context, so any interrupt landing between the two stores stretches it past a microframe. Hardware discards a staged address on a SETUP or OUT to endpoint 0 and zeroes USBADR on a bus reset, which covers a superseded SET_ADDRESS. What it cannot cover is a SETUP latched before this write and still unconsumed after the full CI_HS_BUSY_SPIN spin, which refuses the prime: condition 2 already fired for that earlier SETUP, so the stage would survive and load USBADR on the next EP0 IN ACK of an unrelated transfer. USB 2.0 9.4.6 is explicit that "the USB device does not change its device address until after the Status stage of this request is completed successfully", so the refused-prime path restores the previous USBADR rather than leaving a stage armed. Restoring the previous value rather than writing zero keeps 9.4.6's Address-state row correct, where a device already at a non-zero address must stay there; on Linux that write is always a no-op, since hub_set_address only issues SET_ADDRESS from USB_STATE_DEFAULT. Cast dev_addr before the shift: it is uint8_t, promoted to int, so an address of 64 or more reached the sign bit of a 32-bit int. No errata applies: IMXRT1060CE_A Rev 1.3 lists only ERR050101 and ERR010661 for USB, IMXRT1060CE_B Rev 1.1 only ERR010661. Validated on mimxrt1064_evk: 18/19 device+host tests, 6x usbtest 30/30, and a 100-iteration forced re-enumeration A/B that is clean on both this change and its parent (0/100 each). All 19 ci_hs boards build; unit tests 63/63; PVS drops one diagnostic (the sign-bit shift) and adds none.
3 daysMerge pull request #3816 from Ryzee119/ohci_gtd_fixZixun LI
ohci: fix double allocation of dummy TDs in gtd_find_free
4 daysohci: defer descriptor reclaim until next frameHiFiPHile
4 daysMerge pull request #3830 from kasjer/kasjer/uac2-update-terminal-typesZixun LI
UAC2: Add more terminal types
4 daysFix audio terminal type typosHiFiPHile
4 daysexamples: document and work around the i.MX RT and LPC55 USB erratahathach
ERR050101: while an isochronous IN endpoint is active, an IN token addressed to that same endpoint number on ANOTHER device sharing the host can silently unprime one of this device's OUT endpoints - control, bulk, interrupt or isochronous alike. NXP states it cannot be detected by software and raises no interrupt, so the endpoint simply stops answering and the transfer never completes. The workaround is a uniqueness requirement rather than a particular number: the isochronous IN endpoint must not share its number with any IN endpoint in use on the bus. One family-wide constant therefore defeats it, since two affected boards on the same hub then pick the same number and each becomes the other's aggressor. CFG_TUSB_MIMXRT1XXX_ERRATA_ERR050101 is set only for the parts whose errata list it - RT1015, RT1020, RT1024 and RT1050, where it is marked no fix scheduled, plus RT1060 and RT1064 rev A - so RT1010 and the RT11xx family keep the ordinary number and cannot collide with an affected board beside them. Several affected boards on one hub can still be given distinct numbers with -DEPNUM_ISO_IN. The guard covers every example that has an isochronous IN endpoint: audio_test, audio_4_channel_mic, uac2_headset, cdc_uac2, usbtest, video_capture and video_capture_2ch. The video examples move the endpoint only when streaming isochronously, since the bulk configuration is unaffected, and video_capture_2ch takes two numbers because it has two streams. The macro name follows CFG_TUSB_RP2_ERRATA_E2/E4/E15 already in tree, and its is fixed, and which cannot be told apart at compile time - a way to define it to 0. device_issues.rst records ERR050101 against every affected part with a link to each errata sheet, and adds the LPC55S2x USB.3 speed-detection and USB.5 isochronous IN entries, neither of which TinyUSB works around. The branch's design notes are included under docs/superpowers. Verified: 340 wedge-free runs on mimxrt1064_evk, which previously wedged within hours, and the macro resolving to endpoint 0x87 on mimxrt1064_evk against 0x83 on mimxrt1010_evk and stm32f407disco.
4 daysdcd(ip3511): fix DEVCMDSTAT write-1-to-clear handling and EP0 setup raceshathach
DEVCMDSTAT mixes read/write fields with write-1-to-clear latches, so a blind read-modify-write writes a pending latch back as a one and silently clears it - a setup consumed that way strands EP0. Mask the latches on every update. The setup path follows the manual's order: acknowledge the latch, then read the payload. The EP0 IN interrupt is cleared along with EP0 OUT, as the control endpoint flowchart requires - a control IN completion latched before the setup must not reach usbd after it, where it would be applied to the request the setup just started and arm its status stage early. The payload is copied a byte at a time out of a buffer now declared volatile: the controller DMAs a new setup packet into it as soon as the latch is cleared, and C orders volatile accesses only against each other, so gcc sinks a plain memcpy below the guard read that follows at -O2 and -O3 - leaving only -Os, the level CI builds, correct.
4 daysusbd: handle a refused transfer without halting, and report ithathach
A refused transfer is a recoverable condition - a new setup superseding a control response, for instance - rather than a bug, but every failure path treated it as one. TU_ASSERT carries TU_BREAKPOINT, which is gated on a debugger being attached rather than on CFG_TUSB_DEBUG, so on a rig where a probe is always attached it halted the CPU even in release builds. Use TU_VERIFY on the control transfer paths, including the multi-packet data stage continuation, and drop the breakpoint from the endpoint transfer failure arm, which already marks the endpoint ready again so the next transfer can proceed. The result of usbd_control_xfer_cb() was separately dropped on the floor, leaving EP0 neither armed nor stalled and nothing recorded. It is logged now, and deliberately not stalled: a DCD refuses an EP0 prime when a newer setup is already latched, and EP0 stalls are cleared by hardware when that setup arrives, so a stall issued here would land after the auto-clear and stall the transfer that superseded this one. The pending setup re-drives EP0 by itself.
4 daysdcd(ci_hs): rework bus reset handling and bound the register waitshathach
A bus reset was detected only from the port change that ends it, which is late: the manual asks the DCD to clear the endpoint semaphores, cancel every prime and free the dTDs while the reset is still being driven. Enable the reset interrupt and do all of that there, in the manual's order (IMXRT1060RM 42.5.6.2.1, p.2394), including the two steps that were missing - confirming the port is still being reset, and freeing the dTDs. A failed check means the cleanup arrived late and the controller may be in an undefined state, so the manual's remedy is carried out rather than noted: a controller reset, followed by the full re-initialisation it then requires, since the reset detaches the device. The port change that ends the reset is left with what the manual gives it, the negotiated speed, which the new BUS_RESET_END event carries. A port change is classified by the interrupt that preceded it: a suspend raises no port change of its own, the resume that ends it does. Every unbounded register spin is now bounded. They waited on bits the hardware clears within a frame, but each could hang an interrupt handler outright on a controller that had stopped responding. The endpoint flush follows all three steps of IMXRT1060RM 42.5.6.6.5 (p.2413), repeating a flush the controller refuses while a packet is in progress - previously reported as success. EP0 setup handling is hardened alongside: the payload is copied out of the queue head through the volatile qualifier before ENDPTSETUPSTAT is cleared, since that clear releases the setup lockout and a back-to-back setup can overwrite the buffer immediately after, and C orders volatile accesses only against each other, so a plain memcpy may legally be sunk past the store. There is deliberately no unplug detection. IMXRT1060RM 42.7.31 (p.2470) states a zero Current Connect Status means the device "did not attach successfully or was forcibly disconnected by the software writing a zero to the Run bit ... It does not state the device being disconnected or suspended", so a cable pull raises no port change at all; VBUS via OTGSC is the manual's disconnect indicator and is board dependent. Verified on mimxrt1064_evk: 30 forced bus resets each re-enumerating at high speed with no descriptor errors, plus repeated full usbtest batteries at 30/30 across the series.
4 daysusbd: split bus reset into start/end edge eventshathach
A driver that can see reset signalling begin has no way to say so: the only event carries the negotiated speed, which does not exist until the reset ends. On ChipIdea that left the stack believing it was still configured for the whole reset window - 3 ms at minimum, tens of milliseconds in practice - while the controller had already torn its endpoints down, so a class driver writing in that window primed a disabled endpoint over a zeroed queue head. Add DCD_EVENT_BUS_RESET_START for the leading edge and rename the existing event to DCD_EVENT_BUS_RESET_END, keeping DCD_EVENT_BUS_RESET as an alias. START is optional and END stays self-sufficient, so every other driver and the unit tests are untouched.
4 daysUAC2: Add more terminal typesJerzy Kasenberg
This adds more standard terminal types that can be used in descriptors to improve end user experience when operating system can present more acurate image for audio device terminal. Signed-off-by: Jerzy Kasenberg <[email protected]>
5 daysMerge pull request #3790 from hathach/fix/lpc43-hfp-reliabilityHa Thach
Fix HFP HIL reliability issue
5 daysohci: reclaim orphaned TDs on device disconnectRyzee119
6 daysportable/chipidea: name SBUSCFG in ci_hs_regs_t, unify AHB burst hookhathach
Replace the duplicated per-MCU dispatch in dcd_init/hcd_init and the two helper flavors (USB_Type access on iMX RT, raw offset 0x90 on LPC18/43) with one SBUSCFG register field plus a per-header CI_HS_SET_AHB_BURST() hook, compiled only where defined. The LPC USB0-only policy is now visible at the macro definition.
7 daysMerge pull request #3823 from sauloverissimo/feat/midi2-fb-capsZixun LI
midi2 device: complete the UMP stream discovery responder
8 daysMerge pull request #3802 from dxbjavid/video-payload-capZixun LI
clamp committed video payload size to streaming ep buffer
8 daysPotential fix for pull request findingZixun LI
Co-authored-by: Copilot Autofix powered by AI <[email protected]> Signed-off-by: HiFiPhile <[email protected]>
8 daysfix(midi2): fix discovery response racingHiFiPhile
Signed-off-by: HiFiPhile <[email protected]>
8 daysfix(midi2): keep discovery replies valid under TX pressureSaulo Veríssimo
Text replies resume instead of dropping their tail packets, which used to leave a Start/Continue sequence without an End. A new Function Block Discovery now merges with a pending one instead of replacing it.
8 daysfeat(midi2): complete the UMP stream discovery responderSaulo Veríssimo
Adds the Device Identity Notification with an app callback, MIDI-CI version and SysEx8 stream count in FB Info, honors the Endpoint Discovery filter bitmap, and paces discovery replies by TX FIFO room.
8 daysusbtmc: document why the trigger re-arm result is ignoredice458
A false return from tud_usbtmc_start_bus_read() here does not mean arming failed: it means the endpoint is already armed, either because the application re-armed it from its trigger callback or because a transfer is still queued (usbd_edpt_xfer() reports failure when the endpoint is busy). Both cases end in STATE_IDLE, so the state cannot disambiguate them either, and stalling on the result would halt a healthy endpoint. Co-Authored-By: Claude Opus 5 <[email protected]>
8 daysusbtmc: re-arm (or stall) the bulk-OUT endpoint after a USB488 TRIGGERice458
A single USB488 TRIGGER message left the bulk-OUT endpoint un-armed, so the host's next bulk-OUT transfer timed out. The trigger itself succeeded silently, so the failure surfaced on a later, unrelated command; only a USBTMC device clear recovered it. The bundled examples/device/usbtmc reproduced this as shipped. Every other branch of the STATE_IDLE dispatch in usbtmcd_xfer_cb() leaves the endpoint in a defined state: it either transitions out of STATE_IDLE so a later tud_usbtmc_start_bus_read() can re-arm it, or it stalls and lets the CLEAR_FEATURE(ENDPOINT_HALT) handler recover it. USBTMC_MSGID_USB488_TRIGGER did neither, and because the state stayed STATE_IDLE, even an application following the contract documented in usbtmc_device.h got a silent no-op from tud_usbtmc_start_bus_read(). Transition to STATE_NAK so the re-arm can take effect, and stall the endpoint when trigger is unsupported or the application callback rejects it, matching the existing handling for messages the driver cannot process. The callback result is deliberately not wrapped in TU_VERIFY(), which would return before the stall/re-arm and reintroduce the same hang. Since the driver now re-arms after a trigger, drop tud_usbtmc_msg_trigger_cb from the list of callbacks after which the application must do so. Fixes #3821 Co-Authored-By: Claude Opus 5 <[email protected]>
10 daysusbd: clear endpoint busy/claimed when a completion event is droppedhathach
An XFER_COMPLETE dropped by a full event queue leaves its endpoint's BUSY|CLAIMED state set forever - the consumer that normally clears it never sees the event, so usbd_edpt_claim()/usbd_edpt_xfer() fail from then on and the class never re-arms the endpoint. Clear both flags when the enqueue fails: the completion is lost either way, but the endpoint stays usable. Unit test: arm a bulk endpoint, drop its completion against a full queue, verify the endpoint can be claimed and re-armed.
10 daysusbd: clear the queued-setup counter on bus resethathach
A SETUP counted before a bus reset must not be carried across it: the consumer would either skip a post-reset SETUP (count drained by the stale entry) or, if the count leaked high for any other reason, skip them all. usbd_reset() now zeroes the counter; the consumer already guards on zero, and any pre-reset SETUP still in the queue is stale by definition and correctly discarded.
10 daysusbd: don't leak the queued-setup counter when the event queue is fullhathach
A SETUP arriving while the event queue is full is silently dropped by queue_event(), but _usbd_queued_setup has already been incremented. The leaked count makes the event handler skip every subsequent SETUP ("Skipped since there is other SETUP in queue") forever: EP0 stays deaf until tud_init() while the device otherwise looks alive - enumerated, endpoints armed. Undo the increment when the enqueue fails. Unit test: fill the queue so a SETUP is dropped, then verify the next SETUP still completes a GET_DESCRIPTOR control transfer.
10 daysohci: fix double allocation of dummy TDs in gtd_find_freeRyzee119
2026-08-07Merge pull request #3761 from ↵Zixun LI
morse-cedricvandenbergh/fix/ncm-link-state-notify-retry ncm: retry link-state notification, fix carrier lost on collision
2026-08-07ncm: fix carrier lost on link-state notify collisionCedric Van den Bergh
tud_network_link_state() delivered the NETWORK_CONNECTION notification edge-triggered and fire-once: if a previous notification was still in flight, notification_xmit() returned early and the notification for the new link state was never queued. Because link_is_up is committed before the send, the host could be left reporting a stale carrier state - e.g. a permanent NO-CARRIER after a link up. The notification state was also mutated from both the caller and the notify xfer-completion callback with no serialisation, so on RTOS ports where tud_network_link_state() runs in a task other than tud_task() the two could race. Defer the whole link-state update onto the usbd task, so it can no longer race the completion callback. A collision with an in-flight notification is resolved by re-arming notification_xmit_state and letting the existing completion callback drive it forward on the next xfer completion, rather than adding a separate pending/retry flag. A link toggle does not change the link speed, so strictly only the NETWORK_CONNECTION notification needs (re)sending, but reusing the existing speed-then-connection state machine keeps the fix on a single, already-serialised code path. Closes #3760
2026-08-04audio_device: enforce the documented FIFO minimum in the EP-IN flow-control ↵rt-rtos
guard The comment above audiod_tx_packet_size() states flow control needs a FIFO of at least 4*Navg, but the guard tests nominal_size[1] <= fifo_depth * 4 - true for any FIFO larger than a quarter packet - instead of nominal_size[1] * 4 <= fifo_depth. As written, flow control engages on FIFOs far below its own documented minimum, where the depth/2 setpoint sits within one packet of empty and the packet_size = 0 branch (a zero-length packet, i.e. an audible 1 ms dropout for audio-class hosts) is reachable from ordinary scheduling jitter rather than only from gross clock deviation. With the guard corrected, undersized FIFOs fall back to the plain min(count, max) path as intended.
2026-07-30clamp committed video payload size to streaming ep bufferJavid Khan
Signed-off-by: Javid Khan <[email protected]>
2026-07-30Merge remote-tracking branch 'origin/master' into tmp/pr3790-mergehathach
2026-07-29Merge remote-tracking branch 'tinyusb/master' into fix/lpc43-hfp-reliabilityZixun LI
2026-07-29also added rp2usb_deinit() call to hcd_deinit()Geurt Vos
2026-07-29rp2xxx: added rp2usb_deinit() to fix 'No spinlocks are available'Geurt Vos
2026-07-29Merge pull request #3784 from AnthonyV-modretro/masterZixun LI
Add More HID Usage Page enums
2026-07-29Merge tinyusb/master into fix/lpc43-hfp-reliabilityZixun LI
2026-07-29class/mtp: preserve final OUT payload before ZLPZixun LI
2026-07-28portable/dwc2: rewind DMA on ISO IN retryZixun LI
2026-07-27Address Codex feedback on spellingAnthony VerBurg
2026-07-27portable/chipidea: configure i.MX RT AHB burstsZixun LI
2026-07-27portable/chipidea: configure LPC USB0 AHB burstsZixun LI
2026-07-26TU_MIN suggestionTenGui
2026-07-23save without formattingTenGui
2026-07-23also fix tusb_typesTenGui
2026-07-23fix narrowing, add castTenGui
2026-07-22Add more HID Usage Page enumsAnthony VerBurg
2026-07-21Add support for APM32F072Jie Feng
2026-07-19Merge pull request #3757 from rhgndf/at32f403a_larger_pmaZixun LI
Larger at32f403a PMA area