Compile for the PhatBox

From PhatHack Wiki
Revision as of 15:04, 16 June 2005 by Bushing (talk | contribs)
Jump to navigation Jump to search

Here are some notes on how to compile C programs to run on the PhatBox. It's from memory, so some of the details may be slightly wrong -- please edit this page if you have any corrections. --bushing

Cross-Compiler

Build a cross-compiler for ARM. The PhatBox guys used gcc-2.95.3, so that's what I used.

The crosstool utility makes this very easy under Unix-like systems. The configuration files I used were:

arm.dat

KERNELCONFIG=`pwd`/arm.config
GCC_EXTRA_CONFIG="--with-cpu=arm7tdmi --enable-cxx-flags=-mcpu=arm7tdmi"
TARGET=arm-linux
TARGET_CFLAGS="-Os"
GLIBC_EXTRA_CONFIG=--enable-omitfp

demo-arm.sh

#!/bin/sh
set -ex
TARBALLS_DIR=$HOME/downloads
RESULT_TOP=/opt/crosstool
export TARBALLS_DIR RESULT_TOP
GCC_LANGUAGES="c,c++"
export GCC_LANGUAGES
eval `cat arm.dat gcc-2.95.3-glibc-2.1.3.dat` sh all.sh --notest


libc

In order to actually compile programs, you also need a libc (c library). Crosstool will build you a glibc, but none of the programs I compiled with it actually worked.

So, I turned to diet libc - a libc optimized for small size. I found that I had to first make a version for i386 (to get the build-i386/diet program), and then I could build a version for arm. IE:

$ make
$ make arm

You will then have a program called diet in the bin-i386 directory. Copy this into your path, and then you can build programs for the PhatBox by running

$ diet arm-linux -o hello hello.c

(this is a GCC wrapper)