MIMX8ML8 SDK optimized memcpy routine bug

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

MIMX8ML8 SDK optimized memcpy routine bug

331 Views
bjoern_almqvist
Contributor I

I had trouble getting RPMsg-Lite to run continuously on the i.MX8M Plus Cortex-M7 (FreeRTOS, MCUXpresso SDK 2.16.000, arm-gnu-toolchain 13.3) with a 1 ms request/response cycle to Linux. After a variable number of cycles the communication froze hard and the M7 stopped servicing the incoming messages.

I added a SysTick watchdog that samples the interrupted program counter when the app stopped. During a freeze it consistently showed the M7 stuck in the size_ge_16 burst loop in fsl_memcpy.S, with the link register pointing back into rpmsg_queue_recv, inside env_memcpy(data, msg.data, msg.len) while copying a received payload out of the vring buffer.

It looks like a latent alignment bug in the optimized memcpy routine, exposed by the specific alignment of the rpmsg shared-memory buffers it’s asked to copy. (I did not isolate the exact faulty instruction.)

Swapping to the standard libc memcpy fixed it for me, i.e. changing the SDK_MISC_OVERRIDE_MEMCPY define to 0.

Is this something that is logged and fixed in later SDK versions?

0 Kudos
Reply
1 Reply

252 Views
Manuel_Salas
NXP TechSupport
NXP TechSupport

Hello @bjoern_almqvist 

Hope you are doing very well.

 

The structure of the SDK regarding to the RPMSG has not any change from that Version.

Actually, in that case it is a good and functional workaround.

 

RPMSG is commonly used to send flags and short messages instead of big amount of data in the buffer, then M and A cores can access to the shared memory.

 

Best regards,

Salas.

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2377258%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EMIMX8ML8%20SDK%20optimized%20memcpy%20routine%20bug%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2377258%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20had%20trouble%20getting%20RPMsg-Lite%20to%20run%20continuously%20on%20the%20i.MX8M%20Plus%20Cortex-M7%20(FreeRTOS%2C%20MCUXpresso%20SDK%202.16.000%2C%20arm-gnu-toolchain%2013.3)%20with%20a%201%20ms%20request%2Fresponse%20cycle%20to%20Linux.%20After%20a%20variable%20number%20of%20cycles%20the%20communication%20froze%20hard%20and%20the%20M7%20stopped%20servicing%20the%20incoming%20messages.%3C%2FP%3E%3CP%3EI%20added%20a%20SysTick%20watchdog%20that%20samples%20the%20interrupted%20program%20counter%20when%20the%20app%20stopped.%20During%20a%20freeze%20it%20consistently%20showed%20the%20M7%20stuck%20in%20the%20size_ge_16%20burst%20loop%20in%20fsl_memcpy.S%2C%20with%20the%20link%20register%20pointing%20back%20into%20rpmsg_queue_recv%2C%20inside%20env_memcpy(data%2C%20msg.data%2C%20msg.len)%20while%20copying%20a%20received%20payload%20out%20of%20the%20vring%20buffer.%3C%2FP%3E%3CP%3EIt%20looks%20like%20a%20latent%20alignment%20bug%20in%20the%20optimized%20memcpy%20routine%2C%20exposed%20by%20the%20specific%20alignment%20of%20the%20rpmsg%20shared-memory%20buffers%20it%E2%80%99s%20asked%20to%20copy.%20(I%20did%20not%20isolate%20the%20exact%20faulty%20instruction.)%3C%2FP%3E%3CP%3ESwapping%20to%20the%20standard%20libc%20memcpy%20fixed%20it%20for%20me%2C%20i.e.%20changing%20the%20SDK_MISC_OVERRIDE_MEMCPY%20define%20to%200.%3C%2FP%3E%3CP%3EIs%20this%20something%20that%20is%20logged%20and%20fixed%20in%20later%20SDK%20versions%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2378558%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20MIMX8ML8%20SDK%20optimized%20memcpy%20routine%20bug%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2378558%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F263488%22%20target%3D%22_blank%22%3E%40bjoern_almqvist%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHope%20you%20are%20doing%20very%20well.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EThe%20structure%20of%20the%20SDK%20regarding%20to%20the%20RPMSG%20has%20not%20any%20change%20from%20that%20Version.%3C%2FP%3E%0A%3CP%3EActually%2C%20in%20that%20case%20it%20is%20a%20good%20and%20functional%20workaround.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ERPMSG%20is%20commonly%20used%20to%20send%20flags%20and%20short%20messages%20instead%20of%20big%20amount%20of%20data%20in%20the%20buffer%2C%20then%20M%20and%20A%20cores%20can%20access%20to%20the%20shared%20memory.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EBest%20regards%2C%3C%2FP%3E%0A%3CP%3ESalas.%3C%2FP%3E%3C%2FLINGO-BODY%3E