cancel
Showing results for 
Search instead for 
Did you mean: 

How to program internal flash memory of STM32H753 Controller

Kavana shree
Associate II

I am having problem with writing program to internal flash memory. How to read from flash and write to flash? ​How to compare flash contents with uint8_t array contents? How to write uint8_t array contents to flash memory ? Please help

6 REPLIES 6

Should be FLASH examples in HAL source trees. Review and adapt those. Will have expectation of wide aligned writes. Writing or Erasing internal flash is slow, it will stall the processor in most situations, and break real-time operation. Code can be run from RAM to avoid some issues but is more complicated and involved.

FLASH memory is within the micro-controllers memory map, you can read it the same as any other directly attached memory space.

Try memcmp() ?

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

memcmp worked for me. But I have problem in writing to flash. Whatever I write was not updating and even it gets updated it would be different than the expected. I am not able to understand properly. I am writing uint8_t array to flash address. In example code the array content had data type of uint64_t. Is this making any difference? Should I type cast?

The flash lines are wider and contain ECC/Hamming type bits. Not designed for byte wide writing, and would be highly inefficient.

You can cast a byte array into a 64-bit word array, but the memory must be aligned otherwise you'll get faults. You also need to round up the byte count to a multiple of 8 to ensure all data is committed.

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

Do you use the HAL functions for writing to Flash, i.e. to unlock FLASH memory?

Yes. I am using Unlock_Flash and then write and lock again.

Every time I write into flash I should erase whole sector and write into blocks right?​

Can anyone share me the clock configuration for USB MSC in HS mode?

Does writing multiple blocks improve speed over writing single block? If yes how to write multiple blocks?​