2023-10-18 08:37 AM
I couldn’t figure out how to write a simple code to write some bytes at the end of the Flash on my STM32H7. I don’t need much bytes, only one uint32_t.
I tried using HAL_FLASH_Program by unlocking the flash first but couldn’t make it work..
Any help?
2023-10-18 08:47 AM
Problems here are there's only one flash sector (128KB), you can only write once per erase cycle, the flash line is 256-bits wide (32-bytes), so you're probably going to want a section toward the end, and journal your writes such that you can write sequential words, and recover the settings from the last set.
The HAL H7 libraries should have examples of writing to FLASH, use those as the basis for your code.
2023-10-18 08:52 AM
Thanks for your quick reply.
Any idea where I can find a HAL H7 example to write in the Flash?
2023-10-18 10:27 AM
> Any idea where I can find a HAL H7 example to write in the Flash?
Use the Example Selector in CubeMX to find and run relevant examples.
2023-10-18 10:57 AM - edited 2023-10-18 10:57 AM
Might I suggest looking through the repositories locally with a file browser or manager, or on GitHub directly?
2023-10-18 12:39 PM
You choice MCU not optimized for this. You dont specify where is your code flashing placed ? External QSPI?
Optimal simple way is use external I2C EEPROM, but if you strict require write, your flash is with CRC and can write only once into 32 bounded bytes area. And when is flash full of additional flashing , you need reflash full sw.
2023-10-19 12:40 AM
I'm trying to add this small data at the very end of the program FLASH, as far as possible from the code.
2023-10-19 01:25 AM
I'm not sure which STM32 would be closest to my STM32H730VBT6 to take an example from. STM32H74x? Or STM32H735x?
2023-10-19 05:18 AM
If your write is only once and ontime programming , why not use stmCubeprogrammer cmdline?
2023-10-19 05:28 AM
I'd like to write when a specific command comes through the UART