Skip to main content
Explorer II
May 7, 2025
Solved

HAL_FLASH_Program does not support programming bank 2

  • May 7, 2025
  • 1 reply
  • 362 views

When trying to program the STM32L4P5RE, I get an assertion failure when trying to program the second bank like this:

HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, address, data)

This call fails if my address is in the second bank `0x08080000`.  Looking at the source code, I get an assertion failure here: 

static void FLASH_Program_DoubleWord(uint32_t Address, uint64_t Data)
{
/* Check the parameters */
assert_param(IS_FLASH_PROGRAM_ADDRESS(Address)); <---- HERE

I understand when DBANK (Or DB1M) is set, we cannot read the other bank.  So how are we supposed to actually program it?

    This topic has been closed for replies.
    Best answer by TDK

    The chip has 512 kB of flash, so 0x08080000 is outside of those bounds, regardless of how DB1M is set.

    Second bank of flash starts at 0x08040000.

    TDK_0-1746631245436.png

     

    1 reply

    TDKAnswer
    Super User
    May 7, 2025

    The chip has 512 kB of flash, so 0x08080000 is outside of those bounds, regardless of how DB1M is set.

    Second bank of flash starts at 0x08040000.

    TDK_0-1746631245436.png

     

    dcooperchAuthor
    Explorer II
    May 7, 2025

    Wow, I can't believe I missed that.  I've been relying on the value of the linker script from STM32CubeMX: 

    FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K <----

    But now I realize that linker script is generic: `STM32L4P5XX_FLASH.ld`.  That was a little misleading.  Thank you for the help!