cancel
Showing results for 
Search instead for 
Did you mean: 

GCC toolchain compling errors

xzhang
Associate II
Posted on November 04, 2008 at 00:28

GCC toolchain compling errors

3 REPLIES 3
xzhang
Associate II
Posted on May 17, 2011 at 12:50

Hi

I am using CodeSoucery G++ tool chain for my STM32 project. I setup my GCC environment by following this website:

http://sites.google.com/a/stf12.net/developer-sw-fw/eclipse-demo

When I tried to build my project, I got below error messages:

c:/program files/codesourcery/sourcery g++ lite/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-sbrkr.o): In function `_sbrk_r':

sbrkr.c:(.text+0x12): undefined reference to `_sbrk'

c:/program files/codesourcery/sourcery g++ lite/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-writer.o): In function `_write_r':

writer.c:(.text+0x16): undefined reference to `_write'

c:/program files/codesourcery/sourcery g++ lite/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-closer.o): In function `_close_r':

closer.c:(.text+0x12): undefined reference to `_close'

c:/program files/codesourcery/sourcery g++ lite/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-fstatr.o): In function `_fstat_r':

fstatr.c:(.text+0x14): undefined reference to `_fstat'

c:/program files/codesourcery/sourcery g++ lite/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-isattyr.o): In function `_isatty_r':

isattyr.c:(.text+0x12): undefined reference to `_isatty'

c:/program files/codesourcery/sourcery g++ lite/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-lseekr.o): In function `_lseek_r':

lseekr.c:(.text+0x16): undefined reference to `_lseek'

c:/program files/codesourcery/sourcery g++ lite/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-readr.o): In function `_read_r':

readr.c:(.text+0x16): undefined reference to `_read'

collect2: ld returned 1 exit status

cs-make: *** [IOM_ACQ.elf] Error 1

I spend some effort to figure out those errors caused by sprintf() in my code. But I don't know why I can't call c library?

I searched some arm forum about this topic, some people mentioned about syscalls.c. Does anybody know this issue? If it does need a syscalls.c, does anybody can give a sample code?

disirio
Associate II
Posted on May 17, 2011 at 12:50

Hello,

you are working with a barebone machine so the newlib needs some minimal support in order to allocate memory and perform I/O tasks.

You should provide replacement for some syscalls normally provided by the OS, read this article:

http://sourceware.org/newlib/libc.html#SEC196

Most functions are just stubs, the sbrk() should be implemented in order to make the allocator work (probably the sprintf() allocates memory internally).

regards,

Giovanni

---

ChibiOS/RT

http://chibios.sourceforge.net

xzhang
Associate II
Posted on May 17, 2011 at 12:50

Hi Giovanni

Thanks for help. the link you provided clarifies systemcall functionality. Since I am more familiar with hardware stuff other than software, this document is good for me.

I have solved the problem to use GCC library in my project. I found this link provided good details about how to write syscalls.c and how to define 'end' in link script:

http://forum.sparkfun.com/viewtopic.php?t=5390&start=15

Now my code has been complied without errors! :p

Regards,

JZ