summaryrefslogtreecommitdiff
path: root/src/class
AgeCommit message (Collapse)Author
5 daysclass/mtp: correct data phase completion and transaction recoveryhathach
The data-out phase ended before its terminating ZLP and before the application had seen the final payload, and several transaction states had no way back to idle. Reworked as one state machine: - Add MTP_PHASE_DATA_COMPLETE, entered once the data phase has fully finished - for an exact buffer-multiple data-out, only after the host's terminating ZLP - and deliver tud_mtp_data_complete_cb() from there. tud_mtp_response_send() now refuses while the phase is still MTP_PHASE_DATA: ep_out still owes the host a read at that point and re-arming it for a new command would race that read. - Arm the terminating-ZLP read before handing the final payload to the application, as the IN path already does. The 0-length read passes a NULL buffer so the payload is untouched, and claiming ep_out first means a late tud_mtp_data_receive() fails its own claim instead of breaking the driver's next step. - Honor the documented negative return of tud_mtp_data_xfer_cb() and tud_mtp_data_complete_cb() by entering MTP_PHASE_ERROR, which stalls both endpoints. This is the application's way out of a data phase now that a response cannot be sent from one. Their weak stubs return 0 so an application that does not implement them is unaffected. - Take total_len from the container header the host sends on the first OUT packet. The application can only set it up front when it knows the size (SendObject); SendObjectInfo cannot, so total_len kept the 12-byte header default and the phase ended on the first packet. - Reject a runt or misdirected container in both the command and data phases: a short packet was matched against stale buffer contents, and the failed TU_VERIFY left ep_out neither armed nor stalled. The first data-out packet previously underflowed payload_bytes instead. - Restore the previous phase when tud_mtp_data_send()/_receive() cannot claim their endpoint, so the application's fallback response is not refused by a phase the driver never actually entered. - Re-arm ep_out after MTP_REQ_CANCEL of a data phase, and defer the new-command read when ep_out is still busy with the ZLP read of an abandoned transaction: usbd_edpt_xfer() asserts on a busy endpoint, so MTP_REQ_RESET could not recover. The MTP example follows the same contract: a handler error raised mid data phase (fs_send_object_info validates the received ObjectInfo, so STORE_FULL and INVALID_PARENT_OBJECT can only be raised there) is kept and answered from tud_mtp_data_complete_cb() once the phase completes.
2026-07-29Merge remote-tracking branch 'tinyusb/master' into fix/lpc43-hfp-reliabilityZixun LI
2026-07-29class/mtp: preserve final OUT payload before ZLPZixun LI
2026-07-27Address Codex feedback on spellingAnthony VerBurg
2026-07-22Add more HID Usage Page enumsAnthony VerBurg
2026-07-19Merge pull request #3750 from dxbjavid/cdc-acm-open-desc-boundsZixun LI
bound cdc-data endpoints against descriptor length in acm_open
2026-07-19add interface desc length checkHiFiPhile
Signed-off-by: HiFiPhile <[email protected]>
2026-07-19improve validation structureHiFiPhile
Signed-off-by: HiFiPhile <[email protected]>
2026-07-19improve pointer arithmetic, check funmctional descriptor bLengthHiFiPhile
Signed-off-by: HiFiPhile <[email protected]>
2026-07-17vendor: deactivate de-selected altsetting's isochronous endpointshathach
vendord_set_alt() aborted bulk/interrupt endpoints of the outgoing altsetting (stall/clear-stall) but only dropped the iso endpoints' tracking: an armed iso transfer stayed live in the dcd with its usbd claim held and no tracked handle to stop it, and its completion fired into an endpoint the class no longer recognizes. Reachable through the usbtest example's alt0 (bulk) <-> alt1 (iso) SET_INTERFACE switching. Track each selected iso endpoint's descriptor (points into the app's static descriptor set) and deactivate on de-selection: with the iso-alloc API re-activation is the abort/scrub primitive (resets ep_status, aborts the stale transfer); without it usbd_edpt_close does, and the next selection re-opens. Iso cannot be stalled like bulk/interrupt, hence the separate path. Build-verified: usbtest for stm32f072disco, ra4m1_ek, raspberry_pi_pico (iso-alloc) and ch32v307v_r1_1v0 (close API).
2026-07-09audio: drop stale EP-busy note in audiod_set_interfacehathach
Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HeF2gZ1M7GWkz6Av4BpKPg
2026-07-09class/vendor: add interrupt/iso endpoint pairs and alt-setting supporthathach
Non-buffered per-type source/sink endpoints (bulk/int/iso) with manual RX arming across altsettings. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HeF2gZ1M7GWkz6Av4BpKPg
2026-07-07gate acm_open descriptor bounds behind CFG_TUH_VALIDATION_LEVELJavid Khan
add a three-level TUSB_VALIDATION_NONE/BASIC/STRICT knob and default CFG_TUH_VALIDATION_LEVEL to BASIC, then make acm_open the first user so the enumeration bounds checks compile out at NONE for trusted-device setups and stay on by default.
2026-07-05bound rndis data packet offset in handle_incoming_packetJavid Khan
Signed-off-by: Javid Khan <[email protected]>
2026-07-05Merge pull request #3738 from sauloverissimo/fix/midi2-fb-directionZixun LI
feat(midi2): derive function blocks from the GTB descriptor
2026-07-05ensure gtb is validHiFiPhile
Signed-off-by: HiFiPhile <[email protected]>
2026-07-05Merge pull request #3754 from Old-Ding/codex/usbtmc-status-byte-bufferZixun LI
Fix USBTMC status byte interrupt buffer
2026-07-05Merge pull request #3741 from dxbjavid/ncm-ndp-length-boundZixun LI
bound ndp16 wLength against received ntb in recv_validate_datagram
2026-07-05Fix USBTMC status byte notification bufferaineoae86-sys
Queue the USB488 READ_STATUS_BYTE interrupt notification through tud_usbtmc_transmit_notification_data so it uses the class notification endpoint buffer for the asynchronous transfer. Fixes #2928 Generated-by: OpenAI Codex Signed-off-by: aineoae86-sys <[email protected]>
2026-07-05bound acm_open functional descriptor walk against desc_endJavid Khan
2026-07-05fix sizeof(nth16_t) typoHiFiPhile
Signed-off-by: HiFiPhile <[email protected]>
2026-07-05Fix USBTMC notification endpoint claimaineoae86-sys
Use usbd_edpt_claim() before queuing USBTMC notification data so the interrupt endpoint is reserved through the normal endpoint ownership path. Release the claim if the notification payload cannot be copied before the transfer is queued. Fixes #2735 Generated-by: OpenAI Codex Signed-off-by: aineoae86-sys <[email protected]>
2026-07-04advance acm_open descriptor walk by fixed struct sizesJavid Khan
2026-07-03guard acm_open endpoint reads against short bLength descriptorsJavid Khan
2026-07-03Merge pull request #3660 from andrewleech/cdch-on-enum-idx-guardZixun LI
cdc_host: fix undeclared 'idx' when only LINE_CONTROL_ON_ENUM is defined
2026-07-02bound cdc-data endpoints against descriptor length in acm_openJavid Khan
2026-07-02license: use SPDX identifiers for src/ headers (#3749)Ha Thach
* license: use SPDX identifiers for src/ headers Replace the full ~20-line MIT license boilerplate on every src/ file with a two-line SPDX tag (SPDX-FileCopyrightText + SPDX-License-Identifier), following the REUSE convention used by CircuitPython and the Linux kernel. Removes ~3500 lines of duplicated boilerplate.
2026-06-28feat(midi2): derive function blocks from the GTB descriptorSaulo Veríssimo
Function Block Info (direction, group span, name) is derived from the GTB descriptor as the single source of truth, so a device can expose multiple Group Terminal Blocks with independent directions. Adds Function Block Name notifications (tud_midi2_fb_name_cb) and an opt-in callback to answer UMP Stream messages from the application (tud_midi2_stream_msg_cb). Ref #3571
2026-06-27bound ndp16 wLength against received ntb in recv_validate_datagramJavid Khan
2026-06-24cap tud_msc_scsi_cb bufsize to endpoint buffer sizedxbjavid
2026-06-23Merge pull request #3698 from dxbjavid/hid-report-desc-boundsZixun LI
bound item size to remaining length in hid report descriptor parser
2026-06-19video: assert usbd_edpt_iso_activate() result in _open_vs_itf()hathach
The isochronous streaming endpoint was activated with the usbd_edpt_iso_activate() return value ignored, unlike every neighbouring open in the same function (usbd_edpt_open() is wrapped in TU_ASSERT on both the non-ISO-alloc fallback and the bulk branch). When a DCD refuses the iso endpoint -- e.g. it has no isochronous support, or the requested packet size does not fit its endpoint buffers -- that failure was silently swallowed and the alternate setting was reported as opened, leaving the host streaming to an endpoint the device never armed. Wrap it in TU_ASSERT so the open fails cleanly and the refusal propagates, matching the adjacent endpoint-open calls. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-19Merge pull request #3709 from morse-cedricvandenbergh/ncm-default-link-state-cbZixun LI
ncm: add weak callback for initial link state
2026-06-18class/audio: remove unused audio20_control_request_thathach
After the UAC2 examples switched to tusb_control_request_t with TU_U16_HIGH/LOW() extraction, audio20_control_request_t is no longer referenced anywhere in the tree. It is a byte-overlay of the setup packet whose bChannelNumber/bControlSelector/bInterface/bEntityID sub-byte fields silently misread on big-endian once wValue/wIndex are converted to host order (tu_le16toh in dcd.h), so leaving it in the public header is a latent BE trap; the BE bitfield guard previously added to its bmRequestType_bit only masked that by guarding byte 0. Drop the struct entirely. Callers should use tusb_control_request_t and TU_U16_LOW/HIGH(wValue|wIndex), matching audio_device.c and the examples. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-18Merge remote-tracking branch 'origin/master' into pr-3618hathach
2026-06-16ncm: add weak callback for initial link stateCedric Van den Bergh
netd_init resets link_is_up to a compile-time default, which is incorrect when the host reboots without power-cycling the device. Add tud_network_default_link_state_cb() so applications can return the actual physical link state. The weak default preserves existing CFG_TUD_NCM_DEFAULT_LINK_UP behaviour.
2026-06-15zero-extend usage page before copying shorter payloaddxbjavid
2026-06-12bound item size to remaining length in hid report descriptor parserdxbjavid
2026-06-06host/cdc: use local control bufferHiFiPhile
2026-06-03refactor(cmake): comment out unused target folder propertieshathach
2026-05-31cdc_host: fix undeclared 'idx' when only LINE_CONTROL_ON_ENUM definedAndrew Leech
idx is used in the ENUM_SET_LINE_CONTROL path guarded by CFG_TUH_CDC_LINE_CONTROL_ON_ENUM, but was declared only under CFG_TUH_CDC_LINE_CODING_ON_ENUM. Defining LINE_CONTROL_ON_ENUM without LINE_CODING_ON_ENUM therefore failed to compile with an undeclared identifier. Guard the declaration under either macro. Signed-off-by: Andrew Leech <[email protected]>
2026-05-30Merge pull request #3658 from wjklimek1/mtp-out-transfer-fixZixun LI
Fix premature MTP phase change after short MTP OUT transfer
2026-05-29Handle OUT transfer completion in MTPWojciech Klimek
Handle OUT transfer differently from IN to not prematurely change MTP phase when host sends short packet that is not end of MTP data phase. Only reaching container length or ZLP should change phase.
2026-05-25chore: resolve .gitignore merge conflict with mastercopilot-swe-agent[bot]
Co-authored-by: HiFiPhile <[email protected]>
2026-05-19midi2_host: convert TX to raw FIFO mirroring midi2_device refactorSaulo Veríssimo
2026-05-18midi2: convert to raw Tx FIFO for better segmentation handling, add count to ↵HiFiPhile
packet api Signed-off-by: HiFiPhile <[email protected]>
2026-05-18midi2: boundary-aware drain in xfer_cb to keep UMP packets intactSaulo Veríssimo
2026-05-17midi2: drain pattern for RX FIFOSaulo Veríssimo
Default RX/TX buffers to EPSIZE for both device and host. Document drain-in-loop on ump_read; example device callback drains until empty.
2026-05-17midi2: scale device buffers with EPSIZESaulo Veríssimo
Match midi2_host pattern. Literal 256 underran HS endpoints (512B).
2026-05-17midi2: per-interface weak callbacks for UMP Stream configSaulo Veríssimo
Lets each instance return different NUM_GROUPS, NUM_FUNCTION_BLOCKS, EP_NAME and PRODUCT_ID. Defaults fall back to the macros.