Skip to main content
ariel2
Associate III
March 28, 2015
Question

STM32 Flash organization

  • March 28, 2015
  • 2 replies
  • 766 views
Posted on March 28, 2015 at 01:37

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 #rewrite
This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
March 28, 2015
Posted on March 28, 2015 at 03:40

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.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
ariel2
ariel2Author
Associate III
March 28, 2015
Posted on March 28, 2015 at 06:55

Again, thank you Clive! :)

So place the bootloader at 0, even a minimalistic jump to sector 5 (0x08020000).