From: Martin Mares Date: Tue, 25 Feb 2020 16:42:07 +0000 (+0100) Subject: Bootloader: Cleanup X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=3aa8ac3fb9c547154430c73f68cd2a64b2ac7730;p=home-hw.git Bootloader: Cleanup --- diff --git a/lib/dfu-bootloader.c b/lib/dfu-bootloader.c index f768b40..f40676c 100644 --- a/lib/dfu-bootloader.c +++ b/lib/dfu-bootloader.c @@ -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();