cancel
Showing results for 
Search instead for 
Did you mean: 

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

xxmarko
Associate
Posted on February 13, 2013 at 14:06

Hi,

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

https://forum.sparkfun.com/viewtopic.php?p=67685

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

http://i.imgur.com/0lKDKBs.jpg

.

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

http://i.imgur.com/FW5n3d7.jpg

http://i.imgur.com/Aet57AD.jpg

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.

Conclusion:

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.

Marko 

#stm32-ocd
1 REPLY 1
Posted on February 13, 2013 at 16:30

But you see all those verify errors saying the FLASH contains 0xFF but the file has something else? And surprise, when it loads SP/PC from 0x08000000 they contain 0xFFFFFFFF.

You perhaps need to do a mass erase, or look at what flash applet/macro IAR is using to erase/program the part. Check things like erase before download, and download before run settings.

You need to get to the bottom of the flashing issue first, else nothing is going to run.

Perhaps try some different JTAG pods.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..