summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2021-09-25 18:37:24 +0700
committerGitHub <[email protected]>2021-09-25 18:37:24 +0700
commit958cf2cfbaf1ddb67f31ff5920630304189d7c0c (patch)
tree22b2ff1c38aacc7190ae342499eaf35bdac75c44 /src
parent45ae409e3f7340450ce892abe7f976c3a2d61d71 (diff)
parentc62c1433e7d35ee18d97a7c76a4de91aa66a9486 (diff)
Merge pull request #1102 from kasjer/kasjer/usbd-small-ep0-enumeration-workaround
usbd: Workaround for non standard device descriptor request
Diffstat (limited to 'src')
-rw-r--r--src/device/usbd.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/device/usbd.c b/src/device/usbd.c
index 3043fc7bc..cf3ecea42 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -971,9 +971,11 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
uint16_t len = sizeof(tusb_desc_device_t);
- // Only send up to EP0 Packet Size if not addressed
+ // Only send up to EP0 Packet Size if not addressed and host requested more data
+ // that device descriptor has.
// This only happens with the very first get device descriptor and EP0 size = 8 or 16.
- if ((CFG_TUD_ENDPOINT0_SIZE < sizeof(tusb_desc_device_t)) && !_usbd_dev.addressed)
+ if ((CFG_TUD_ENDPOINT0_SIZE < sizeof(tusb_desc_device_t)) && !_usbd_dev.addressed &&
+ ((tusb_control_request_t*) p_request)->wLength > sizeof(tusb_desc_device_t))
{
len = CFG_TUD_ENDPOINT0_SIZE;