Topic : How to set MSP at the debug startup with RLink

Forum : ARM

Original Post
Post Information Post
November 24, 2010 - 3:47pm
Guest

Hi,

I use an evaluation card STM3210C that embedded an STM32F107VCT6 (64Kio of RAM at address 0x20000000)

At startup on debug session, the stack register MSP is set to 0x20005000 and not to _estack value indicate in the ld script.

It's a problem, the data section finish at 0x2000B02C so at the first function call my program crash, so my question is : How to set MSP at the startup of debug session with RLink ?

Best regards,

Nicolas.

Replies
Post Information Post
+1
0
-1
November 24, 2010 - 4:22pm
Raisonance Support Team

Hi,

Using the RLink to fix the SP would only work in debug, so it's not a valid option.

Your problem is probably in the startup file, which is responsible for initializing SP before calling main()...
Check your startup code to see why it does not use _estack from ld as it should.

Best Regards,

Vincent

+1
0
-1
November 24, 2010 - 5:30pm
Guest

Thank's for the answer,

write MSP at startup is the solution, but where the 0x20005000 come from ? I suppose RLink set the MSP with this value. Is it possible to change this value in script/configuration file (and how) or not ? The goal is to fully control the STM32 startup on debug mode. (I search in the documentation but probably not at the good place)

regards,

Nicolas

+1
0
-1
November 24, 2010 - 6:48pm
Raisonance Support Team

Hi,

The Cortex HW initializes SP from address 0 at reset. See the Cortex doc for more information.

Your startup should include this at the very beginning, just before the reset vector itself.

Now, on some devices the RAM is not completely active on reset, (for power consumption considerations) so the SP at 0 is lower than it could be, and after activating the RAM the startup modifies the SP. The startup codes provided by the ST libraries do this. I suggest you take a look at them.

Best Regards,

Vincent