From 0a1d25d27a50fca95305c7d3ee3bdcfec8dbdae1 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Mon, 4 Oct 2021 16:42:36 -0400 Subject: [PATCH] Sansa E200v1 Bootloader ensure USB unplug is detected Change-Id: Ibec5bf5e0f7a518fafc7b9fb8b95d420ef4ddfc0 --- bootloader/main-pp.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bootloader/main-pp.c b/bootloader/main-pp.c index d1b45dfb66..15f6ad4fb7 100644 --- a/bootloader/main-pp.c +++ b/bootloader/main-pp.c @@ -234,7 +234,18 @@ static int handle_usb(int connect_timeout) usb = USB_HANDLED; usb_acknowledge(SYS_USB_CONNECTED_ACK); +#if defined(SANSA_E200) && defined(HAVE_BOOTLOADER_USB_MODE) + /* E200 misses unplug randomly + probably fine for other targets too but needs tested */ + while (usb_wait_for_disconnect_w_tmo(&q, HZ * 5) > 0) + { + /* timeout */ + if (!usb_plugged()) + break; + } +#else usb_wait_for_disconnect(&q); +#endif break; }