Skip to content

Fix USBH_MIDI_Transmit: use DMA-safe buffer and serialize transfers#698

Open
jpanneton wants to merge 1 commit intoelectro-smith:masterfrom
jpanneton:fix-usb-midi-transmit
Open

Fix USBH_MIDI_Transmit: use DMA-safe buffer and serialize transfers#698
jpanneton wants to merge 1 commit intoelectro-smith:masterfrom
jpanneton:fix-usb-midi-transmit

Conversation

@jpanneton
Copy link
Copy Markdown

The caller's buffer was passed directly to USBH_BulkSendData. On the STM32H750, this buffer may reside in DTCM or cached AXI SRAM, which are memory regions the USB OTG peripheral cannot reliably access. This caused the device to ACK but silently discard the payload, leading to OUT transfers sending corrupted data.

Additionally, rapid back-to-back calls would re-submit on the same OUT pipe before the previous transfer completed, since USBH_BulkSendData sets the URB state to URB_IDLE on submission, making it indistinguishable from "no transfer pending"

Changes to USBH_MIDI_Transmit:

  • Copy TX data into the handle's txBuffer before sending
  • Track in-flight state with a txActive flag and wait for URB_DONE from the previous transfer before submitting the next

The caller's buffer was passed directly to USBH_BulkSendData. On the
STM32H750, this buffer may reside in DTCM or cached AXI SRAM, which are
memory regions the USB OTG peripheral cannot reliably access. This caused
the device to ACK but silently discard the payload, leading to OUT
transfers sending corrupted data.

Additionally, rapid back-to-back calls would re-submit on the same OUT pipe
before the previous transfer completed, since USBH_BulkSendData sets the
URB state to URB_IDLE on submission, making it indistinguishable from
"no transfer pending"

Changes to USBH_MIDI_Transmit:
- Copy TX data into the handle's txBuffer before sending
- Track in-flight state with a txActive flag and wait for URB_DONE from
  the previous transfer before submitting the next
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.

1 participant