2021-08-28 04:05 AM
I am trying to make UART boot loader and programming via Teraterm by sending HEX file.
some hex records have only 4 bytes. how to program only one word.
Reference manual RM0454 page no. 59 says only double word can be programmed.
How to program single word only ?
can I skip writing one word by modifying the below function ? in stm32g0xx_hal_flash.c
Sample Hex records
:1000000000900020690C0008C10B0008C70B000815
:100B60000000000000000000000000000000000085
:0C0B700000000000000000000000000079
:040B7C00E10000088C
:040B8000B9000008B0
:100B84001E00000064000000D007000064000000A4
/**
* @brief Program double-word (64-bit) at a specified address.
* @param Address Specifies the address to be programmed.
* @param Data Specifies the data to be programmed.
* @retval None
*/
static void FLASH_Program_DoubleWord(uint32_t Address, uint64_t Data)
{
/* Set PG bit */
SET_BIT(FLASH->CR, FLASH_CR_PG);
/* Program first word */
*(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 */
*(uint32_t *)(Address + 4U) = (uint32_t)(Data >> 32U);
}
Solved! Go to Solution.
2021-08-28 10:54 AM
> Reference manual RM0454 page no. 59 says only double word can be programmed.
> How to program single word only ?
You can only program double words, per the RM. You'll need to pad the value with 0xFF or 0x00 or whatever you want.
The Flash memory is programmed 72 bits (64-bit data plus 8-bit ECC) at a time.
Programming a previously programmed address with a non-zero data is not allowed. Any such attempt sets PROGERR flag of the FLASH status register (FLASH_SR).
It is only possible to program a double word (2 x 32-bit data).
2021-08-28 10:54 AM
> Reference manual RM0454 page no. 59 says only double word can be programmed.
> How to program single word only ?
You can only program double words, per the RM. You'll need to pad the value with 0xFF or 0x00 or whatever you want.
The Flash memory is programmed 72 bits (64-bit data plus 8-bit ECC) at a time.
Programming a previously programmed address with a non-zero data is not allowed. Any such attempt sets PROGERR flag of the FLASH status register (FLASH_SR).
It is only possible to program a double word (2 x 32-bit data).
2021-08-28 03:08 PM
Thank You.