Skip to main content
Kavana shree
Associate III
December 21, 2018
Question

How to program internal flash memory of STM32H753 Controller

  • December 21, 2018
  • 6 replies
  • 2137 views

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

This topic has been closed for replies.

6 replies

Tesla DeLorean
Guru
December 21, 2018

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
Kavana shree
Associate III
December 21, 2018

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?

Tesla DeLorean
Guru
December 21, 2018

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..