2024-03-18 04:47 AM
Hello,
Can I only write to the flash with 64 bit variables, or also 32/16/8 bit?
I just used this function for this: HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, activepageaddress + u32_Offset, u64_Data)
I have an STM32L432 uC.
I already found this example: https://github.com/STMicroelectronics/STM32CubeL4/blob/master/Projects/NUCLEO-L4P5ZG/Examples/FLASH/FLASH_FastProgram/Src/main.c
Many thanks in advance.
Solved! Go to Solution.
2024-03-18 05:02 AM
Hello @Martin42
Flash programming is only by 64-bits at a time. On other series it can be 32-bits.
For more details refer to this post.
Best Reagrds.
STTwo-32
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-03-18 05:02 AM
Hello @Martin42
Flash programming is only by 64-bits at a time. On other series it can be 32-bits.
For more details refer to this post.
Best Reagrds.
STTwo-32
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-03-18 05:52 AM
You'd use a structure (packed?) or array to consolidate the smaller variables into a larger / usable block that fits the minimum write width of the FLASH memory. You'd then write as a block.
2024-03-18 06:56 AM - edited 2024-03-18 06:58 AM
I would like to write a second firmware via Modbus and delete areas in the flash.
I send the raw HEX file using a PC tool and then write 64 bits at a time, since the flash only allows access with 64 bits.
To build the HEX file I use the addition "--gap-fill 0x00 --pad-to 0x08019000" to always get addresses with 32 bytes. This should also ensure that 64 bits are always written.
e.g. arm-atollic-eabi-objcopy.exe -O ihex --gap-fill 0x00 --pad-to 0x08019000 "${BuildArtifactFileBaseName}.elf" "${BuildArtifactFileBaseName}.hex"
-> Adds ":04018C00000000006F" the missing values for to fill 64 bit
:1001600059C0000859C0000859C00008000000002C
:1001700059C0000859C0000800000000000000003D
:0C01800059C0000859C0000859C0000810
:04018C00000000006F
:1001900010B5054C237833B9044B13B10448AFF3C1
:1001A00000800123237010BD1C010020000000000E
2024-03-18 07:20 AM
Not sure if there was a question there.
Either normalize the data on the host. Or as you process it on the target
2024-03-18 08:05 AM
No question :)
I will do it on the target.