Skip to content

Commit c8c3a2f

Browse files
committed
dfu: support "detach"
When in DFU mode, the only way to exit was via a download operation. "dfu-util -e" to request a detach was simply not supported, so the bootloader simply remains sitting there Handle detach via reboot, the usb layer will re-enumerate if it can, and will boot app/bl based on it's own decisions. Signed-off-by: Karl Palsson <karlp@tweak.net.au>
1 parent a89c83f commit c8c3a2f

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/dfu.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <stdlib.h>
2020
#include <string.h>
2121

22+
#include <libopencm3/cm3/scb.h>
2223
#include <libopencm3/cm3/vector.h>
2324
#include <libopencm3/usb/usbd.h>
2425
#include <libopencm3/usb/dfu.h>
@@ -294,6 +295,11 @@ static int dfu_control_class_request(usbd_device *usbd_dev,
294295
}
295296
#endif
296297
case DFU_DETACH:
298+
/* Best we can do! */
299+
scb_reset_system();
300+
status = USBD_REQ_HANDLED;
301+
break;
302+
297303
default: {
298304
/* Stall the control pipe */
299305
dfu_set_status(DFU_STATUS_ERR_STALLEDPKT);

0 commit comments

Comments
 (0)