From 363179e8373c9a05d810a15a7896385ecd3d7432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Fri, 10 Jan 2020 11:04:20 +0100 Subject: [PATCH] flash_internal: fix provided flash size detection --- lib/flash_internal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/flash_internal.c b/lib/flash_internal.c index 167dc4e..b7c12fb 100644 --- a/lib/flash_internal.c +++ b/lib/flash_internal.c @@ -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();