Fix optiboot erase function after address 0xFFFF

This commit is contained in:
Alex Voinea 2019-12-08 08:43:43 +02:00
parent 15bfb7013d
commit 89dfb00b04
No known key found for this signature in database
GPG Key ID: F5034E7CFCF2F973

View File

@ -258,11 +258,11 @@ void optiboot_w25x20cl_enter()
uint32_t addr = (((uint32_t)rampz) << 16) | address;
// During a single bootloader run, only erase a 64kB block once.
// An 8bit bitmask 'pages_erased' covers 512kB of FLASH memory.
if (address == 0 && (pages_erased & (1 << addr)) == 0) {
if ((address == 0) && (pages_erased & (1 << (addr >> 16))) == 0) {
w25x20cl_wait_busy();
w25x20cl_enable_wr();
w25x20cl_block64_erase(addr);
pages_erased |= (1 << addr);
pages_erased |= (1 << (addr >> 16));
}
w25x20cl_wait_busy();
w25x20cl_enable_wr();