Page 1 of 1

Linking to _sbrk

Posted: Sun Dec 20, 2015 4:36 am
by A319
Hi,

I want to print out some data from my calculations, which I want to do with my STM32. But sbrkr.c is unable to link _sbrk.

Code: Select all

double t = 0;
while(t < 90) {
   sgp4(&m, tsince, &e, pos, vel);
   char buff[30];
   sprintf(buff, "%f %f %f %f\n", t, pos[0], pos[1], pos[2]);
   uartStartSend(&UARTD2, sizeof(buff), buff);
   t += 1;
}


Code: Select all

/home/sven/gcc-arm-none-eabi-4_8-2014q2/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib/armv7e-m/libg.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
collect2: error: ld returned 1 exit status


I've checked, that CH_CFG_USE_MEMCORE is set TRUE (See http://stackoverflow.com/questions/3244 ... 6#32446906).
I've also checked, that $(CHIBIOS)/os/various is included. (See viewtopic.php?t=630&p=6424)

Regards
Sven

Re: Linking to _sbrk

Posted: Sun Dec 20, 2015 7:39 am
by Giovanni
Hi,

Is syscalls.c included in the makefile? you could simply use chprintf() too.

Giovanni

Re: Linking to _sbrk

Posted: Sun Dec 20, 2015 8:30 pm
by A319
No. I compared another example Makefile.

I added

Code: Select all

$(CHIBIOS)/os/various/shell.c \
$(CHIBIOS)/os/hal/lib/streams/memstreams.c \
$(CHIBIOS)/os/hal/lib/streams/chprintf.c \

to CSRC

and

Code: Select all

$(CHIBIOS)/os/hal/lib/streams

to INCDIR

And it works now :)

Thanks
Sven