cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_FLASH_Program does not support programming bank 2

dcooperch
Associate II

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?

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

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

 

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

2 REPLIES 2
TDK
Guru

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

 

If you feel a post has answered your question, please click "Accept as Solution".

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!