cancel
Showing results for 
Search instead for 
Did you mean: 

stack pointer incorrect

optifier
Associate II
Posted on March 25, 2013 at 10:39

Hi,

We are trying to migrate from IAR Kickstart kit with IAR-STM32F207ZG-SK board to our own board.

On our PCB we have STM32F207ZC mounted.

The small test code is successfully downloaded with J-Link.

Downloaded C:\data\p-1026-lockkort-pwm10\arm\examples\ST\STM32F2xx\STM32F2xx_StdPeriph_Lib\Project\STM32F2xx_StdPeriph_Examples\TIM\TIM10_PWMOutput\STM322xG_EVAL\Exe\TIM10_PWMOutput.out to flash memory.

But we get this warning:

Warning: Stack pointer is setup to incorrect alignment. Stack addr = 0xFFFFFFFF

We have changed to the device we use in IAR pre-processor settings.

Probably there is still a file somewhere that describe device used as STM32F207ZG

and set stack pointer to a non-existing SRAM address.

The downloaded program do not run.

Any suggestions where to look for and change device settings?

/Richard

9 REPLIES 9
Posted on March 25, 2013 at 12:27

Looks more like it's not programming flash, or the right area at the beginning. You should definitely look over the .MAP file to see where things are situated.

Not a big IAR guy, but I'd imaging there is a CPU Target selection under the options, but this should only alter the size of memory regions, not the start address. Check the debug/flash algorithm settings. Check the flash memory with something like JMem to confirm your app downloaded at 0x08000000. Check what you're doing with the  BOOTx pins.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
optifier
Associate II
Posted on March 25, 2013 at 14:51

Hi clive1,

MAP file seem to have correct values:

*** PLACEMENT SUMMARY

***

''A1'':  place at 0x08000000 { ro section .intvec };

''P1'':  place in [from 0x08000000 to 0x080fffff] { ro };

''P2'':  place in [from 0x20000000 to 0x20020000] { rw, block CSTACK, block HEAP };

  Section            Kind        Address    Size  Object

  -------            ----        -------    ----  ------

''A1'':                                      0x184

  .intvec            ro code  0x08000000   0x184  startup_stm32f2xx.o [1]

                            - 0x08000184   0x184

We have changed to the device we're using inside IAR options and J-Link seem to get it right during download:

Device ''STM32F207ZC'' selected (256 KB flash, 64 KB RAM).

J-Link seem to use correct bootloader and debugger algoritm:

lö mar 23, 2013 15:40:59: Loaded debugee: C:\Program Files (x86)\IAR Systems\Embedded Workbench 6.5\arm\config\flashloader\ST\FlashSTM32F205xC.out

lö mar 23, 2013 15:40:59: Target reset

lö mar 23, 2013 15:40:59: Downloaded C:\data\p-1026-lockkort-pwm10\arm\examples\ST\STM32F2xx\STM32F2xx_StdPeriph_Lib\Project\STM32F2xx_StdPeriph_Examples\TIM\TIM10_PWMOutput\STM322xG_EVAL\Exe\TIM10_PWMOutput.out to flash memory.

lö mar 23, 2013 15:40:59: Loaded macro file: C:\Program Files (x86)\IAR Systems\Embedded Workbench 6.5\arm\config\debugger\ST\Trace_STM32F2xx.dmac

lö mar 23, 2013 15:40:59: Hardware reset with strategy 0 was performed

lö mar 23, 2013 15:40:59: 3308 bytes downloaded into FLASH (10.91 Kbytes/sec)

lö mar 23, 2013 15:40:59: Loaded debugee: C:\data\p-1026-lockkort-pwm10\arm\examples\ST\STM32F2xx\STM32F2xx_StdPeriph_Lib\Project\STM32F2xx_StdPeriph_Examples\TIM\TIM10_PWMOutput\STM322xG_EVAL\Exe\TIM10_PWMOutput.out

lö mar 23, 2013 15:40:59: Hardware reset with strategy 0 was performed

lö mar 23, 2013 15:41:03: Warning: Stack pointer is setup to incorrect alignment. Stack addr = 0xFFFFFFFF

lö mar 23, 2013 15:41:03: Target reset

lö mar 23, 2013 15:41:04: There was 1 warning during the initialization of the debugging session.

BOOT pins are set to download from flash (same setting on EVAL board works).

STM32 processors are new territory for us, I got an inkling that somewhere inside a file wrong values are passed. Tried to search with no luck...

/Richard

Posted on March 25, 2013 at 17:52

Use the JMem utility, check the memory content at 0x08000000 and 0x00000000

Your .MAP still reflects FLASH 1MB, RAM 128KB, although honestly it's the same die as the one you're using.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
jpeacock2399
Associate II
Posted on March 26, 2013 at 04:02

Are you sure you are booting from user flash?  Check the BOOT0 AND BOOT1 pins.

The MSP stack is inited from the first entry in the vector table.  Looks like you aren't loading from the right location.

  Jack Peacock
optifier
Associate II
Posted on March 26, 2013 at 19:32

I'm clueless.

But also quite happy...

Did some more code development on Kickstart eval board.

I.e got USART3 up and running finally.

Thanks Clive1 for giving a code example in another thread.

Made me realize that the example code was missing essential stuff.

Decided to get back to our own board and maybe try to see what JMem could offer to solve the problem.

Connected the board to J-Link and downloaded the new code, expecting same warning about Stack address.

But no, it just worked!!

Thanks everyone trying to help, hopefully this subject is solved now and I can concentrate on developing code.

What caused it in first place remains a mystery...

/Richard

Posted on March 26, 2013 at 20:40

The suggestion with JMem would do two things, it would confirm that the device was being flashed with code, and secondly indicate what is mapped at zero, ie FLASH, RAM or ROM.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
shaxjl
Associate
Posted on January 16, 2014 at 05:22

In 'project settings', 'Debugger, 'download' page, select the 'use flash loader(s)' checkbox... 

subodhsvs
Associate
Posted on October 06, 2014 at 11:16

For me this one worked :

   Go to -- ''Options->Debugger->Download'' .  Select 'Use flash loader(s)'.

Every time I faced this Warning Message ''.....stack addr = 0xFFFF...''. I have observed that this option gets automatically unchecked.

  This seems to be  some bug with IAR development environment.

I hope this works for you as well

megahercas6
Senior
Posted on October 06, 2014 at 12:09

http://youtu.be/FV5x-RiyKqo?list=UUDBSFAz0IZN4Jjs07bH1XqQ

if you follow all steps, it should work just fine. Yes, using correct flash loader for your correct device is essential to make it work