EmbDev.net

Forum: ARM programming with GCC/GNU tools Yagarto arm-none-eabi- undefined reference _sbrk


von Staffan B. (staffan)


Rate this post
useful
not useful
Hello,

I'm trying to compile code for the NXP lpc2138 using Yagarto 2.20.1 (gcc 
4.5.0?)
After some initial problems with linking (wrong order of libraries) I'm 
now down to a single error:

..linking
arm-none-eabi-ld -v -LC:\program1\yagarto\lib\gcc\arm-none-eabi\4.5.0 
-LC:\Program1\yagarto\arm-none-eabi\lib -Map main.map -T2138_demo.cmd 
-o main.out  crt.o main.o adcHAL.o adf4108.o adf4156.o adcLTC1606.o 
adcLTC1864.o armVIC.o commandLineInterpreter.o counter.o fft.o flash.o 
frequencyCounter.o irq.o lmx2487.o measurementEngine.o rs232.o spi.o 
synthHAL.o system.o systemparams.o timer.o UARTStdIO.o -lm -lgcc -lc
GNU ld (GNU Binutils) 2.20.1.20100303
C:\Program1\yagarto\arm-none-eabi\lib\libc.a(lib_a-sbrkr.o): In function 
`_sbrk_r':
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\reent/.. 
/../../../../newlib-1.18.0/newlib/libc/reent/sbrkr.c:60:  undefined 
reference to `_sbrk'
make: *** [main.out] Error 1


It seems like _sbrk isn't found.
I've been searching a bit and it seems like this may be related to the 
arm-none-eabi libraries and it appears as if one solution is to add a 
stub for the _sbrk.

I am a newbie at these things so unless I get a library that I can 
include or very hands on instructions on how to get past this, I'm lost.
If anyone can help, it would be very much appreciated!

Many thanks in advace!

/Staffan

von 900ss (900ss)


Rate this post
useful
not useful
Staffan Bruce wrote:
> It seems like _sbrk isn't found.

_sbrk is part of a module which contains the low level functions to 
access your hardware. As in embedded systems the hardware from system to 
system is different, the newlib (clib for ARMs) don't know how to access 
your hardware. Therefore a small module called syscalls.c is necessary.

You can found some examples on this site:
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/

Furthermore read the doc for the newlib on the Red Hat website.

900ss

von Martin T. (mthomas) (Moderator)


Rate this post
useful
not useful
Staffan Bruce wrote:
>...
> After some initial problems with linking (wrong order of libraries) I'm
> now down to a single error:
>
> ..linking
> arm-none-eabi-ld -v -LC:\program1\yagarto\lib\gcc\arm-none-eabi\4.5.0
> -LC:\Program1\yagarto\arm-none-eabi\lib
>...

The "inital problems" could have been avoided. If the compiler-frontend 
(arm-none-eabi-gcc) is used for linking there is not need for -L 
parameters for the toolchain's library-pathes. The linker (*-ld) is 
called internally. Some options which should be passed to the linker 
need to be prefixed with -Wl, (for example -Wl,-Map=...) when calling 
the linker indirectly.

von Staffan B. (staffan)


Rate this post
useful
not useful
Martin Thomas wrote:
> Staffan Bruce wrote:
>>...
>> After some initial problems with linking (wrong order of libraries) I'm
>> now down to a single error:
>>
>> ..linking
>> arm-none-eabi-ld -v -LC:\program1\yagarto\lib\gcc\arm-none-eabi\4.5.0
>> -LC:\Program1\yagarto\arm-none-eabi\lib
>>...
>
> The "inital problems" could have been avoided. If the compiler-frontend
> (arm-none-eabi-gcc) is used for linking there is not need for -L
> parameters for the toolchain's library-pathes. The linker (*-ld) is
> called internally. Some options which should be passed to the linker
> need to be prefixed with -Wl, (for example -Wl,-Map=...) when calling
> the linker indirectly.

Martin,

Thanks for the info! Could you please point out an example file 
(preferably with a few comments!) that I could have a look at?
I guess I still need the linker program, but that gcc can invoke it 
automagically with the right parameters (except for the ones I should 
pass myself)?

Regards,
  Staffan

von Staffan B. (staffan)


Rate this post
useful
not useful
900ss D. wrote:
> Staffan Bruce wrote:
>> It seems like _sbrk isn't found.
>
> _sbrk is part of a module which contains the low level functions to
> access your hardware. As in embedded systems the hardware from system to
> system is different, the newlib (clib for ARMs) don't know how to access
> your hardware. Therefore a small module called syscalls.c is necessary.
>
> You can found some examples on this site:
> http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/
>
> Furthermore read the doc for the newlib on the Red Hat website.
>
> 900ss

Hello,

Many thanks, I followed the link and found some entries. There was one 
package containing syscalls.c, but that was for cortex-M3. Could that be 
used also for lpc-213X? Or am I perhaps missing the best entry?

Regards,
  Staffan

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.