Skip to content

Conversation

mathieuchopstm
Copy link
Contributor

  • empty control endpoint transfer queues when SETUP is received
  • properly handle OUT control transfers with Data larger than EP0 MaxPacketSize

First commit is similar to what was introduced by #94001 - in my testing, it doesn't seem necessary, but I've included it in this patchset regardless. (I allowed myself to "cherry-pick" it as @nandojve seems unavailable)

Second commit fixes the same issue as #94001 but in a different manner that is, I believe, more solid.

Full testing TBD, but preliminary results show I have same testusb results as with #94001.

Drop all existing transfers in control endpoints' queue when a new SETUP
packet is received. Also use the appropriate net_buf API in a nearby place.

Signed-off-by: Mathieu Choplain <[email protected]>
During a Host-to-Device Control transfer, an arbitrary amount of data is
sent from Host to the Device using OUT Data packets. If the total amount of
data to transfer, communicated via the wLength field of the SETUP packet,
exceeds the EP0 MaxPacketSize, several Data packets until all data has been
transfered.

Combined with HAL behavior, the STM32 driver did not handle this situation
properly and always ended reception after a single Data packet was received
regardless of whether or not all data had actually been received from Host.

Modify driver to handle this situation properly by keeping track of how
much data has been received and restarting transfers until we have received
everything the Host promised it would send.

Signed-off-by: Mathieu Choplain <[email protected]>
Copy link

Copy link
Contributor

@etienne-lms etienne-lms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM AFAICT.

@mathieuchopstm mathieuchopstm added this to the v4.3.0 milestone Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: USB Universal Serial Bus platform: STM32 ST Micro STM32

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants