Changes by last author:
Added:
== Hardware Specific Compilation Information ==
Each hardware implementation has their own quirks for building: * CrossCompilation/GameBoyAdvance Information With different crt0/libraries, the same tool chain should also work for developing firmware for the VemsFrontier/ArmEfi boards. ---- == Building An ARM Cross-compiler Using The GNU Toolchain == In order to easily/quickly build binaries from C for the ARM processor, it's necessary to build a cross-compiler to run on a non-ARM machine (you can build natively if you've got the resources, but speaking as someone who has built all of XFree86 on a 200 MHz StrongARM, it sucks -- Alexander). Almost any desktop/workstation/server running Windos/Linux/*BSD/Mac OS X can host a cross-compiler, but it's a bit easier to get up and running under UNIX. [Devkitpro project] makes it a simpler process (tried with success on Linux and win32): * download devkitARM and libgba * cd /usr/local/arm-efi; unzip the downloaded tar.bz2 files: ** tar xjvf .... ** or bzip2 -d < .... | tar xvf - * export PATH=/usr/local/arm-efi/bin (set PATH=c:\pfiles\arm\bin on win32) * cd /tmp/gbatune; make While on linux you might be tempted to do the "compile yourself" method below, on win32 this is about your only choice to get going easily. All of the following was done under Linux (Debian/testing), but it can be easily applied to building the GNU toolchains on any other platform. === 1. Obtaining Source === Grab the following off of a GNU mirror of your choice (e.g. ftp.gnu.org): * binutils-2.13.2.1 (binutils-2.15 should work as well) * gcc-core-3.4.3 In order to get some semblance of libc support, you'll need to get newlib from sources.redhat.com: * newlib-1.13.0 Before we continue to build things, a couple assertions need to be made: * Our target name is 'arm-elf'. * Our installation prefix is going to be '/usr/local/arm-elf'. * We're going to configure/build our source separate from source. === 2. Setting Up The Source/Build Environment === Start by decompressing/extracting all of the source into one directory. Next, create empty build directories for each of the source packages: : > <code> drwxr-xr-x 15 alexander alexander 4096 Dec 27 16:32 binutils-2.15 -rw-r drwxr-xr-x 10 alexander alexander 4096 Dec 27 16:48 build.binutils drwxr-xr-x 7 alexander alexander 4096 Dec 27 17:01 build.gcc drwxr-xr-x 4 alexander alexander 4096 Dec 27 17:08 build.newlib drwxr-xr-x 11 alexander alexander 4096 Dec 27 17:00 gcc-3.4.3 -rw-r drwxr-xr-x 9 alexander alexander 4096 Dec 17 15:03 newlib-1.13.0 -rw-r </code> In order to not have to do the builds/installs as root, it's nice to make the base directory of the toolchain (i.e. /usr/local/arm-efi) a directory owned by your user. This avoids having to run configure scripts and make files as your super-user. After everything has been built/setup, you can change ownership over to whomever you feel is correct for your system (e.g. root). === 3. Configure/Build/Install binutils === Enter into your build.binutils directory, and execute the following: : > <code> ../binutils-2.15/configure --target=arm-elf --prefix=/usr/local/arm-elf </code> Next, run make, and then make install. To make sure the rest of your builds can now see your new tools, add /usr/local/arm-elf/bin to your PATH. In a Bourne-a-like shell (e.g. sh, or bash), you do something like: : > <code> PATH=$PATH:/usr/local/arm-elf/bin </code> === 4. Configure/Build/Install gcc === Inside build.gcc, execute the following: : > <code> ../gcc-3.4.3/configure --target=arm-elf --with-cpu=arm7tdmi --with-newlib --enabl e-multilib --enable-interwork --disable-threads --enable-targets=arm-elf --enable-la nguages=c --prefix=/usr/local/arm-elf </code> Now make and make install. === 5. Configure/Build/Install newlib === Inside build.newlib, execute the following: : > <code> ../newlib-1.13.0/configure --target=arm-elf --prefix=/usr/local/arm-elf </code> Again, make and make install. === 6. Test Out Your Creation === Open up your favorite editor, and edit a file called test.c: : > <code> int main(void) {return 0; }</code> Now compile/link this program with your new toolchain, and then verify the contents of the product: : > <code> alexander@midget:/tmp$ arm-elf-gcc armtest.c -o armtest alexander@midget:/tmp$ arm-elf-objdump -f armtest armtest: file format elf32-littlearm architecture: arm, flags 0x00000112: EXEC_P, HAS_SYMS, D_PAGED start address 0x00008110 </code> Rejoice, your compiler/linker worked. |