2025-12-04 1:19 PM
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
2025-12-04 1:37 PM
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
2025-12-04 1:38 PM - edited 2025-12-04 1:39 PM
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