flash_internal: fix provided flash size detection
This commit is contained in:
parent
ecac618d67
commit
363179e837
|
@ -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
|
if (address < FLASH_BASE) { // start address is before the start of the internal flash
|
||||||
return false;
|
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
|
if ((address + size) > (uint32_t)&__flash_end) { // end address is after the end of the enforced internal flash
|
||||||
return false;
|
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
|
flash_internal_eeprom_pages = pages; // just need to remember the number of pages
|
||||||
|
|
||||||
// get allocated memory address
|
// 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();
|
flash_internal_eeprom_start = (uint32_t)&__flash_end - flash_internal_eeprom_pages * flash_internal_page_size();
|
||||||
} else {
|
} else {
|
||||||
flash_internal_eeprom_start = (FLASH_BASE + DESIG_FLASH_SIZE * 1024) - flash_internal_eeprom_pages * flash_internal_page_size();
|
flash_internal_eeprom_start = (FLASH_BASE + DESIG_FLASH_SIZE * 1024) - flash_internal_eeprom_pages * flash_internal_page_size();
|
||||||
|
|
Loading…
Reference in New Issue