From ed3ceec56f45e45aabfd1c084135fd51df6ac8fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Redon?= Date: Tue, 3 Dec 2019 15:29:33 +0100 Subject: [PATCH] DFU: increase USB reset duration to 50 ms the specification requires a reset duration of at least 10 ms. reset is indicated by the device to the host by removing the pull-up on D+ (host to device reset is a USB packet). we used 20 ms, but on some setups (USB host, stack, hub, and load dependent), this does not seem to be enough (no USB enumeration was performed afterward, at least for the DFU bootloader). increasing to 50 ms solved the issue on the affected setups. instead of USB suspend, the more proper USB disconnect is used. this mainly disables the pull-up provided by the USB peripheral. USB activate is not required since the follow up initialisation takes care of it. Change-Id: If5ceb3b8f7a8f134d4439fdd138dd12b46589f97 --- firmware/apps/dfu/main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/firmware/apps/dfu/main.c b/firmware/apps/dfu/main.c index 97cd074d..36f80a8b 100644 --- a/firmware/apps/dfu/main.c +++ b/firmware/apps/dfu/main.c @@ -300,17 +300,16 @@ extern int main(void) TRACE_INFO("USB init...\n\r"); /* Signal USB reset by disabling the pull-up on USB D+ for at least 10 ms */ + USBD_Disconnect(); #ifdef PIN_USB_PULLUP const Pin usb_dp_pullup = PIN_USB_PULLUP; PIO_Configure(&usb_dp_pullup, 1); PIO_Set(&usb_dp_pullup); #endif - USBD_HAL_Suspend(); - mdelay(20); + mdelay(50); #ifdef PIN_USB_PULLUP PIO_Clear(&usb_dp_pullup); #endif - USBD_HAL_Activate(); USBDFU_Initialize(&dfu_descriptors);