From 77218a641bc866daf30ef5e16d00e832bfcfaca7 Mon Sep 17 00:00:00 2001 From: Jacob Alexander Date: Sun, 24 Jul 2016 15:48:30 -0700 Subject: [PATCH] Fixing dfu-util warning due to improper protocol state sequence Fixes this warning message: dfu-util: unable to read DFU status after completion Results in: Download done. state(7) = dfuMANIFEST, status(0) = No error condition is present state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present Done! Functionally no different, just a better user experience. --- Bootloader/dfu.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Bootloader/dfu.c b/Bootloader/dfu.c index cfc99d7..3ff83dc 100644 --- a/Bootloader/dfu.c +++ b/Bootloader/dfu.c @@ -185,10 +185,18 @@ static int dfu_handle_control( struct usb_ctrl_req_t *req, void *data ) * and reset the system to put the new firmware into * effect. */ - usb_ep0_tx_cp(&st, sizeof(st), req->wLength, NULL, NULL); - if (ctx->state == DFU_STATE_dfuMANIFEST) { + usb_ep0_tx_cp( &st, sizeof(st), req->wLength, NULL, NULL ); + switch ( ctx->state ) + { + case DFU_STATE_dfuMANIFEST: + ctx->state = DFU_STATE_dfuMANIFEST_WAIT_RESET; + break; + case DFU_STATE_dfuMANIFEST_WAIT_RESET: + ctx->state = DFU_STATE_dfuIDLE; usb_handle_control_status_cb(dfu_reset_system); goto out_no_status; + default: + break; } break; } @@ -198,11 +206,12 @@ static int dfu_handle_control( struct usb_ctrl_req_t *req, void *data ) break; case USB_CTRL_REQ_DFU_GETSTATE: { uint8_t st = ctx->state; - usb_ep0_tx_cp(&st, sizeof(st), req->wLength, NULL, NULL); + usb_ep0_tx_cp( &st, sizeof(st), req->wLength, NULL, NULL ); break; } case USB_CTRL_REQ_DFU_ABORT: - switch (ctx->state) { + switch ( ctx->state ) + { case DFU_STATE_dfuIDLE: case DFU_STATE_dfuDNLOAD_IDLE: case DFU_STATE_dfuUPLOAD_IDLE: