Author Topic: STM32 Flash organization  (Read 2317 times)

0 Members and 1 Guest are viewing this topic.

Offline tanffnTopic starter

  • Contributor
  • Posts: 17
STM32 Flash organization
« on: March 28, 2015, 12:35:40 am »
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: [Select]
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
define symbol __ICFEDIT_region_ROM_start__    = 0x08000000;

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: [Select]
define symbol __ICFEDIT_intvec_start__ = 0x08040000;
define symbol __ICFEDIT_region_ROM_start__    = 0x08040000;

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?
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: STM32 Flash organization
« Reply #1 on: March 28, 2015, 08:41:32 pm »
I'm not sure what chip you have. But the reset vector is fetched from 0x0800 0000 in the F4.
You cannot start at sector 6 without 0x0800 0000 telling to go there. Or did I miss something?

Since I put my .RESET and vector table inside sector 0, and all other stuff in sectors >1. Saving 16 kB for settings. Which is plenty.

I looked for an option byte or otp telling to start code from a different bank, but couldn't find one.
The F103 has that option, but the F4 seems to lack it.
« Last Edit: March 28, 2015, 08:43:27 pm by Jeroen3 »
 

Offline tanffnTopic starter

  • Contributor
  • Posts: 17
Re: STM32 Flash organization
« Reply #2 on: March 29, 2015, 05:03:10 pm »
Thank you Jeroen,
I will look into it.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf