2015-03-27 05:37 PM
Hello!
I found an interesting issue with FLASH_Erase_Sector().Two setups, one always works the other usually doesn't.Setup 1 - that always works:
Program starts at SECTOR_0[code]
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;
[/code]
And my variables I wish to save is at SECTOR_10 (0x080C0000)
Setup 2 - That ''sometimes'' works:
Program starts at SECTOR_6 (2nd 128KB sector)[code]
define symbol __ICFEDIT_intvec_start__ = 0x08040000;
define symbol __ICFEDIT_region_ROM_start__ = 0x08040000;
[/code]
And my variables I wish to save is at SECTOR_[0 to 5] SECTOR_[7 to 11].
In the 2nd setup the PC will run to the end of the memory (when I stop it and look at the assembly windows).The weird thing is that it's inconsistent, sometimes it does work..If I try to debug it, moving step by step it *always* work, if I run it it will fail (stuck)Looking at the project.map everything looks good..Maybe it's something to do with timing? (sector <5 are smaller, faster to erase which is also why I prefer the 2nd setup).Did you encounter this phenomena? What do you think? #stm32f #flash #rewrite2015-03-27 07:40 PM
The debugger might fake it, but the processor doesn't know how to start code at 0x08080000. You have to have vectors (SP, PC) at Zero (0x08000000 maps to zero with BOOT0=Low) to tell the processor where to go. And the code in SystemInit() will need to set SCB->VTOR to the actual vector table if the address is different.
2015-03-27 10:55 PM
Again, thank you Clive! :)
So place the bootloader at 0, even a minimalistic jump to sector 5 (0x08020000).