Appendix 3. Building the GNU Software Tools

This appendix shows how to build the ARM-targeted (arm-elf) GNU software tools (gcc, binutils, gdb, newlib) used in this book. The instructions are for both Windows (running Cygwin) and Linux host operating systems.

Warning

Unless there is some specific reason for building a new set of GNU tools, we recommend you use the prebuilt GNU binaries provided on the book’s web site and included on the Arcom board’s CD-ROM. The installation of the prebuilt tools is covered in Appendix B and Appendix E, respectively.

Approximately 1.2 GB of disk space is needed for the GNU tools source code and build output directories. These instructions are adapted from the web page “Building a toolchain for use with eCos,” found online at http://ecos.sourceware.org.

Another popular site for building cross development tools is found online at http://kegel.com/crosstool. This site contains instructions and numerous scripts for building various GNU cross development tool chains for various processors and host systems. You might find that the tools on this site suit your needs better.

The following steps should be followed at a bash shell prompt in Cygwin or a terminal in Linux. We built the GNU tools under Windows XP (SP2) and Linux Fedora Core 5. These instructions locate the GNU tools’ source code under the /src directory, the build output under /tmp/build, and the resulting GNU tools under /opt/gnutools. In Windows, all of these subdirectories are contained under the main cygwin directory.

Extracting the Source Files

After downloading the gnutoolssrc.tar.gz file from the book’s web site, become superuser (root) and proceed as follows:

  1. Create a directory to contain the tool sources (avoid directory names containing spaces, as these can confuse the build system). Under Windows, this directory is contained under the cygwin directory. Under Linux, this directory is expected to be located under the root (/) directory.

  2. # mkdir -p /src
  3. Change to the newly created directory:

  4. # cd /src
  5. Copy the gnutoolssrc.tar.gz file to the src directory.

  6. Extract the sources from the compressed file, as shown here. This should create the following directories under src: binutils-2.15, gcc-3.4.4, gdb-6.3, and newlib-1.13.0.

  7. # tar xvzf gnutoolssrc.tar.gz
  8. Normally, you would apply any patches needed at this point; however, we have already applied the necessary patches to the source files. There is a patch utility to aid in applying patches.

Building the Toolchain

Now you need to compile the tools for your hardware and operating system:

  1. Before attempting to build the tools, ensure that the GNU native compiler tools directory is on the PATH and precedes the current directory.

  2. # PATH=/bin:$PATH ; export PATH
  3. Configure the GNU binary utilities ( binutils):

  4. # mkdir -p /tmp/build/binutils
    # cd /tmp/build/binutils
    # /src/binutils-2.15/configure --target=arm-elf \
                      --prefix=/opt/gnutools/arm-elf -v 2>&1 | tee configure.out
  5. The resulting output is contained in the file configure.out. If there are any problems configuring the tools, refer to this file.

  6. Build and install the GNU binutils (this step may take an especially long time):

  7. # make -w all install 2>&1 | tee make.out
  8. The resulting output is contained in the file make.out. If there are any problems building the tools, refer to this file.

  9. Ensure that the binutils are at the head of the PATH:

  10. # PATH=/opt/gnutools/arm-elf/bin:$PATH ; export PATH
  11. Configure gcc:

  12. # mkdir -p /tmp/build/gcc
    # cd /tmp/build/gcc
    # /src/gcc-3.4.4/configure --target=arm-elf \
                      --prefix=/opt/gnutools/arm-elf --enable-languages=c,c++ \
                      --with-gnu-as --with-gnu-ld --with-newlib \
                      --with-gxx-include-dir=/opt/gnutools/arm-elf/arm-elf/include \
                      -v 2>&1 | tee configure.out
  13. Build and install gcc (this step may take an especially long time):

  14. # make -w all install 2>&1 | tee make.out
  15. Configure gdb:

  16. # mkdir -p /tmp/build/gdb
    # cd /tmp/build/gdb
    # /src/gdb-6.3/configure --target=arm-elf \
                      --prefix=/opt/gnutools/arm-elf --disable-nls \
                      -v 2>&1 | tee configure.out
  17. Build and install gdb (this step may take an especially long time):

  18. # make -w all install 2>&1 | tee make.out

Following the successful building and installation of the GNU tools, the associated build tree (located under /tmp/build) may be deleted to save space if necessary. The toolchain executable files directory (/opt/gnutools/arm-elf/bin) should be added to the head of your PATH.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.82.79