Trials, Tribulations and Toolchains

Edit: Future me, nearly 10 years later, says don’t bother attempting these steps unless you really have no alternative. My comment below about guides found on the net quickly becoming obsolete now applies to this post!

If you’re using Ubuntu or a derivative, then the arm-none-eabi-… toolchain is now in the repos, so can easily be installed with apt, and there’s even an m68k gcc cross compiler too.

<Historical content resumes…>

To build the OSD firmware for the Minimig projects, a cross-compilation environment is needed. Configuring GCC for this task can be an arcane process, and aspects tend to change from time to time, so guides found on the net quickly become obsolete. For instance, guides recommending the target “arm-elf” will fail with the latest GCC. Instead we need to use the target “arm-none-eabi”.

Here’s how I built a toolchain for building both M68K (Chameleon Minimig port) and ARM (Original Minimig and MiST) versions of the firmware:

Firstly I downloaded the latest versions of Binutils, GCC and Newlib. At the time of writing these were: Binutils 2.23.1, GCC 4.8.0 and Newlib 2.0.0.

Unpack all three tarballs into the same toplevel directory, then proceed as follows.
GCC is a bit of a special case when it comes to compiling. Rather than simply issuing the usual ./configure / make / make install commands from the toplevel directory, we have to create a target-specific build directory, and issue the configure command from within. (This is compulsory for GCC. It’s not compulsory for binutils, but a good idea nonetheless, since we’re going to be building for two different targets.)

cd binutils-2.23.1
mkdir arm-none-eabi
cd arm-none-eabi
../configure --target=arm-none-eabi --prefix=/opt/arm-none-eabi
make
sudo make install
cd ../../

Now we need to add the newly-compiled binutils to the PATH so they can be used when building GCC:

export PATH=/opt/arm-none-eabi/bin:$PATH

Before building GCC we need to link newlib into it, like so:

cd gcc-4.8.0
ln -s ../newlib-2.0.0/newlib .

Now we can make a directory to hold build files, and build GCC.

mkdir arm-none-eabi
cd arm-none-eabi
../configure --target=arm-none-eabi --prefix=/opt/arm-none-eabi --enable-languages=c --with-newlib
make
sudo make install
cd ../../

That’s all there is to it. The toolchain is now complete enough to build the firmware for the MiST project. At the time of writing the makefile needs one small adjustment; it assumes that the toolchain has been built with the target “arm-elf” – but as mentioned earlier that target is no longer available, so just change the first line of the Makefile to read:
BASE = arm-none-eabi

If we want an m68k toolchain the steps are almost identical:

cd binutils-2.23.1
mkdir m68k-elf
cd m68k-elf
../configure --target=m68k-elf --prefix=/opt/m68k-elf
make
sudo make install

export PATH=/opt/m68k-elf/bin:$PATH


cd ../../gcc-4.8.0
# I assume you've already linked newlib in by this point, but if not:
# ln -s ../newlib-2.0.0/newlib .
mkdir m68k-elf
cd m68k-elf
../configure --target=m68k-elf --prefix=/opt/m68k-elf --enable-languages=c --with-newlib
make
sudo make install

The only other thing needed for the m68k is VASM, which you can find here.

3 thoughts on “Trials, Tribulations and Toolchains

Leave a Reply

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