|
|
@ -13,7 +13,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
// see docs/memory.md for more information
|
|
|
|
// see docs/memory.md for more information
|
|
|
|
|
|
|
|
|
|
|
|
const uint32_t FLASH_SECTOR_TABLE[FLASH_SECTOR_COUNT + 1] = {
|
|
|
|
static const uint32_t FLASH_SECTOR_TABLE[FLASH_SECTOR_COUNT + 1] = {
|
|
|
|
[ 0] = 0x08000000, // - 0x08003FFF | 16 KiB
|
|
|
|
[ 0] = 0x08000000, // - 0x08003FFF | 16 KiB
|
|
|
|
[ 1] = 0x08004000, // - 0x08007FFF | 16 KiB
|
|
|
|
[ 1] = 0x08004000, // - 0x08007FFF | 16 KiB
|
|
|
|
[ 2] = 0x08008000, // - 0x0800BFFF | 16 KiB
|
|
|
|
[ 2] = 0x08008000, // - 0x0800BFFF | 16 KiB
|
|
|
@ -66,7 +66,7 @@ const void *flash_get_address(uint8_t sector, uint32_t offset, uint32_t size)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
uint32_t addr = FLASH_SECTOR_TABLE[sector];
|
|
|
|
uint32_t addr = FLASH_SECTOR_TABLE[sector];
|
|
|
|
uint32_t next = FLASH_SECTOR_TABLE[sector + 1];
|
|
|
|
uint32_t next = FLASH_SECTOR_TABLE[sector + 1];
|
|
|
|
if (offset + size > next - addr) {
|
|
|
|
if (addr + offset + size > next) {
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (const uint8_t *)addr + offset;
|
|
|
|
return (const uint8_t *)addr + offset;
|
|
|
@ -92,7 +92,7 @@ secbool flash_erase_sectors(const uint8_t *sectors, int len, void (*progress)(in
|
|
|
|
return secfalse;
|
|
|
|
return secfalse;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// check whether the sector was really deleted (contains only 0xFF)
|
|
|
|
// check whether the sector was really deleted (contains only 0xFF)
|
|
|
|
uint32_t addr_start = FLASH_SECTOR_TABLE[sectors[i]], addr_end = FLASH_SECTOR_TABLE[sectors[i] + 1];
|
|
|
|
const uint32_t addr_start = FLASH_SECTOR_TABLE[sectors[i]], addr_end = FLASH_SECTOR_TABLE[sectors[i] + 1];
|
|
|
|
for (uint32_t addr = addr_start; addr < addr_end; addr += 4) {
|
|
|
|
for (uint32_t addr = addr_start; addr < addr_end; addr += 4) {
|
|
|
|
if (*((const uint32_t *)addr) != 0xFFFFFFFF) {
|
|
|
|
if (*((const uint32_t *)addr) != 0xFFFFFFFF) {
|
|
|
|
flash_lock();
|
|
|
|
flash_lock();
|
|
|
@ -135,7 +135,7 @@ secbool flash_read_word_rel(uint8_t sector, uint32_t offset, uint32_t *data)
|
|
|
|
if (offset % 4 != 0) {
|
|
|
|
if (offset % 4 != 0) {
|
|
|
|
return secfalse;
|
|
|
|
return secfalse;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*data = *((uint32_t *) FLASH_SECTOR_TABLE[sector] + offset);
|
|
|
|
*data = *((const uint32_t *)FLASH_SECTOR_TABLE[sector] + offset);
|
|
|
|
return sectrue;
|
|
|
|
return sectrue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|