SparkFun Forums 

Where electronics enthusiasts find answers.

Everything ARM and LPC
By fll-freak
#167600
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?
By UhClem
#167632
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. :-)
By fll-freak
#167633
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.
By hsutherl
#167647
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),
Code: Select all
>>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
Code: Select all
arm-none-eabi-nm libc.a
to see the functions. On linux I use e.g.
Code: Select all
arm-none-eabi-nm libc.a | grep strtok
to limit the output but you could
Code: Select all
arm-none-eabi-nm libc.a > libc.txt
and then search the text file.

[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.
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]