diff --git a/lib/usb_dfu.c b/lib/usb_dfu.c index 1357d5f..754d85a 100644 --- a/lib/usb_dfu.c +++ b/lib/usb_dfu.c @@ -157,7 +157,7 @@ static void usb_dfu_flash(usbd_device *usbd_dev, struct usb_setup_data *req) (void)usbd_dev; // variable not used (void)req; // variable not used led_off(); // indicate we are processing - if (0 != flash_internal_write(flash_pointer, download_data, download_length, true)) { // write downloaded data + if (flash_internal_write(flash_pointer, download_data, download_length, true) >= download_length) { // write downloaded data flash_pointer += download_length; // go to next segment usb_dfu_state = STATE_DFU_DNLOAD_IDLE; // go back to idle stat to wait for next segment } else { // warn about writing error