Bootloader flashing WORD using double WORD
Hi,
I want to flash my STM32L452RET6P using a .hex file. I am however struggling with the fact that STM IDE generates a .hex file with lines with only one WORD instead of the only supported double WORD when writing. So I need to buffer and assemble each double WORD from the .hex file. This involves a lot of tinkering for me, as in: how to buffer, how to know for sure we can finally write and so on. So is there any way to write only one WORD?
The HAL suggests it is possible as the write is done in two steps:
static void FLASH_Program_DoubleWord(uint32_t Address, uint64_t Data)
{
/* Check the parameters */
assert_param(IS_FLASH_PROGRAM_ADDRESS(Address));
/* Set PG bit */
SET_BIT(FLASH->CR, FLASH_CR_PG);
/* Program first word */
*(__IO uint32_t*)Address = (uint32_t)Data;
/* Barrier to ensure programming is performed in 2 steps, in right order
(independently of compiler optimization behavior) */
__ISB();
/* Program second word */
*(__IO uint32_t*)(Address+4U) = (uint32_t)(Data >> 32);
}
Another workaround could be to fix the .hex file formatting, so that each line in the .hex file is forced to contain a multiple of 8 bytes to be able to write straightaway to flash. I don't know why those weird 4 byte lines are in the file, it makes no sense to me.
Any suggestions?
My first thought was to write one word followed by 0xFFFFFFFF to be able to overwrite the second part if the .hex file contains any data for that part. But that wouldn't work if I'm right, because of how the ecc works.
