Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix(eeprom): ensure to have the correct FLASH_END
FLASH_END which is defined in CMSIS file doesn't take
into account the real flash size of a the device,
(it is just the maximum possible within the productline).

Fixes stm32duino#1316, fixes stm32duino#1500

Signed-off-by: Frederic Pillon <[email protected]>
  • Loading branch information
fpistm committed Sep 21, 2021
commit 5c111915f9a74f7d53c34f82135ed4dcc7fb759a
22 changes: 2 additions & 20 deletions libraries/EEPROM/src/utility/stm32_eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,6 @@ extern "C" {
#define FLASH_PAGE_NUMBER ((uint32_t)(((LL_GetFlashSize() * 1024) / FLASH_PAGE_SIZE) - 1))
#endif /* !FLASH_PAGE_NUMBER */

/* Be able to change FLASH_END to use */
#if !defined(FLASH_END)
#if defined(EEPROM_RETRAM_MODE)
#define FLASH_END ((uint32_t)(EEPROM_RETRAM_START_ADDRESS + EEPROM_RETRAM_MODE_SIZE -1))
#elif defined(DATA_EEPROM_END)
#define FLASH_END DATA_EEPROM_END
#elif defined (FLASH_BANK2_END) && (FLASH_BANK_NUMBER == FLASH_BANK_2)
#define FLASH_END FLASH_BANK2_END
#elif defined (FLASH_BANK1_END) && (FLASH_BANK_NUMBER == FLASH_BANK_1)
#define FLASH_END FLASH_BANK1_END
#elif defined(FLASH_BASE) && defined(FLASH_PAGE_NUMBER) && defined (FLASH_PAGE_SIZE)
/* If FLASH_PAGE_NUMBER is defined by user, this is not really end of the flash */
#define FLASH_END ((uint32_t)(FLASH_BASE + (((FLASH_PAGE_NUMBER +1) * FLASH_PAGE_SIZE))-1))
#endif
#ifndef FLASH_END
#error "FLASH_END could not be defined"
#endif
#endif /* FLASH_END */

/* Be able to change FLASH_BASE_ADDRESS to use */
#ifndef FLASH_BASE_ADDRESS
/*
Expand All @@ -81,7 +62,8 @@ extern "C" {
#if defined(EEPROM_RETRAM_MODE)
#define FLASH_BASE_ADDRESS EEPROM_RETRAM_START_ADDRESS
#else
#define FLASH_BASE_ADDRESS ((uint32_t)((FLASH_END + 1) - FLASH_PAGE_SIZE))
/* If FLASH_PAGE_NUMBER is defined by user, this is not really end of the flash */
#define FLASH_BASE_ADDRESS ((uint32_t)(FLASH_BASE + (FLASH_PAGE_NUMBER * FLASH_PAGE_SIZE)))
#endif
#ifndef FLASH_BASE_ADDRESS
#error "FLASH_BASE_ADDRESS could not be defined"
Expand Down