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

strlen

Posted by jordiblasi on July 28, 2016

I am using Freertos on a Intel Galileo Gen 2 board and I am trying to copy and compare some strings but i am having some trouble. As I see I have available on the libraries distribbuted the strlen, strcpy, memcpy and memcmp. What I am seeing is that both strlen and strcpy don't work. They are even commented as "Extremely crude implementations" in the code. In fact, strlen seems not be be even implemented. memcpy and memcmp seem to do the job, but they ask for the memory string size to work with. As I am not able to use strlen, I have been defining a maximun string size to perform this operations. I understand that this is not optimal, but at least it works for copying. My problem is that if I compare two strings, one static value and the other as an entry to a function I get values that don't fit what I was expecting.

~~~

define VARSIZE 50

static char reference[VARSIZE];

int locate(char id[] ) { ... r = memcmp(conTab[a].reference,id,VARSIZE); ... } ~~~

When I set both values to "refe03" (so comparison result should be 0) I get as a result value 43. If I set other values (f.e. "refe04" for id) I get 45 as a result. Am I doing something wrong? How can I solve this?

Thanks,


strlen

Posted by rtel on July 28, 2016

It might be that GCC is using a builtin version of the function. Try adding -fno-builtin-strlen to the command line to see if that fixes the strlen() problem. Also, the source code for the function is there and is very short, so you can step through it easily enough to see what it is doing to check it is correct.

The crude implementations of the functions are only provided because the demo as downloaded makes no assumptions as to the C libraries that are available with the compiler. Ideally link to a suitable GCC unhosted C library, then use the functions provided by the C library.


strlen

Posted by jordiblasi on July 28, 2016

Running the gcc command with -fno-builtin-strlen changes nothing in the response. I get this error:

undefined reference to 'strlen'

I have tried to remove the string.h and freestanding_functions.c files to force it to use the standard libraries but it looks like it is not able to find them. I have included the cygwin libraries I have in my computer (by adding C:cygwin64usrinclude to the eclipse include folders) but it does not use them.

Where can I get a valid library set to use?

Thanks,

Jordi


[ 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