Skip to content

Commit ed3ad75

Browse files
warasilapmcarlescufi
authored andcommitted
drivers: flash: stm32l5_u5: fix L5/U5 difference in FLASH_PAGE_NB
In flash_stm32_page_layout, the FLASH_PAGE_NB macro is used to set the page count in the flash layout returned to the caller. On STM32L5 platforms this is defined in stm32l5xx_hal_flash.h to be (FLASH_SIZE / FLASH_PAGE_SIZE). However, on STM32U5 platforms the macro is defined in the soc headers (such as stm32u585xx.h) define the macro as (FLASH_BANK_SIZE / FLASH_PAGE_SIZE). This results in the flash layout only reflecting the first bank on STM32U5 platforms with the maximum 2 MB of flash. This commit resolves this discrepancy by directly calculating the number of pages by dividing FLASH_SIZE by FLASH_PAGE_SIZE. Tested on a proprietary board using the STM32U585 which mounts a littlefs partition in the last 256 kB of its 2 MB of flash. Signed-off-by: Peter Maxwell Warasila <madmaxwell@soundcomesout.com>
1 parent 6efc55e commit ed3ad75

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/flash/flash_stm32l5_u5.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ void flash_stm32_page_layout(const struct device *dev,
387387
if (stm32_flash_layout[0].pages_count == 0) {
388388
if ((regs->OPTR & FLASH_STM32_DBANK) == FLASH_STM32_DBANK) {
389389
/* flash with dualbank has 2k pages */
390-
stm32_flash_layout[0].pages_count = FLASH_PAGE_NB;
390+
stm32_flash_layout[0].pages_count = FLASH_SIZE / FLASH_PAGE_SIZE;
391391
stm32_flash_layout[0].pages_size = FLASH_PAGE_SIZE;
392392
#if defined(CONFIG_SOC_SERIES_STM32L5X)
393393
} else {

0 commit comments

Comments
 (0)