Yagarto arm-none-eabi- undefined reference _sbrk

OP #1708907
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
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
Moderator
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.
OP
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
OP
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

Reply

A question of your own? This thread is over 16 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.