Re: GCC linking and compiling error for Cortex-M3 Microcontroller because of Newlib

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2011-01-09 at 11:12 -0800, deut3892 wrote:
> Hello,
> 
> Please forgive me if my post is in an incorrect place. This seems to be the
> most appropriate place for it since it is about gcc.
> 
> I have followed the instructions here:
> http://johannes-bauer.com/mcus/cortex/
> 
> Basically, I have setup the gcc cross compiler in Ubuntu 10.10 for the
> Cortex-M3 compiler. I've also added GDB and eclipse. Compilation of a simple
> hello world program works just fine, but when I need to compile more
> advanced programs that use malloc and other features that are part of newlib
> fails.
> 
> Newlib was compiled as:
> newlib-1.18.0/configure --target=${BLD_TARGET} --prefix=${BLD_PREFIX}
> --disable-multilib --disable-newlib-supplied-syscalls --disable-interwork
> 
> therefore, my understanding is I have to supply my own newlib. When I am
> compiling and linking I get the following errors:
> 
> /home/ops/bin/arm-elf/lib/gcc/arm-elf/4.4.3/../../../../arm-elf/lib/libc.a(lib_a-sbrkr.o):
> In function `_sbrk_r':
> /home/ops/Desktop/arm-toolchain/newlib/arm-elf/newlib/libc/reent/../../../../newlib-1.18.0/newlib/libc/reent/sbrkr.c:60:
> undefined reference to `_sbrk'
[...]
> 
> How would I got about resolving this? Should I change the newlib
> configuration before I compile and recompile?
> I know that I need to add stubs and I've tried adding them from the
> codesourcery g++ lite library. However, it gave me many errors about the use
> of asm:
> syscalls.c:81: error: expected '=', ',', ';', 'asm' or '__attribute__'
> before 'asm'
> 
> The syscalls I use is similar or the same as the one in:
> http://newlib.sourcearchive.com/documentation/1.14.0-1/libgloss_2arm_2syscalls_8c-source.html
> 
> I'd be appreciative of any help. Being my first time really compiling gcc
> from scratch, I would hope I can make good use of it.

newlib is really divided into two parts, the standard C library
implementation and the low-level IO functionality.  The symbols you are
missing are all from the latter category.  That IO functionality is
normally supplied by libgloss.  Perhaps you aren't linking that in
properly.

libgloss cannot be written without some knowledge of how IO works on
your board.  If you are doing IO through a serial line then the
implementation is going to be vastly different to a case where IO is
done through some boot monitor program, or when you've got an embedded
file-system.  There are some example implementations for ARM boards (for
example, there's an implementation that uses semi-hosting sys-calls that
can be trapped using a JTAG unit), but ultimately you have to decide how
that will be done and link in the relevant version of libgloss.

Hope that helps.

R.





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux