wch/usbfs host: default endpoint table leaves a hubless device 3 data endpoints (was 4)

Open Beginner friendly
#4,596 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
64/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c
Domain
embedded-iot

Research direction

Start at src/portable/wch/usbfs/hcd_wch_usbfs.c: the macro around lines 55-57 sizes the endpoint table, while lines 148-149 reserve ep[0] for address 0 and give the addressed EP0 its own record. Read how hcd_edpt_open() (around line 762) indexes that table, then compare with the old hcd_ch32_usbfs.c usb_edpt_list[CFG_TUH_DEVICE_MAX*6], which left four data endpoints. Done means the default hubless config admits EP0 plus four data endpoints, or the reduced default is documented.

Written by the indexing model from the issue text.

Description

follow-up Port WCH USBFS Prio 📌

With the default config (CFG_TUH_DEVICE_MAX 1, CFG_TUH_HUB 0), CFG_TUH_WCH_USBFS_ENDPOINT_MAX is 5 (https://github.com/hathach/tinyusb/blob/490eb4ec9/src/portable/wch/usbfs/hcd_wch_usbfs.c#L55-L57). ep[0] is reserved for address 0 and the addressed EP0 takes one record (:148-149), so one hubless device gets 3 data endpoints and hcd_edpt_open() fails on the 4th (:762). The old hcd_ch32_usbfs.c (usb_edpt_list[CFG_TUH_DEVICE_MAX*6], 53c1d1473) left 4.

Found syncing 490eb4ec9 into adafruit/Adafruit_TinyUSB_Arduino#642 (review comment by CodeRabbit), verified in source.

Trigger: default config, no hub, a device with 4 data endpoints (e.g. CDC-ACM with 3 plus a HID IN): the last interface's endpoint fails to open. Overriding the macro works around it.

Introduced by: a76e22cbc ("endpoint table sized by device count").

Remaining work: size per device as 1 (EP0) + 4 data endpoints, matching the comment "control plus about three endpoints" and the old driver's capacity, or document the reduced default.

Why deferred: found on the downstream sync PR, which carries upstream bytes only. Not reproduced on hardware.

Dominant language
C
Stars
7.3k
Forks
1.6k
Avg merge
1d 19h
Merged PRs (30d)
67

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from hathach/tinyusb

All issues in hathach/tinyusb

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.