Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

Potential problems with memcpy() in ISR

Posted by npkz on March 13, 2017

Hello people,

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.

Regards, Nenad


Potential problems with memcpy() in ISR

Posted by heinbali01 on March 13, 2017

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?


Potential problems with memcpy() in ISR

Posted by rtel on March 13, 2017

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.


Potential problems with memcpy() in ISR

Posted by npkz on March 13, 2017

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?


Potential problems with memcpy() in ISR

Posted by npkz on March 13, 2017

Yes, I am using Zynq and FreeRTOS v8.2.3. So I am not able to make a use of that funcionality.


Potential problems with memcpy() in ISR

Posted by heinbali01 on March 13, 2017

I pointed to the wrong file. It should be:

~~~ FreeRTOS-Plus/Demo/FreeRTOSPlusTCPandFATZynqSDK/RTOSDemo/src/memcpy.c ~~~

But don't worry, I attached that file in this post.

It will replace the standard memcpy().

Regards.

Attachments

memcpy.c (5958 bytes)

Potential problems with memcpy() in ISR

Posted by heinbali01 on March 13, 2017

Forgot to mention, if you want to use the FPU and have its registers saved saved as the task- or ISR-context, please have a look here


Potential problems with memcpy() in ISR

Posted by npkz on March 13, 2017

Wow, I can't thank you enough! And I must say that this forum generally provides most helpful and fastest support!


Potential problems with memcpy() in ISR

Posted by heinbali01 on March 14, 2017

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().

It is all described here


Potential problems with memcpy() in ISR

Posted by npkz on March 16, 2017

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 configUSETASKFPU_SUPPORT to 0.


Potential problems with memcpy() in ISR

Posted by thomask on March 21, 2017

I've run into similar problems, and built my own toolchain with Crosstool-NG.

You might be interested to try it out: https://github.com/thomask77/ct-ng-toolchains


Potential problems with memcpy() in ISR

Posted by aseris on March 27, 2017

Had issue memcpy crash like. The root cause was in incorrect pointer typecast in 3rd party open source code. The chain was: some uint16t record in structure -> void * type pointer to this record - > uint32t * type pointer to this record. In case of 32 bit architecture it causes strange behavior during built in memcpy.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists