cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H730VBT6 write user settings in FLASH

Baxtouxe
Associate II

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?

 

17 REPLIES 17

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Thanks for your quick reply.

Any idea where I can find a HAL H7 example to write in the Flash? 

> 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.

TDK_0-1697650036948.png

 

If you feel a post has answered your question, please click "Accept as Solution".

Might I suggest looking through the repositories locally with a file browser or manager, or on GitHub directly?

https://github.com/STMicroelectronics/STM32CubeH7/tree/master/Projects/NUCLEO-H723ZG/Examples/FLASH/FLASH_EraseProgram

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
MM..1
Chief II

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.

 

I'm trying to add this small data at the very end of the program FLASH, as far as possible from the code.

Baxtouxe
Associate II

I'm not sure which STM32 would be closest to my STM32H730VBT6 to take an example from. STM32H74x? Or STM32H735x?

If your write is only once and ontime programming , why not use stmCubeprogrammer cmdline?

I'd like to write when a specific command comes through the UART