From 3aa8ac3fb9c547154430c73f68cd2a64b2ac7730 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 25 Feb 2020 17:42:07 +0100 Subject: [PATCH] Bootloader: Cleanup --- lib/dfu-bootloader.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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(); -- 2.39.5