flash_internal: fix provided flash size detection

This commit is contained in:
King Kévin 2020-01-10 11:04:20 +01:00
parent ac1485004e
commit 2520df3e72
1 changed files with 2 additions and 2 deletions

View File

@ -51,7 +51,7 @@ static bool flash_internal_range(uint32_t address, size_t size)
if (address < FLASH_BASE) { // start address is before the start of the internal flash
return false;
}
if ((uint32_t)&__flash_end >= FLASH_BASE) { // check if the end for the internal flash is enforce by the linker script
if ((uint32_t)&__flash_end >= FLASH_BASE) { // check if the end for the internal flash is enforced by the linker script
if ((address + size) > (uint32_t)&__flash_end) { // end address is after the end of the enforced internal flash
return false;
}
@ -231,7 +231,7 @@ void flash_internal_eeprom_setup(uint16_t pages)
flash_internal_eeprom_pages = pages; // just need to remember the number of pages
// get allocated memory address
if ((uint32_t)&__flash_end > (FLASH_BASE + DESIG_FLASH_SIZE * 1024)) { // user specified larger flash than advertised by chip
if ((uint32_t)&__flash_end >= FLASH_BASE) { // check if the end for the internal flash is enforced by the linker script
flash_internal_eeprom_start = (uint32_t)&__flash_end - flash_internal_eeprom_pages * flash_internal_page_size();
} else {
flash_internal_eeprom_start = (FLASH_BASE + DESIG_FLASH_SIZE * 1024) - flash_internal_eeprom_pages * flash_internal_page_size();