summaryrefslogtreecommitdiff
path: root/src/class/mtp
AgeCommit message (Collapse)Author
14 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-29class/mtp: preserve final OUT payload before ZLPZixun LI
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-03refactor(cmake): comment out unused target folder propertieshathach
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-04-17remove duplicated tu_le16toh since we have converted the endian when setup.Fan DANG
2026-03-27fix string overflowHiFiPhile
Signed-off-by: HiFiPhile <[email protected]>
2026-03-25mtp: fix adding empty cstring to mtp_container_infostepan chepushtanov
2026-02-07minor updatehathach
2026-01-13minor clean uphathach
separate tud_mtp_data_send() and tud_mtp_data_receive()
2025-12-29device/mtp: improve loggingHiFiPhile
Signed-off-by: HiFiPhile <[email protected]>
2025-12-28device/mtp: queue ZLP when neededHiFiPhile
Signed-off-by: HiFiPhile <[email protected]>
2025-12-10Fix MTP transfer completion detection for exact-length packetscopilot-swe-agent[bot]
Change condition from `>` to `>=` to properly detect completion when xferred_len equals total_len. This fixes the bug where transfers of exactly bulk_mps length (e.g., 64 bytes for low speed) would never complete, such as GetHandles responses with 12 elements. Co-authored-by: hathach <[email protected]>
2025-11-11Merge remote-tracking branch 'tinyusb/master' into ↵HiFiPhile
copilot/fix-dcd-edpt-xfer-issue Signed-off-by: HiFiPhile <[email protected]>
2025-11-05added .clang-formathathach
fix more alerts disable IAR CStat since pvs-studio check is better integrated with clion
2025-10-22Fix copilot issuesMengsk
Signed-off-by: Mengsk <[email protected]>
2025-10-22Add is_isr parameter to usbd_edpt_xfer and usbd_edpt_xfer_fifocopilot-swe-agent[bot]
- Added bool is_isr parameter to usbd_edpt_xfer() and usbd_edpt_xfer_fifo() wrapper functions - These are called by class drivers to queue USB transfers - Updated all callers to pass false by default (non-ISR context) - Updated audiod_rx_xfer_isr() and audiod_tx_xfer_isr() to pass true (ISR context) - All 21 unit tests pass Co-authored-by: HiFiPhile <[email protected]>
2025-10-08fix incorrect MTP xact_len calculationRigoLigo
2025-10-01minor updatehathach
2025-09-29refactor mtp examples, add phase and session id to callback datahathach
2025-09-27make command container more consistenthathach
2025-09-27add edpt claim for public APIhathach
2025-09-27implement serial for MTPhathach
2025-09-27implement control requesthathach
2025-09-26implement tud_mtp_mounted() and tud_mtp_event_send()hathach
refactor phase state
2025-09-26fix more ci buildhathach
2025-09-26fix compile warningshathach
2025-09-25clean up, wrap up bulk command supportedhathach
2025-09-25implement send object command, able to create new filehathach
2025-09-25implement MTP_OP_SEND_OBJECT_INFO, refactor fs examplehathach
2025-09-24clean uphathach
2025-09-24unify callback argument. support multiple packet get objecthathach
2025-09-23refactor APIhathach
2025-09-23try to add logo png to mtp examplehathach
2025-09-22implement get object, close sessionhathach
2025-09-21implement get object infohathach
2025-09-21implement get objection handleshathach
2025-09-20implement get device properties describer and device properties valuehathach
2025-09-20implement get device properties valuehathach
2025-09-19rework get storageIDs and get storage infohathach
2025-09-19rework get storageIDs and get storage infohathach
2025-09-19reworking MTP API, adding callback, getting GetDeviceInfo workinghathach
2025-09-16remove mtp contexthathach
2025-09-16refactor mtp xfer callbackhathach
2025-09-16refactor generic container to use EPBUF declarationhathach
simplify container field name
2025-09-16merge context into interface and refactor, reformathathach
2025-09-12add all constant from MTP specs appendix, rename some e.g OPEC to OP, EVTC ↵hathach
to EVENT
2025-08-06Add MTP class deviceMaurizio Pesce