cancel
Showing results for 
Search instead for 
Did you mean: 

What is the right way to write to the flash?

noam ben
Associate
Posted on May 02, 2018 at 08:20

hi i'm using stm32F030F4P6 what is the right way to write to the flash? from where(the start address) i can write? i know that the start address is 0x08000000 but did my code download to there? and before i write did i need to erase the address where i want to write over and over?

#flash-sector
3 REPLIES 3
Posted on May 02, 2018 at 13:57

You can only write to locations once after you erase them. The erase block/page size is significantly larger than the minimum write unit, so you erase a block, and can then write many words.

You should try an avoid situations/code where you erase and write data in the same areas thousands of times.

The device has a 16KB FLASH, so 0x08000000..0x08003FFF, with 1KB blocks

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on May 02, 2018 at 14:43

thank you for the answer.

how do i know what the maximum size of the flash that my code take place when i download it?

i try to write with the function HAL_FLASH_Program to the address 0x08000000 but my code/program stuck after the writing.

and if i write to the address 0x08004000 all goes well. 

thx

Posted on May 02, 2018 at 17:40

Not sure how I'd know, you could look in the .MAP file or other output from the Linker to understand the utilization. In your own code you could pull through symbols generated by the linker.

If you write at 0x08004000 and beyond it suggests the die has more than 16KB, which is possible, but you'd need to be careful as this is untested, and has the potential to be eliminated if a die shrink moves to a 16KB only implementation.

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