Standard libraries for ARM

Very confused. Hundreds of tutorials and none of them work as versions and tools have changed over the years.

I am an experienced ARM programer but I use the expensive tools at work (IAR, JLINK). For home I have been trying to get an Atmel AT91SAM7S256 up and running using free tools. I took the easy way and downloaded the OlimexODS package that includes Yagarto, Eclipse, and OpenOCD. For the most part I have this working. I can compile under Eclipse using a makefile project. I can download it to the host using OpenOCD. I have yet to figure out how to run the debugger. But that will be the subject of a future question.

Right now, I am trying to figure out where to get basic libraries like strlen, strcpy, memset, strtok, sin, cos, and atan2. I found myself rewriting these as I need them, but there must be a better way. Is there an embedded version of the C standard libraries that work on ARM?

It has been a bit but I built the gcc tool chain from scratch for the STM32F4 Discovery board and the libraries are there. I see strlen is in libc.a and atan2 is in libm.a.

libc should normally get linked by default but libm requires that you add “-lm” to the command line. Perhaps the flags are set to prevent linking of the default libraries.

I didn’t have much use for the standard library in my code but I did use some string functions. But that is a story for another time. :slight_smile:

I am not using GNU per see but rather the Yagarto version that I beleive is devired from GNU. As far as I can see, the the only library file that is available only has the compiler helper functions like floating point multiply and divide. I have used ‘ar’ to dump the contents of the .a file and nothing comes up looking like strlen, sprintf, …

Strangely, Eclipse sees my call to strlen and thinks life is good (it must have some knowledge of what should be in the standard library?) even though I do not include <string.h>. And when I link the linker generates an error for the missing routine.

Perhaps I should go back to GNU and look for the ARM libraries there and see if I can compile them under ARM. Last time I tried (a few months ago), I was unable to find the needed source.

This is where I learned how to compile it myself:

http://cu.rious.org/make/compiling-the- … -yourself/

But those instructions had an error which built the library incorrectly for a Cortex M4. Which meant that my calls to the string library were adjusted by the linker into instructions not available on a Cortex M4. Took me a while to figure that one out.

Has good sized C library, including printf() and all, and the I/O devices on a Freescale ARM K20 w/256KB flash/64KB RAM

http://www.pjrc.com/teensy/index.html

http://forum.pjrc.com/forum.php

also sold by SFE, Osh, others.

Is very low cost/small.

Interesting about teensy. I’d looked at that but not lately. Definitely worth another look…

I did compile my own toolchain a few years ago but pre-compiled tools are available. If the yagarto you downloaded from Olimex seems to be recent, stick with that, otherwise you might be better off to download either the [latest yagarto, [linaro (be sure to get the bare metal flavor) or [sourcery codebench lite (previously codecourcery).

Not exactly sure how to define recent. From linaro 2012-q2 (which isn’t the latest),

>>arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.6.2 20120613 (release) [ARM/embedded-4_6-branch revision 188521]

In your linker commands you need to include a -L directive to tell the linker what directory the libraries are in. You’ll need to sniff around - they may be somewhere like path/to/yagarto/arm-none-eabi/lib for arm code and path/to/yagarto/arm-none-eabi/lib/thumb for thumb code. Dunno for interworking. My very old version of yagarto has a yagarto/arm-elf/lib/interwork directory. If the current version of yagarto still has that it might be an advantage over linaro. Linaro has good instructions for cortex parts in the readme but I don’t see anything about ARM7TDMI (armv5).

As UhClem said it sounds like all the functions you mentioned are standard libc and libm, so you could probably just put -lc and -lm on the linker command line. Linaro and sourcery both include libc and libm doc files. If yagarto does then that is one way to check which lib has strtok for example. You can also use something like arm-none-eabi-nm libc.a to see the functions. On linux I use e.g. arm-none-eabi-nm libc.a | grep strtok to limit the output but you could ```
arm-none-eabi-nm libc.a > libc.txt


[edit]It sounds like you looked at the .a files under yagarto/lib/gcc/arm-something/4.x.y. As you said, those only contain the gcc internal functions. You need to sniff around and find the libc and libm locations.](http://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition.html)](http://www.linaro.org/downloads/)](http://sourceforge.net/projects/yagarto/files/YAGARTO%20for%20Windows/20121222/)