S32K311 Stack pointer is setup to incorrect alignment

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

S32K311 Stack pointer is setup to incorrect alignment

跳至解决方案
2,544 次查看
MickMick
Contributor II

Hi,

I tried to export my S32DS project to IAR EWARM by referring to the link below.

HOWTO: Export S32DS Project to IAR EW (S32K14x/S32K11x)

If I did not select SDKs, I was able to debug successfully.

S32K311Eva_woSDK_NoSDK.PNGS32K311Eva_woSDK_Debug.PNG

However, if I select a SDK, a stack pointer alignment error occurs when debugging starts.

S32K311Eva_withSDK_selSDK.PNGS32K311Eva_withSDK_Debug.PNG

I set "alignment = 8" in the icf file but no improvement.

The project is not modified from the one generated by S32DS, do I need to make any changes?

My development environment is as follows.
S32DS: Version: 3.5 Build id: 230728 (Update 4)
IAR EWARM: Ver.8.50.9.33462

I hope you could help me.

标记 (1)
0 项奖励
回复
1 解答
2,455 次查看
MickMick
Contributor II

Thank you for your reply.

I looked into the alignment issue and found the following problem with the IAR compiler.

https://www.iar.com/knowledge/support/technical-notes/general/run-time-error-in-newly-migrated-proje...

Apparently, there is a problem with the startup code written in assembler.

This problem may be solved by using C for startup code.

Thank you.

在原帖中查看解决方案

0 项奖励
回复
13 回复数
2,456 次查看
MickMick
Contributor II

Thank you for your reply.

I looked into the alignment issue and found the following problem with the IAR compiler.

https://www.iar.com/knowledge/support/technical-notes/general/run-time-error-in-newly-migrated-proje...

Apparently, there is a problem with the startup code written in assembler.

This problem may be solved by using C for startup code.

Thank you.

0 项奖励
回复
1,980 次查看
SPK_FW
Contributor II

Hi  Mick,

I am also facing same issue. I created a project with S32k3 and RTD. Complied with IAR and when i start debugging stack alignment issues comes up.

I tried accessing this link "https://www.iar.com/knowledge/support/technical-notes/general/run-time-error-in-newly-migrated-proje... ", but its showing page not found.

Can you help me out.

 

Thank you

Suraj Prem

0 项奖励
回复
1,873 次查看
jiri_kral
NXP Employee
NXP Employee

Hi,

can you please share more details? Is there some error message? Normally is stack pointer stored on very first 4 bytes after boot header - not sure exact address for K311, for K344 it is 0x401000 and address of stack beginning is taken from linker script file.  

0 项奖励
回复
1,771 次查看
SPK_FW
Contributor II

Hi,

1.png

 This is error message seen. 

I have attached my .map and linker here in case its needed.

 

Thank you,

Suraj Prem

0 项奖励
回复
1,761 次查看
jiri_kral
NXP Employee
NXP Employee

Hi, 

you are using S32K1xx linker script file with S32K3xx and the stack pointer address is taken from boot header instead of correct SP address. Please use correct linker script file. 

0 项奖励
回复
1,758 次查看
SPK_FW
Contributor II

Hi,

Sorry that was a mistake happened while copy pasting as this website dont allow to do a upload of .icf files.

But In my project setting i cross verified and its correct linker file.

 

Here i have updated correct linker file.

Thank you

 

 

0 项奖励
回复
1,952 次查看
MickMick
Contributor II

Hi Suraj,

The link seems to have expired.

I think you can check the contents of the link in the archive.

http://web.archive.org/web/20230328154742/https://www.iar.com/knowledge/support/technical-notes/gene...

 

Thank you!

 
2,493 次查看
jiri_kral
NXP Employee
NXP Employee

Hi, 

I'm not familiar with IAR, but in my opinion there is no issue with alignment - the stack pointer address seems invalid for some reason. 

0 项奖励
回复
1,936 次查看
dylan_cristiani
Contributor II

Hi to all i don't know if this is the same problem, but when i compiled an empty project from nxp design studio ide, with iar toolchain, and importend into iar IDE, the problem i faced (live wathcing directly the memory with the pemicro debugger) is that the vector table was misaligned ahead by 0x40 bytes: in fact i did find the vector table @0x00400840 instead of 0x00400800 or something similar; due to fact that the first 32 bit value into the vector table is the starting SP this was a big and bloking issue; i did managed a bit the assembler code generated from nxp ide (mainly Vector_Table.s) and then the vector table back to the right place, and the issue disappeared; hope this could help you

1,930 次查看
SPK_FW
Contributor II
Hi Dylan,
Thanks for info.
Can you point out were you modified this. I am not able to locate the place to check and modify.
0 项奖励
回复
1,929 次查看
dylan_cristiani
Contributor II

i have to cross check and find differencies between native asm file generated by nxp ide and my changes: an easy way to check if the issue is the same i faced is to watch the memory area where the vector table is supposed to be located (in my case with an s32k324 derivative it was @0x0400800) and the 'real' place where it was linked (in my case if i remeber good @0x0400840). If this is the same matter as this thread, i can try to merge the differencies and post them here. Let me know

0 项奖励
回复
1,926 次查看
SPK_FW
Contributor II
Hi Dylan,
My vector table is at 0x7D 4800 So it seems to be aligned.

thanks for updates
0 项奖励
回复
1,921 次查看
dylan_cristiani
Contributor II

If into he SCB->VTOR register you are seeing your v_table address (0x7D 4800) and if watching this memory address content, you can see that here there are the correct vector table values, it seems that your issue is different from mine