From 757128f54b4eebfd0cba705e76bcc8c70b87ec66 Mon Sep 17 00:00:00 2001 From: Catherine Date: Wed, 20 Sep 2023 15:33:04 +0000 Subject: [PATCH] firmware: fix issue #382 (-88 bytes XRAM). The issue #382 (failure of the device to enumerate when plugged into a Windows machine for the first time) was caused by the lack of handling of a Windows-specific descriptor. Respond to a request for this descriptor. Co-authored-by: Maya Co-authored-by: Charlotte --- firmware/main.c | 28 +++++++++++++++++++--------- vendor/libfx2 | 2 +- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/firmware/main.c b/firmware/main.c index 997ef7743..17bda99d8 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -187,6 +187,13 @@ usb_desc_ms_ext_compat_id_c usb_ms_ext_compat_id = { } }; +usb_desc_ms_ext_property_c usb_ms_ext_properties = { + .dwLength = sizeof(struct usb_desc_ms_ext_property), + .bcdVersion = 0x0100, + .wIndex = USB_DESC_MS_EXTENDED_PROPERTIES, + .wCount = 0, +}; + void handle_usb_get_descriptor(enum usb_descriptor type, uint8_t index) { if(type == USB_DESC_STRING && index == 0xEE) { xmemcpy(scratch, (__xdata void *)&usb_microsoft, usb_microsoft.bLength); @@ -792,18 +799,21 @@ void handle_pending_usb_setup() { // Microsoft descriptor requests if(req->bmRequestType == (USB_RECIP_DEVICE|USB_TYPE_VENDOR|USB_DIR_IN) && - req->bRequest == USB_REQ_GET_MS_DESCRIPTOR) { - enum usb_descriptor_microsoft arg_desc = req->wIndex; + req->bRequest == USB_REQ_GET_MS_DESCRIPTOR && + req->wIndex == USB_DESC_MS_EXTENDED_COMPAT_ID) { pending_setup = false; - switch(arg_desc) { - case USB_DESC_MS_EXTENDED_COMPAT_ID: - xmemcpy(scratch, (__xdata void *)&usb_ms_ext_compat_id, usb_ms_ext_compat_id.dwLength); - SETUP_EP0_IN_DESC(scratch); - return; - } + xmemcpy(scratch, (__xdata void *)&usb_ms_ext_compat_id, usb_ms_ext_compat_id.dwLength); + SETUP_EP0_IN_DESC(scratch); + return; + } + if(req->bmRequestType == (USB_RECIP_IFACE|USB_TYPE_VENDOR|USB_DIR_IN) && + req->bRequest == USB_REQ_GET_MS_DESCRIPTOR && + req->wIndex == USB_DESC_MS_EXTENDED_PROPERTIES) { + pending_setup = false; - STALL_EP0(); + xmemcpy(scratch, (__xdata void *)&usb_ms_ext_properties, usb_ms_ext_properties.dwLength); + SETUP_EP0_IN_DESC(scratch); return; } diff --git a/vendor/libfx2 b/vendor/libfx2 index 7454158f2..73fa81181 160000 --- a/vendor/libfx2 +++ b/vendor/libfx2 @@ -1 +1 @@ -Subproject commit 7454158f2c0328c1054111156807a2324c8ebd85 +Subproject commit 73fa811818d56a86b82c12e07327946aeddd2b3e