AnsweredAssumed Answered

STM32-E407 + ARM-USB-TINY + OpenOCD Stack problem

Question asked by car.marko on Feb 13, 2013
Latest reply on Feb 13, 2013 by Clive One

I have successfully programed and debugged my chip many times with toolchain from subject (IAR 6.30.6 + OpenOCD 0.6.1) and everything worked just fine.

Then something went wrong. After download IAR threw a warning:  "Warning: Stack pointer is setup to incorrect alignment. Stack addr = 0xFFFFFFFF".

I couldn't debug normally my code and breakpoints didn't work also. OpenOCD started setting xPSR to incorrect address when I tried to download a program to flash.

As I sad, I haven't change anything in toolchain or in project options.

After hours of searching I found a workaround for my problem. While I was searching for solution I came across on link

I'll try to explain procedure that works for me...

I made a small "empty" project with ST library, board specific files, startup file and main. I have only SysInit and empty while(1) loop in main.c. The idea was mainly to initialize interrupt vectors.

After that I programed my Project.bin image to flash via telnet. Then I tried download it trough IAR couple of times and everything worked fine. Info window looked like on

Then I downloaded successfully my CODE from IAR and finally I was able to debug it! But...after that I tried once more and error popped up again! You can see that on

Then I tried to download from IAR my "empty" code and got the same error. Then I tried once again and I managed to download it without errors. After that I was able to program my code.


To debug my code (let we say that I have my "empty code" downloaded to flash) trough IAR I have to do next steps:

Program my code and debug it. If I want to change something and download it again I have to do next:

1. Download my "empty code" for the first time. (Stack warning)
2. Download my "empty code" for second time. (No warnings no errors and debugging works fine)
3. Download my code. (No warnings no errors and debugging works fine)
4. If I have to change something and then debug it--> jump to step 1

I would also like to ask how can I set CSTACK starting address to top of the RAM 0x20020000 in startup.s file because as I can see it is not set to that address by default.

I really appreciate any help you can provide.