cancel
Showing results for 
Search instead for 
Did you mean: 

I can't use function HAL_FLASH_Program to program same memory address twice

JimEno
Associate III

When I call function HAL_FLASH_Program twice with the same Flash address, the second call is ignored. See test code below.

int8_t buffer1[16] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};

int8_t buffer2[16] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F};

EraseIntFlash( 0x08200000, 0x08300000 );

HAL_FLASH_Program(FLASH_TYPEPROGRAM_QUADWORD, 0X0820000, buffer1);

HAL_FLASH_Program(FLASH_TYPEPROGRAM_QUADWORD, 0X0820000, buffer2);

 

In Memory Browser, I expect:

0x08200000   03020100 07060504 0B0A0908 0F0E0D0C

But I get:

0x08200000   03020100 07060504 FFFFFFFF FFFFFFFF

What is going on? I really need this to work. Can anyone provide insight or solution or workaround?

Jim Eno

2 REPLIES 2

Right you get one shot per address.

The flash line contains unshown ECC bits

I think you need one larger, contiguous, buffer. Or the address needs to increase

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
KnarfB
Super User

Did you check for error codes/return values?

RM0456 Rev 3:

7.3.7 Flash main memory programming sequences
The Flash memory is programmed 137 bits at a time (128-bit data + 9 bits ECC).
Programming in a previously programmed address is not allowed except if the data to write
is full zero, and any attempt sets the PROGERR flag ...

hth

KnarfB