Browse Source

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.
blockKey
Jacob Alexander 7 years ago
parent
commit
77218a641b
1 changed files with 13 additions and 4 deletions
  1. 13
    4
      Bootloader/dfu.c

+ 13
- 4
Bootloader/dfu.c View File

@@ -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: