ColdFire Techniques

Building ColdFire GNU C with Windows NT

Building a GNU C cross-compiler using Windows NT is a fairly complex task much more so that the equivalent unix build. You must follow the instructions quite carefully as it is quite easy to make a mistake. If at all possible I would recommend finding a binary build of the compiler for NT/95/98 systems. Occasionally it will not be possible to find a suitable compiler binaries and you need to build your own. This guide explains the process I currently use. The build conststs of 3 main stages.

Many thanks to Paul Breed, Matt Minnis, Geoffroy Montel and Rick Haubenstricker for helping debug these instructions.

Downloading Everything

There is quite a lot to download to get a compiler build going. At the end you will have a pretty complete unix emulation layer capable of targeting partically any 32-bit micro-processor. Try to pick a local mirror otherwise things will be really slow.

You will need:

You will also need the following patches:

Installing Cygwin32 B20.1

This section describes the process of installing the version Beta 20.1 of the Cygwin environment. It assumes that this toolset is installed in a directory referred to as c:\unix.

Execute full.exe. These instructions assume that you install Cygwin under the c:\unix\cygnus\cygwin-b20 directory.

Execute Cygwin.bat (either on the start menu or under c:\unix\cygnus\cygwin-b20).

At this point, you are at the command line of "bash", a Unix-like shell. You have to mount the "/" directory. Type:

umount /
mount -b c:\\unix /

Note the use of two \s when specifying DOS paths in bash.

Create the /bin, /tmp, /source and /build directories.

mkdir /bin
mkdir /tmp
mkdir /source
mkdir /build
mkdir /build/binutils
mkdir /build/egcs
mkdir /build/texinfo

The light ash shell provided with Cygwin B20.1 is buggy. You should copy it to a fake name and copy bash.exe to sh.exe:

cd /cygnus/cygwin-b20/H-i586-cygwin32/bin
mv sh.exe old_sh.exe
cp bash.exe sh.exe

The Bourne shell has to be present in /bin directory to run shell scripts properly:

cp /cygnus/cygwin-b20/H-i586-cygwin32/bin/sh.exe /bin
cp /cygnus/cygwin-b20/H-i586-cygwin32/bin/bash.exe /bin

Copy the updated make.exe from make-3.77.zip over the top of the existing one in /cygnus/cygwin-b20/H-i586-cygwin32/bin/

Edit the c:\coldfire\cygnus\cygwin-b20\cygnus.bat file and add the following lines:

SET CYGWIN=binmode
SET HOME=/home

This makes Cygwin pipes 8 bit clean and sets your unix home directory(~) to /home which is necessary for some programs.

At this point, you have a native installation of Cygwin32 and are ready to proceed to building a cross-compiler. Remember to restart all your Cygwin windows!

Unpacking Everything

In /source unpack binutils-2.9.1, egcs-1.1.2 and newlib-1.8.1:

cd /source
tar -xzvf //e/download/files/binutils-2.9.1.tar.gz
tar -xzvf //e/download/files/egcs-1.1.2.tar.gz
tar -xzvf //e/download/files/newlib-1.8.1.tar.gz

Now we apply all of the patches:

cd /source/binutils-2.9.1
gzip -cd //e/download/files/binutils-2.9.1-coldfire-990206.diff.gz | patch -p1 --binary
cd /source/egcs-1.1.2
gzip -cd //e/download/files/egcs-1.1.1-coldfire-990207.diff.gz | patch -p1 --binary

Installing makeinfo

This step is optional as there is currently no method of viewing the GNU Info files that makeinfo produces from the compiler documentation. The compiler build expects to find it on the system though. The same technique can be used to build and install most GNU utility programs for Cygwin.

cd /build/texinfo
/source/egcs-1.1.2/texinfo/configure --prefix=/cygnus/cygwin-b20 --exec-prefix=/cygnus/cygwin-b20/H-i586-cygwin32
make all install

Building Binutils

To build binutils (linker, assembler and other object file utils) we must first go to /build/binutils and configure the tools.

cd /build/binutils
/source/binutils-2.9.1/configure --target=m68k-coff --prefix=/gcc-m68k -verbose

and build and install the compiler

make all install

The make all should complete without any errors. If there are errors recheck the steps above and delete your build directory contents before retrying. If they persist then drop me an email with a full log (make all install > my.log 2>&1) and I'll see what I can do.

After you have installed the tools you must put them in the PATH so they can be picked up. Edit c:\unix\cygnus\cygwin-b20\cygwin.bat appropriately. Restart bash/Cygwin for this change to take effect.

Test that you can run the m68k/ColdFire assembler. Running:

m68k-coff-as --version 

should return:

GNU assembler 2.9.1
Copyright 1997 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License.  This program has absolutely no warranty.
This assembler was configured for a target of `m68k-coff'.

Building the EGCS compiler

Remove the following directories (we cannot use Fortran or Objective-C as Cygwin cross-compilers):

/source/egcs-1.1.2/libf2c
/source/egcs-1.1.2/gcc/objc
/source/egcs-1.1.2/gcc/f

In order to build the compiler properly you must build the newlib C library at the same time. To do this we symbolicly link the following directories from Newlib to the main EGCS directory:

cd /source/egcs-1.1.2
ln -s ../newlib-1.8.1/newlib newlib
ln -s ../newlib-1.8.1/libgloss libgloss

Change to the /build/egcs directory to configure the compiler:

/source/egcs-1.1.2/configure --verbose --target=m68k-coff --prefix=/gcc-m68k --with-newlib

Compile the toolset as follows:

make cross

You must do a make cross (not a simple make) to insure that the different packages are built in the correct order. Making the compiler can take several hours even on fairly fast machines, beware.

Install with the following command:

make install

With any luck, at this point you having a working cross-compiler.

Although you need to use the Cygwin/bash shell to build the compiler you will not need to have Cygwin installed to use the finished compiler. I usually copy cygwinb1.dll and a few other useful utils (make, diff, patch, etc) for Cygwin into the /gcc-m68k/bin directory.

Congratulations!

[Home]

Copyright (c) 1997-98 David J. Fiddes.