Skip to content

Commit cfbccbd

Browse files
committed
Fix eeprom build issue
Signed-off-by: Frederic Pillon <[email protected]>
1 parent f50b69a commit cfbccbd

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

cores/arduino/stm32/stm32_eeprom.c

+9-5
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,15 @@
8484
#elif defined (STM32L0xx)
8585
#define FLASH_BASE_ADDRESS ((uint32_t)(DATA_EEPROM_BASE)) /* 0x08080000 */
8686
#elif defined (STM32L4xx)
87-
// Flash base address (Bank2, page 256)
88-
#define FLASH_BASE_ADDRESS 0x080FF800
89-
#define FLASH_PAGE_NUMBER 255
87+
#ifndef FLASH_BANK_2
88+
#define FLASH_BANK_NUMBER FLASH_BANK_1
89+
#else
90+
#define FLASH_BANK_NUMBER FLASH_BANK_2
91+
#endif // FLASH_BANK_2
92+
// Flash base address
93+
#define FLASH_PAGE_NUMBER ((uint32_t)((FLASH_SIZE/FLASH_PAGE_SIZE) -1))
94+
#define FLASH_BASE_ADDRESS ((uint32_t)(0x08000000 + (FLASH_PAGE_NUMBER*FLASH_PAGE_SIZE)))
9095
#endif
91-
9296
/**
9397
* @}
9498
*/
@@ -176,7 +180,7 @@ void set_data_to_flash(void)
176180
// ERASING page
177181
EraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGES;
178182
#ifdef STM32L4xx
179-
EraseInitStruct.Banks = FLASH_BANK_2;
183+
EraseInitStruct.Banks = FLASH_BANK_NUMBER;
180184
EraseInitStruct.Page = FLASH_PAGE_NUMBER;
181185
#else // STM32F4xx
182186
EraseInitStruct.PageAddress = FLASH_BASE_ADDRESS;

0 commit comments

Comments
 (0)