Sep 122008
 
Compiling jcwren's LPC2148 Demo

Turns out using CodeSourcery’s gcc is not problem-free: to use jcwren’s highly recommended lpc2148 demo code, it’s needed to compile newlib, the C library for embedded machines, with one particular option, as otherwise you’ll get errors when linking the demo code. When not using newlib, all is fine though. Since I do want to use the code, I had to configure newlib accordingly.

The hint came from Dan on the LPC2000 mailing list:

One more thing…. your demo requires the version of newlib without
the syscall stubs and without reentrant syscalls. WinARM and most
distributions don’t have this.

Here in short the way to compile the tool chain (see also http://www.gnuarm.com/support.html)

  1. Get binutils-2.1.7, gcc-4.3.2, newlib-1.16.0 (the version from cvs has small changes which are not 100% compatible with 1.16.0)
  2. Compile binutils for arm-elf and install, and then add the bin directory of the installed binaries to PATH:
    ../binutils-2.17/configure --target=arm-elf --prefix=/opt/cross --enable-interwork --enable=multilib --with-float=soft
  3. Configure and compile first stage of gcc:
    ../gcc-4.3.2/configure --target=arm-elf --prefix=/opt/cross --enable-interwork --enable-multilib --with-float=soft --enable-languages="c,c++" --with-newlib --with-headers=../newlib-1.16.0/newlib/libc/include
    Configure and compile newlib:
    ../newlib/src/configure --target=arm-elf --prefix=/opt/cross --enable-interwork --enable-multilib --with-float=soft --disable-newlib-supplied-syscalls
  4. Compile the rest of gcc

The arm-elf-objdump is awfully slow though and strace shows lots of
open("../../../../../newlib/src/newlib/libc/stdlib/mbrtowc.c", O_RDONLY) = -1 ENOENT (No such file or directory)

with changing values for mbrtowc.c, but about 100 repetitions of each such line for each source file. That was the only problem I faced. Since objdump is not needed, I’ll simply skip it unless really needed.