]> mj.ucw.cz Git - home-hw.git/commitdiff
Bootloader: Cleanup
authorMartin Mares <mj@ucw.cz>
Tue, 25 Feb 2020 16:42:07 +0000 (17:42 +0100)
committerMartin Mares <mj@ucw.cz>
Tue, 25 Feb 2020 16:42:07 +0000 (17:42 +0100)
lib/dfu-bootloader.c

index f768b40a079cef5ad8aeeb0317b012a6095e60bd..f40676c925c52d23f98549aa6cb5a41c19bf43a8 100644 (file)
@@ -136,8 +136,10 @@ static void dfu_getstatus_complete(usbd_device *usbd_dev UNUSED, struct usb_setu
 {
        switch (dfu_state) {
        case STATE_DFU_DNBUSY:
-               if (prog.blocknum == 0)
+               if (prog.blocknum == 0) {
+                       // The "flash in progress" word is programmed as 0xffff first and reset later
                        *(u16*)(prog.buf + HDR_FLASH_IN_PROGRESS) = 0xffff;
+               }
                flash_unlock();
                u32 baseaddr = BOOTLOADER_APP_START + prog.blocknum * dfu_function.wTransferSize;
                DEBUG("DFU: Block %u -> %08x + %u\n", prog.blocknum, (uint) baseaddr, prog.len);
@@ -150,8 +152,7 @@ static void dfu_getstatus_complete(usbd_device *usbd_dev UNUSED, struct usb_setu
                dfu_state = STATE_DFU_DNLOAD_IDLE;
                return;
        case STATE_DFU_MANIFEST:
-               // At the very end, program the first page
-               // FIXME
+               // At the very end, re-flash the "flash in progress" word
                flash_unlock();
                flash_program_half_word(BOOTLOADER_APP_START + 0x20, 0);
                flash_lock();