Commit a974f2dc authored by Damien George's avatar Damien George

stm32/flash: Fix bug computing page number for L432 page erase.

parent 3fbf32b9
......@@ -122,6 +122,12 @@ static uint32_t get_page(uint32_t addr) {
}
#endif
#elif defined(STM32L4) && !defined(SYSCFG_MEMRMP_FB_MODE)
static uint32_t get_page(uint32_t addr) {
return (addr - FLASH_BASE) / FLASH_PAGE_SIZE;
}
#endif
uint32_t flash_get_sector_info(uint32_t addr, uint32_t *start_addr, uint32_t *size) {
......@@ -167,7 +173,7 @@ void flash_erase(uint32_t flash_dest, uint32_t num_word32) {
#elif (defined(STM32L4) && !defined(SYSCFG_MEMRMP_FB_MODE))
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
EraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGES;
EraseInitStruct.Page = flash_dest;
EraseInitStruct.Page = get_page(flash_dest);
EraseInitStruct.NbPages = (4 * num_word32 + FLASH_PAGE_SIZE - 4) / FLASH_PAGE_SIZE;
#elif defined(STM32L4)
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment