summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHiFiPhile <[email protected]>2025-11-26 23:06:15 +0100
committerHiFiPhile <[email protected]>2025-11-26 23:06:15 +0100
commitc05d809e3eb9364e4db9f9997dc51dde169ed2c5 (patch)
treebbdabe5b7cc4e5744a5b40e5a52d83b7ca7ad21f /src
parentc785469881199b92b5ee8739d56ffe5aebcb6804 (diff)
usbh: Stop enumeration gracefully if EP0 can't be open
Signed-off-by: HiFiPhile <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/host/usbh.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/host/usbh.c b/src/host/usbh.c
index 734024771..5fea5fa9f 100644
--- a/src/host/usbh.c
+++ b/src/host/usbh.c
@@ -1575,7 +1575,11 @@ static void process_enumeration(tuh_xfer_t* xfer) {
// TODO probably doesn't need to open/close each enumeration
uint8_t const addr0 = 0;
- TU_ASSERT(usbh_edpt_control_open(addr0, 8),);
+ if (!usbh_edpt_control_open(addr0, 8)) {
+ // Stop enumeration gracefully
+ enum_full_complete(false);
+ TU_ASSERT(false,);
+ }
// Get first 8 bytes of device descriptor for control endpoint size
TU_LOG_USBH("Get 8 byte of Device Descriptor\r\n");
@@ -1613,7 +1617,12 @@ static void process_enumeration(tuh_xfer_t* xfer) {
usbh_device_close(dev0_bus->rhport, 0); // close dev0
- TU_ASSERT(usbh_edpt_control_open(new_addr, new_dev->bMaxPacketSize0),); // open new control endpoint
+ if (!usbh_edpt_control_open(new_addr, new_dev->bMaxPacketSize0)) { // open new control endpoint
+ // Stop enumeration gracefully
+ clear_device(new_dev);
+ enum_full_complete(false);
+ TU_ASSERT(false,);
+ }
TU_LOG_USBH("Get Device Descriptor\r\n");
TU_ASSERT(tuh_descriptor_get_device(new_addr, _usbh_epbuf.ctrl, sizeof(tusb_desc_device_t),