{
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);
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();