Skip to content

Commit

Permalink
stm32/flash: Fix bug computing page number for L432 page erase.
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgeorge committed May 2, 2019
1 parent 3fbf32b commit a974f2d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ports/stm32/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a974f2d

Please sign in to comment.