Skip to content

Commit 5c11191

Browse files
committed
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]>
1 parent 6dec3b6 commit 5c11191

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

Diff for: libraries/EEPROM/src/utility/stm32_eeprom.c

+2-20
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,6 @@ extern "C" {
5252
#define FLASH_PAGE_NUMBER ((uint32_t)(((LL_GetFlashSize() * 1024) / FLASH_PAGE_SIZE) - 1))
5353
#endif /* !FLASH_PAGE_NUMBER */
5454

55-
/* Be able to change FLASH_END to use */
56-
#if !defined(FLASH_END)
57-
#if defined(EEPROM_RETRAM_MODE)
58-
#define FLASH_END ((uint32_t)(EEPROM_RETRAM_START_ADDRESS + EEPROM_RETRAM_MODE_SIZE -1))
59-
#elif defined(DATA_EEPROM_END)
60-
#define FLASH_END DATA_EEPROM_END
61-
#elif defined (FLASH_BANK2_END) && (FLASH_BANK_NUMBER == FLASH_BANK_2)
62-
#define FLASH_END FLASH_BANK2_END
63-
#elif defined (FLASH_BANK1_END) && (FLASH_BANK_NUMBER == FLASH_BANK_1)
64-
#define FLASH_END FLASH_BANK1_END
65-
#elif defined(FLASH_BASE) && defined(FLASH_PAGE_NUMBER) && defined (FLASH_PAGE_SIZE)
66-
/* If FLASH_PAGE_NUMBER is defined by user, this is not really end of the flash */
67-
#define FLASH_END ((uint32_t)(FLASH_BASE + (((FLASH_PAGE_NUMBER +1) * FLASH_PAGE_SIZE))-1))
68-
#endif
69-
#ifndef FLASH_END
70-
#error "FLASH_END could not be defined"
71-
#endif
72-
#endif /* FLASH_END */
73-
7455
/* Be able to change FLASH_BASE_ADDRESS to use */
7556
#ifndef FLASH_BASE_ADDRESS
7657
/*
@@ -81,7 +62,8 @@ extern "C" {
8162
#if defined(EEPROM_RETRAM_MODE)
8263
#define FLASH_BASE_ADDRESS EEPROM_RETRAM_START_ADDRESS
8364
#else
84-
#define FLASH_BASE_ADDRESS ((uint32_t)((FLASH_END + 1) - FLASH_PAGE_SIZE))
65+
/* If FLASH_PAGE_NUMBER is defined by user, this is not really end of the flash */
66+
#define FLASH_BASE_ADDRESS ((uint32_t)(FLASH_BASE + (FLASH_PAGE_NUMBER * FLASH_PAGE_SIZE)))
8567
#endif
8668
#ifndef FLASH_BASE_ADDRESS
8769
#error "FLASH_BASE_ADDRESS could not be defined"

0 commit comments

Comments
 (0)