This document shows you how to compile and install the GNU Tools for
the ARM microcontroller under the Linux or Unix operating systems. Please
note that it is much easier to install the precompiled binary image for
Linux (as found on this CD-ROM). If you do choose to recompile the
GNU Tools, as explained in this document, expect to spend about three
hours doing so (depending, of course, on the speed of your machine).
In order to successfully compile, install and run the GNU Tools, you
will need to meet at least the following requirements:
Compiling and installing 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 you have
already mounted the CD-ROM on your computer, and that the mount
point (where the CD-ROM can be found within the file system) is /mnt/cdrom. See the instructions for mounting
the CD-ROM for more details.
1. |
Log in as an ordinary user, not as the root superuser. This is
highly recommended and is standard Unix practice. In fact, you should
never directly log in as the root superuser; this helps save you
from your own mistakes and/or any viruses that can destroy the working of
your system! |
2. |
Create a directory to contain the sources. Note that at least
740 MB of space is required for both the source code and build files.
In this document, /var/tmp/src will be used for
the sources: |
|
$ | mkdir /var/tmp/src |
$ | cd /var/tmp/src |
|
3. |
Locate the appropriate sources, either on this CD-ROM, or by downloading the source code archives from the
Internet. Assuming the CD-ROM is mounted on /mnt/cdrom, the source code archives can be found in /mnt/cdrom/gnutools/src. |
4. |
Unpack the sources: |
|
$ | gzip -dc /mnt/cdrom/gnutools/src/binutils-2.14.tar.gz | tar xv |
$ | gzip -dc /mnt/cdrom/gnutools/src/gcc-core-3.3.tar.gz | tar xv |
$ | gzip -dc /mnt/cdrom/gnutools/src/gcc-g++-3.3.tar.gz | tar xv |
$ | gzip -dc /mnt/cdrom/gnutools/src/insight-5.3.tar.gz | tar xv |
$ | gzip -dc /mnt/cdrom/gnutools/src/newlib-1.11.0.tar.gz | tar xv |
|
|
If your version of tar is compatible with GNU tar, you can use
tar xzvf ... instead of gzip -dc ... | tar xv: this
will save a couple of minutes… |
|
If you are using sources that you downloaded from the Internet,
you would replace /mnt/cdrom/gnutools/src with the
location of those sources, of course. Archives having .tar.gz on the end of their filename require GNU gzip;
those with .tar.bz2 require
bzip2 . |
5. |
Apply the appropriate patches (on this CD-ROM, or from the Internet) to the sources: |
|
$ | gzip -dc /mnt/cdrom/gnutools/src/binutils-2.14.patch.gz | patch -p0 |
$ | gzip -dc /mnt/cdrom/gnutools/src/gcc-3.3.patch.gz | patch -p0 |
$ | gzip -dc /mnt/cdrom/gnutools/src/insight-5.3.patch.gz | patch -p0 |
$ | gzip -dc /mnt/cdrom/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. |
6. |
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 |
|
7. |
Configure the binutils package: |
|
$ | cd /var/tmp/build/binutils-2.14 |
$ | /var/tmp/src/binutils-2.14/configure --target=arm-elf |
|
8. |
Compile the binutils package: |
|
|
9. |
As the root superuser, install the compiled binutils
package. You will need the root superuser’s password: |
|
|
10. |
Still as the root superuser, create some destination directories
and give everyone (temporary) write access to them: |
|
# | cd /usr/local/arm-elf |
# | mkdir sys-include |
# | ln -s sys-include include |
# | chmod g+w,o+w sys-include |
# | cd /usr/local/lib |
# | mkdir gcc-lib gcc-lib/arm-elf |
# | chmod g+w,o+w gcc-lib/arm-elf |
# | exit |
|
11. |
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 |
|
12. |
Compile the gcc package: |
|
|
13. |
As the root superuser, install the compiled gcc
package and remove the write permissions granted in step 10: |
|
|
|
# | cd /usr/local/arm-elf |
# | rm -fr include sys-include |
# | cd /usr/local/lib/gcc-lib/arm-elf |
# | chown -R root:root . |
# | chmod g-w,o-w . |
# | exit |
|
14. |
Configure the newlib package: |
|
$ | cd /var/tmp/build/newlib-1.11.0 |
$ | /var/tmp/src/newlib-1.11.0/configure --target=arm-elf |
|
15. |
Compile the newlib package: |
|
|
16. |
As the root superuser, install the compiled newlib
package: |
|
$ | /bin/su |
# | make install |
# | exit |
|
17. |
Configure insight . This package requires the X11
Window System header files and libraries: |
|
$ | cd /var/tmp/build/insight-5.3 |
$ | /var/tmp/src/insight-5.3/configure --target=arm-elf |
|
18. |
Compile the insight package: |
|
|
19. |
As the root superuser, install the compiled insight
package: |
|
|
20. |
Still as the root superuser, clean up a number of installation
issues and reduce the size of the final installation: |
|
# | cd /usr/local/bin |
# | strip arm-elf-* |
# | cd /usr/local/lib/gcc-lib/arm-elf/3.3 |
# | strip cc1 cc1plus collect2 cpp0 tradcpp0 |
# | exit |
|
21. |
(Optional) Remove the source code and build files to reclaim about
740 MB of disk space (the final binaries take about 110 MB of
space): |
|
$ | cd /var/tmp |
$ | rm -fr src build |
|
22. |
You have successfully compiled and installed the GNU Tools for the
ARM microcontroller! |
In most cases, you will not encounter any problems in compiling and
installing the GNU Tools. There might be exceptions, however. You should
check the following if a compilation (a “make all”
step) terminates with an error:
If all your efforts fail to get the GNU Tools compiled and installed
(and you have tried and failed with the combined sources method), either install the precompiled binary image,
search the Internet for answers or consult your local Linux/Unix guru!