K22 and IAR - Stack pointer is setup to incorrect alignment

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

K22 and IAR - Stack pointer is setup to incorrect alignment

ソリューションへジャンプ
11,400件の閲覧回数
weblar
Contributor V

Hi,

I have a puzzling problem.

For the past 2 weeks, I've been downloading and debugging code written for a Kinetis K22 device through IAR v6.40. I did have to manually copy across the supporting K22 files from a later version of an IAR trial as the K22 doesn't have the support files in 6.40 - however, this has been working perfectly for the past 2 weeks, i.e. USB CDC device working, OLED display via FlexBus, etc, etc.

All of a sudden, I am no longer able to debug because of the following error when trying to download the binary to the device:

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

I've tried to create a new, simple project with just a main function targetting the same K22 device however this also fails with the same issue when downloading and debugging via the Segger J-Link. I had thought that the device could be securely locked so today I replaced the chip however this has made no difference. The map file generated by the compiler seems absolutely fine.


I am sometimes able to download to the device using Seggers own J-Flash utility however this is quite flaky, the device takes a long time to reset but when it does download, the application runs as expected.

Having torn pretty much the last of my remaining hair from my head, I can't even begin to think what could have changed. The obvious answer is nothing, I've not updated any drivers or J-Link firmware, nor IAR updates.

Please please please can someone help me with this.

Regards,

Kevin

ラベル(1)
タグ(3)
0 件の賞賛
返信
1 解決策
6,900件の閲覧回数
weblar
Contributor V

Hmm, mysteriously, I've turned on the "Use flash downloader" in the debugger options tab and all is well in the world again.

Unless this was "on" by default and has somehow manage to un-tick itself then I'm in a total state of befuddlement.

Kev

元の投稿で解決策を見る

0 件の賞賛
返信
6 返答(返信)
4,309件の閲覧回数
sanjay645
Contributor I

Hello, I have same problem, I have migrated code from s32 design studio to IAR embedded workbench, when I am trying "debug without download", I am getting error "

Mon Sep 25, 2023 11:57:36: : User error: Stack pointer is setup to incorrect alignment.  Stack addr = 0xcdcd'cdcd
Since I don't have orignal hardware, I want to run it in simulator. Please help me if it can be done.

 

0 件の賞賛
返信
6,901件の閲覧回数
weblar
Contributor V

Hmm, mysteriously, I've turned on the "Use flash downloader" in the debugger options tab and all is well in the world again.

Unless this was "on" by default and has somehow manage to un-tick itself then I'm in a total state of befuddlement.

Kev

0 件の賞賛
返信
6,900件の閲覧回数
mjbcswitzerland
Specialist V

Kevin

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


This is a message that IAR always displays when the start of Flash (first 4 bytes at 0x00000000) is not programmed. If you do a chip erase and connect to the board using the "Debug without downloading" command rather than the "Download and Debug" command it will always occur. This suggests to me that some setting in the debugger setup has changed, for example the "Suppress download" option has been enabled in the "Debugger | Download" configuration (?)

Regards

Mark


6,900件の閲覧回数
weblar
Contributor V

Hi Mark,

We must have posted at the same time.

When I try an application, I always use "Download and debug", never the alternative. The answer lies within the "use flash downloader" option - turning this on fixes the problem.

Regards,

Kevin

0 件の賞賛
返信
6,901件の閲覧回数
mjbcswitzerland
Specialist V

Kevin

Sometimes these tools seems to have a mind of their own...

However I thought it would likely be due to no download taking place because IAR otherwise gives a warning after the download in case any written flash location doesn't match the downloaded code (as in the case of differences in the Flash configuration pattern that it may purposly not set as in the code).

Regards

Mark

0 件の賞賛
返信
6,901件の閲覧回数
weblar
Contributor V

Hi Mark,

The odd thing is though, I don't ever remember it being turned on - its always been off yet working.

IAR does have a tendency to do very odd things and given the hefty price-tag, it can be a pile of cr**!

Thanks Mark, have a good weekend.

Regards,

Kevin

0 件の賞賛
返信