Skip to content

refactor(usb): dynamic endpoint descriptor generation#5405

Open
digitalentity wants to merge 2 commits into
tinygo-org:devfrom
helvionics:de_usb_endpoint_remap
Open

refactor(usb): dynamic endpoint descriptor generation#5405
digitalentity wants to merge 2 commits into
tinygo-org:devfrom
helvionics:de_usb_endpoint_remap

Conversation

@digitalentity
Copy link
Copy Markdown

Replace static endpoint variables with EndpointIN and EndpointOUT functions.
Change the CDC, CDCHID and CDCMSC descriptors to fit into 4 endpoints.
This is a pre-requisite for supporting USB on STM32 which has only 4 EPs in hardware.

@digitalentity
Copy link
Copy Markdown
Author

@deadprogram please have a look

Replace static endpoint variables with EndpointIN and EndpointOUT
functions. Allows flexible endpoint remapping across USB configs.
@deadprogram
Copy link
Copy Markdown
Member

@digitalentity please note test failure.

@deadprogram
Copy link
Copy Markdown
Member

@digitalentity that was fast! 😸

@digitalentity
Copy link
Copy Markdown
Author

@deadprogram @sago35 I've tested this on a tiny2350, seems to work.

@deadprogram
Copy link
Copy Markdown
Member

Can some others please test out on various USB devices with your own projects e.g. TinyGo Keeb etc? I just want to make sure this does not cause any unexpected issues, or at least that people know about it.

@sago35
Copy link
Copy Markdown
Member

sago35 commented May 29, 2026

I’ll check on Monday or Tuesday.

@sago35
Copy link
Copy Markdown
Member

sago35 commented Jun 4, 2026

I'll look into it now.

@sago35
Copy link
Copy Markdown
Member

sago35 commented Jun 4, 2026

I am checking this with the RP2040. I found that it is more complex than I expected. Currently, USB CDC works fine because it uses endpoints 1 to 3 in a unidirectional manner rather than bidirectional.

However, when trying to use USB HID, Endpoint 1 and Endpoint 2 need to be configured as bidirectional. The current machine_rp2_usb.go implementation does not support this.

This issue likely occurs on the ATSAMD and nRF52840 as well. I need to investigate a bit further.

For now, I will focus on getting it to work on the RP2040 first.

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.

3 participants