Compiling and Packaging the GNU Tools under Microsoft Windows

This document shows you how to compile and package the GNU Tools for the ARM microcontroller under Microsoft Windows. Doing this creates the .tar.gz package used for the standard precompiled binary image installation for Microsoft Windows. It does not generate the GNU Tools documentation: that is covered in the packaging instructions for Linux.

Please note that you probably do not need to read this document: it is much easier to install the precompiled binary image for Windows (as found on this CD-ROM). These instructions should really only be followed by system administrators wanting to retain complete control of their system… or those wanting to update this CD-ROM.

In this document, something like “Start » Settings » Control Panel” means that you click on the Start button, select the Settings sub-menu and finally click on Control Panel. “$” will indicate the Cygwin shell prompt. Anything in a bold monospaced font is what you are expected to type in; an ordinary monospaced font is used for the computer’s response. Please note that this document doesn’t show every response from the computer!

Minimum System Requirements

In order to successfully compile the GNU Tools, you will need to meet at least the following requirements:

1. Microsoft Windows NT 4 or later (including Windows 2000, Windows XP Home and Windows XP Professional), or Windows 98SE, as your operating system,
2. A complete installation of the Cygwin Unix Emulator, as found on this CD-ROM,
3. At least 900 MB of free disk space (after Cygwin has been installed),
4. At least three to four hours of free time, and
5. If you are running Microsoft Windows NT, Windows 2000 or Windows XP Professional, the password for the Administrator account on your system.

Step-by-step Instructions

Compiling the GNU Tools is not that complicated (although there are rather a lot of steps), but be careful that you type in the commands exactly as shown. These instructions assume that this CD-ROM can be found as drive D: on your computer (/cygdrive/d within the Cygwin environment). If it is not, simply substitute the actual drive letter for the “d”. See the instructions for mounting the CD-ROM for more details.

1. If you are running Microsoft Windows NT, Windows 2000 or Windows XP Professional, log in as Administrator. If you are running Microsoft Windows XP Home or Windows 98SE, simply log in.
2. Start a Cygwin command line (usually by selecting Start » Programs » Cygwin » Cygwin Bash Shell).
3. Due to a number of limitations of Microsoft Windows and the Cygwin Unix Emulator, the final output will appear “in place” in /usr/local. This means, however, that this directory must be empty prior to compilation. The easiest way to do this is to enter:
rm -fr /usr/local/*
Please check before-hand that there is nothing in /usr/local that you wish to keep! If there is, you will need to move it to another directory; you can move it back in afterwards.
4. Create a directory to contain the sources. Note that at least 900 MB of space is required for the source code, build and installation files. In this document, /var/tmp/src will be used for the sources:
mkdir /var/tmp/src
cd /var/tmp/src
5. Locate the appropriate sources, either on this CD-ROM, or by downloading the source code archives from the Internet. Assuming the CD-ROM is available at /cygdrive/d, the source code archives can be found in [List] /cygdrive/d/gnutools/src.
6. Unpack the sources:
tar xzvf /cygdrive/d/gnutools/src/binutils-2.14.tar.gz
tar xzvf /cygdrive/d/gnutools/src/gcc-core-3.3.tar.gz
tar xzvf /cygdrive/d/gnutools/src/gcc-g++-3.3.tar.gz
tar xzvf /cygdrive/d/gnutools/src/insight-5.3.tar.gz
tar xzvf /cygdrive/d/gnutools/src/newlib-1.11.0.tar.gz
If you are using sources that you downloaded from the Internet, you would replace /cygdrive/d/gnutools/src with the location of those sources, of course. Archives having .tar.gz on the end of their filename require xzvf as the parameter to the tar command; those with .tar.bz2 require xjvf.
7. Apply the appropriate patches (on this CD-ROM, or from the Internet) to the sources:
gzip -dc /cygdrive/d/gnutools/src/binutils-2.14.patch.gz | patch -p0
gzip -dc /cygdrive/d/gnutools/src/gcc-3.3.patch.gz | patch -p0
gzip -dc /cygdrive/d/gnutools/src/insight-5.3.patch.gz | patch -p0
gzip -dc /cygdrive/d/gnutools/src/newlib-1.11.0.patch.gz | patch -p0
Please note that parts of these patches may not need to be applied to later versions of the GNU Tools. You are on your own if you decide to use versions of software different from those described in this document! However, you might like to see if later versions of the patches exist on the Internet before giving up.
8. Create a separate directory, with subdirectories, in which to build the sources. In this document, /var/tmp/build will be used:
mkdir /var/tmp/build
cd /var/tmp/build
mkdir binutils-2.14 gcc-3.3 insight-5.3 newlib-1.11.0
9. Configure the binutils package:
cd /var/tmp/build/binutils-2.14
/var/tmp/src/binutils-2.14/configure --target=arm-elf
Please note that you can (and probably should) specify compiler options on the command line. You can do this by specifying variable definitions in front of configure. The following command line, for example, enables both optimisation level 2 and debugging (the -O2 and -g compiler options, respectively):
CFLAGS="-O2 -g" /var/tmp/src/binutils-2.14/configure --target=arm-elf
If you do specify compiler options on the command line, you will need to do so for every other configure step as well (ie, steps 13, 16 and 19).
10. Compile the binutils package:
make all
11. Install the compiled binutils package:
make install
12. Create a temporary link to the header files:
cd /usr/local/arm-elf
mkdir sys-include
ln -s sys-include include
13. Configure the gcc package:
cd /var/tmp/build/gcc-3.3
/var/tmp/src/gcc-3.3/configure --target=arm-elf --with-newlib --with-headers=/var/tmp/src/newlib-1.11.0/newlib/libc/include
14. Compile the gcc package:
make all
15. Install the compiled gcc package and remove the link created in step 12:
make install
cd /usr/local/arm-elf
rm -fr include sys-include
16. Configure the newlib package:
cd /var/tmp/build/newlib-1.11.0
/var/tmp/src/newlib-1.11.0/configure --target=arm-elf
17. Compile the newlib package:
make all
18. Install the compiled newlib package:
make install
19. Configure the insight package:
cd /var/tmp/build/insight-5.3
/var/tmp/src/insight-5.3/configure --target=arm-elf
20. Compile the insight package:
make all
21. Install the compiled insight package:
make install
22. Create the final package directory. In this document, /var/tmp/final will be used:
mkdir /var/tmp/final
23. Change to the root directory and create the package file. You should substitute date with an appropriate date, such as 2003-06:
cd /
tar cvf /var/tmp/final/arm-elf-gnutools-win32-date.tar usr/local
cd /var/tmp/final
gzip -9 arm-elf-gnutools-win32-date.tar
24. Create the uninstallation program, using the mkuninst script found on the CD-ROM:
/cygdrive/d/utils/unsw/src/mkuninst -F arm-elf-gnutools-win32-date.tar.gz
25. (Optional) Remove the source code and build files to reclaim about 620 MB of disk space (the binaries installed into /usr/local take about 125 MB of space; the final package requires about 35 MB):
cd /var/tmp
rm -fr src build
26. You have successfully compiled the GNU Tools for the ARM microcontroller! You can find the final package file in the /var/tmp/final directory.

Common Problems

In most cases, you will not encounter any problems in compiling the GNU Tools. There might be exceptions, however. The following is a list of things you should check if a compilation (a “make all” step) terminates with an error:

1. Check that you entered all commands exactly as specified. Please note that your browser may split up commands over a number of lines (depending on the width of your browser window); that does not mean you do the same! Each shell prompt (“$”) indicates a single command line.
2. If the compilation of gcc aborts mid-way with multiple error messages, including one about “No such file or directory” (or something similar, about a non-existant header file), you may need to check if the symbolic link you created in step 12 still exists. Simply jump back to step 12 and ignore any errors from the mkdir and/or ln commands in that step.
3. If you get the error message about cygpath.exe complaining that it “can’t create title mutex” during the configuration of insight in step 19, and the process seems to hang, then you need to modify two configuration files. Press CTRL+C to get back to the Cygwin prompt. Next, use VI to change line 1349 of /var/tmp/src/insight-5.3/tcl/win/configure from “cyg_conftest=`$CYGPATH $conftest`” to “cyg_conftest=C:\\cygwin\\tmp\\conftest.rc”. Now do the same to line 1351 of /var/tmp/src/insight-5.3/tk/win/configure. Now, jump back to step 19. These instructions assume, of course, that you have installed the Cygwin Unix Emulator in the C:\cygwin directory. If you continue to have problems, consult expert help.

If none of these suggestions help you, it is probably time to search for answers on the Internet, or to consult expert help. Happy compiling!