Categories
arm Embedded

ARM Cross-Compiler

With the new server, I had to rebuild my cross compiler for arm projects. Luckily, such a thing is documented reasonably well over at gnuarm.com so I was able to get things moving along without too much fuss. Although it took a little doing to find the right combination of versions to compile properly. I’m not sure why the most up-to-date stuff doesn’t work as expected, but there it is.

The process really is straight forward: build the assembler and object manipulation tools (binutils), build a bootstrapped gcc so that newlib can in turn be built, finally finish the gcc build.

My weapones of choice:

  • binutils-2.19
  • gcc-4.3.2
  • newlib-2.17

For the sake of honesty, I also tried newlib-2.16 and newlib-2.18. The above combination was the one that finally delivered the goods. Onto the build process. If installing the tools into a home directory or something world writable, then the make command make all install will suffice. I installed everything into /usr/local so I had to switch to root to run make install.

Binutils is easy:

configure --target=arm-elf --program-prefix=arm-elf- --enable-interwork --enable-multilib
          --with-float=soft --disable-nls

Then just run make as appropriate. If locating binutils somewhere special, add a --prefix=/path/to/bintutil option to the above configure command. If using this option now, be sure to add this option to all of the following configure commands.

Next, gcc:

configure --target=arm-elf --program-prefix=arm-elf- --enable-language=c --enable-interwork
          --enable-multilib --disable-nls --disable-shared --disable-libssp --disable-libjava
          --disable-libada --disable-zlib --disable-libgfortran --with-newlib
          --with-headers=/path/to/newlib-1.17.0/newlib/libc/include

I suppose it doesn’t hurt to bring along some of those extra language features, but I don’t need them and I figured it would cut down on compile and link time. Also, if compiling for arm7 then make sure to edit the t-arm-elf file in gcc/config/arm. Basically, uncomment everything related to arm7. Missing this is a bummer because when a project needs interwork, none of the standard libraries will support it. The project may well build and link, but there will be tons of cryptic warnings about interwork not being supported made all the more mystifying when examining the command line and finding stuff like --enable-interwork there. Those commented lines in t-arm-elf are why.

For this build step, run

make all-gcc

and

make install-gcc

for a bootstrapped version of gcc so that newlib can be built.

Onto newlib:

configure --target=arm-elf --enable-languages=c --enable-interwork --enale-multilib
          --disable-nls

Run make to build it. Finally, go back to gcc and run a normal make process to finish the build.

I think most of the options are self explanatory. The disable-nls option has to do with language support and locales- not really necessary for embedded work. The disable-shared has to do with the cross-compiler executables and how they are linked- statically when disabled, dynamically when enabled. The size of the executable is smaller for dynamically linked compilers. (Again, I’m not talking about target executables.) I’m not sure what the answer is here for preference.

I’ve seen other instructions, but these worked for me.

Leave a Reply

Your email address will not be published. Required fields are marked *