iMxRT1021 code jump out of call routine return to wrong location

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iMxRT1021 code jump out of call routine return to wrong location

535 Views
ChengGu
Contributor I

Hi There,

 I am using iMxRT1021 with IAR, I call a encryption routine in my code, the structure is like  a call b, b call c, c call d, d call e, e is the encryption block code.

 if I don't turn on optimization in IAR, e return directly back to a skip d/c/b. 

if I turn on optimization in IAR, e returns back to d, then d return to c, c return to b, b return to a.

I checked no stack overflow, no heap corruption. I am using freeRTOS, I don't know what could be wrong, please advise. thanks.

Best

Gu

Labels (1)
0 Kudos
3 Replies

522 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
Firstly, I don't think the encrypted code is anything related to the above call routine behavior, next, I'd like to suggest you observe the corresponding assembly instruction to figure out the influence of the optimization feature
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

514 Views
ChengGu
Contributor I

Hi Jemery,

 thanks for you suggestion. I compared the assembly code of optimization and none-optimization. in the none optimization code, the pop command is like below, 4 bytes command.

 \ 0x66 0x.... 0x.... BL squeeze
82 }
\ 0x6A 0xE8BD 0x83F1 POP {R0,R4-R9,PC}

but in optimization code, the pop command is like below. pop is 2 bytes command

\ 0x8A 0x.... 0x.... BL squeeze
115 }
\ 0x8E 0xBD70 POP {R4-R6,PC}

could this be the problem? I run my code in external spi flash, stack is in external sdram, is it possible external ram bus or the command cache cause this issue?

as I test, I change my project setting, I set my code stack to internal ocram instead of external sdram, then this problem disappear even I use none-optimization. does this mean my sdram is not reliable? thanks.

Best

Gu

0 Kudos

500 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
Thanks for your reply.
Frankly, according to the above assembly command, we only can find the differences of protecting the environment and recovering environment schemes between non-optimization code and optimization code.
More further, I'd like to know whether the code itself can get expected no matter enables optimization or not.
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos