cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F205: Erasing FLASH sector by sector

petrovsky
Associate II
Posted on February 17, 2014 at 15:12

I am using STM32F205 and I have designed my own bootloader. Before FLASH programming, my bootloader always erase whole FLASH from sector 1 to sector 11 (it uses fixed count cycle through sectors without determining FLASH size). For devices with 1MB FLASH it is OK, but I  wonder what heapens if I use device with 768kB of FLASH and I try to erase sector which does not exist, because of FLASH size. Is this situation indicated through FLASH->SR? I tried it on 512kB device and it seems that it works without indicating of any error. I wonder if this behaviour is aplicable for all devices (with different FLASH sizes) or I have to change erase function implementation and use FLASH size register to examine sectors count.

4 REPLIES 4
Posted on February 17, 2014 at 15:26

All the die have 1MB, you should read the size for your part from the System Loader space.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on February 17, 2014 at 16:34

unsigned short flashkb = *((unsigned short *)0x1FFF7A22);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
petrovsky
Associate II
Posted on February 21, 2014 at 10:40

Thank you for answer. If all the die have 1MB of FLASH, than I don't care about non existing sectors erase and erasing them do not cause errors during erase operation. Am I right?

Posted on February 21, 2014 at 11:34

You might get errors for other reasons, but I wouldn't use errors to determine the flash size. If your code needs to adapt to different devices, read the size from it's location, otherwise code your app to only erase the flash it knows about.

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