are there any known problems on using memcpy() function inside of ISR? I’ve had some really odd problems while using it in ISR (I can get into those if needed), even though buffers that were being used as parameters for memcpy weren’t being shared by other tasks. I decided to manually do the copying instead of using memcpy(), and those strange problems disappeared.
Hello Nenad, recently there was a post in which the standard memcpy() seemed to crash.
Could you try your code using memcpy() but also with the compiler option -fno-builtin-memcpy?
In addition to Hein’s valid comments: Are you using a Zynq? If so then
there are some library optimisations that use the floating point
registers even when they are not saved as the task or ISR context.
Hein’s option of creating your own memcpy function is a solution for
that too - but the latest FreeRTOS version also has an options to always
save floating point registers for all tasks and ISRs - it fixes the
problem at the expense of adding RAM and processing time overheads.
Hi Hein, thanks for your quick answer!
I have just added that compiler option, but it doesn’t help.
In that previous post you mentioned that there are memcpy() alternatives in /labs sw. I have downloaded it but couldn’t find specific functions, probably I am not searching right. Can you specify in which file I can see those?
Thank you good to hear. But I’m curious about the results:
Which solution did you choose?
● Replace memcpy() with a new implementation
● Make sure the FPU registers are stored/restored as the task- or ISR-context
The reason for not storing FPU registers by default is performance: during each task switch, an extra 260 bytes must be saved and restored.
If you only have a single task that uses the FPU, you can tell the scheduler to store the registers of that task only by calling portTASK_USES_FLOATING_POINT().
Yes, I have replaced memcpy() with a new implementation (and added mentioned compiler options).
Well, since I don’t have a need to use FPU at all in my app, I just decided to set configUSE_TASK_FPU_SUPPORT to 0.
Had issue memcpy crash like. The root cause was in incorrect pointer typecast in 3rd party open source code. The chain was: some uint16_t record in structure -> void * type pointer to this record - > uint32_t * type pointer to this record. In case of 32 bit architecture it causes strange behavior during built in memcpy.