memcmp fails on RT1060

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

memcmp fails on RT1060

1,860 Views
dh1
Contributor II

Hello

We experience a problem with a call to the memcmp function.

We are using MCUXpresso 11.4.1 and the Redlib library.

Under certain circumstances, the memcmp function returns the wrong result. We debugged by looking at the disassembly, and experienced unexpected behaviour there.

It seems that in the failing cases, the subs r2, #4 instruction is not executed.

Following are screenshots from the debug session, first for the successful case, and then for the failing case.

Successful case

 

Situation before the SUBS r2, #4

dh1_0-1647418914728.png

dh1_1-1647418927465.png

Situation after SUBS r2, #4

dh1_2-1647418956950.png

dh1_3-1647418968908.png

This is as expected, r2 has been decremented by 4.

Failing case

Situation before the SUBS r2, #4

dh1_4-1647419022257.png

dh1_5-1647419033337.png

Situation after SUBS r2, #4

dh1_6-1647419056464.png

dh1_7-1647419065946.png

This is not expected. r2 stays 0xC, and this seems to be the reason why the memcmp fails.

What could lead to such a failure?

Thanks in advance and regards,
Daniel

Tags (1)
0 Kudos
Reply
4 Replies

1,839 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
Thanks for your reply and clarification.
In my opinion, to avoid the cache data coherency problem, I'd like to suggest assigning a non-cacheable buffer for the store variables or arrays that will be used as input parameters in the memcmp function, it.
And please refer to the application note to do it.
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
Reply

1,853 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
I was wondering if you can introduce the testing steps of replicating the issue, moreover, please upload the demo project.
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
Reply

1,845 Views
dh1
Contributor II

Hello

Unfortunately, the problem only happens under very specific circumstances and in our full project.
The code was working, until we changed some things in other places of the project. Then suddenly it failed.

This happened to us before, it seems like it could be a problem with pipelining/cache or maybe it is dependent on what address the variables are allocated.

Regards,
Daniel

 

0 Kudos
Reply

1,757 Views
dh1
Contributor II

Hello

It seems we are getting closer to the problem, see results in this thread:

https://community.nxp.com/t5/i-MX-RT/Failure-on-BX-LR-istruction-in-redlib/m-p/1456279

0 Kudos
Reply