2014-02-17 06:12 AM
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.
2014-02-17 06:26 AM
All the die have 1MB, you should read the size for your part from the System Loader space.
2014-02-17 07:34 AM
unsigned short flashkb = *((unsigned short *)0x1FFF7A22);
2014-02-21 01:40 AM
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?
2014-02-21 02:34 AM
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.