GNU cross tool chain (ARM-Linux-GCC 3.4.4)

Source: Internet
Author: User
Tags posix automake

Source: chinaunix blog Date: 2006.08.28

 

GNU cross tool chain (ARM-Linux-GCC 3.4.4)
Modified by litroncn (
Litroncn@163.com
)
Based on Sunhe (msunhe@gmail.com)

1. Working users and environments in Linux
1.1 Software Environment
Linux Ubuntu 6.06 lts
Kernel version BRL. 15-23-686
GCC version 4.0.3 (Ubuntu 4.0.3-1ubuntu5)
GNU make 3.81
Msgfmt (GNU gettext-tools) 0.14.5
Makeinfo (GNU texinfo) 4.8
GNU M4 1.4.4
Flex 2.5.31
GNU awk 3.1.5
Perl, v5.8.7
GNU sed version 4.1.4
Gettext (GNU gettext-runtime) 0.14.5
Autoconf (GNU Autoconf) 2.59
Automake (GNU automake) 1.4-P6
1.2 compile related configurations
1. Add a working user (under the root user)
Root @ ubuntu :~ # Useradd-G root-g root-d/home/arm
Root @ ubuntu :~ # Mkdir-p/home/arm
Root @ ubuntu :~ # Chown-R arm/home/arm
Root @ ubuntu :~ # Chmod-R 775/home/arm
2. Create a working directory (log in with an arm user)
Arm @ ubuntu :~ $ Mkdir dev_home
Arm @ ubuntu :~ $ Cd dev_home
Arm @ ubuntu :~ /Dev_home $ mkdir btools kernel
3. Start the environment variable at login (use the root user to log on)
Root @ ubuntu :~ # Vi ~ /. Bashrc
Add
Export PATH =/usr/local/arm/3.4.4/bin: $ PATH
Arm @ ubuntu :~ /Dev_home $

Log on to the arm user again, and the environment variables take effect.
Arm @ ubuntu :~ $ Su arm

2.Set environment variables, prepare source code and related patches
2.1 set Environment Variables
Arm @ ubuntu :~ $ Vi ~ /. Bashrc
Export PREFIX =/usr/local/arm/3.4.4
Export TARGET = arm-linux
Export SYSROOT =$ {PREFIX}/sysroot
Export ARCH = arm
Export CROSS_COMPILE =$ {TARGET }-
Export PATH =$ {PREFIX}/bin: $ PATH
Export SRC =/home/arm/dev_home/btools/tchain3.4.4
Note: If you have installed arm-linux-gcc and added it to environment variables, remove it from the environment to ensure that the root user and arm user environments do not contain arm-linux-gcc

2.2 prepare the source code package

2.2.1 binutils
Binutils-2.16.tar.gz name
Tar.gz
:
Http://ftp.gnu.org/gnu/binutils/binutils-2.16.tar.gz

2.2.2 gcc
Gcc-3.4.4.tar.bz2 name
:
Http://ftp.gnu.org/gnu/gcc/gcc-3.4.4/gcc-3.4.4.tar.bz2

2.2.3 glibc
Glibc-2.3.5.tar.gz name
Glibc-linuxthreads-2.3.5.tar.gz
:
Http://ftp.gnu.org/gnu/glibc/glibc-2.3.5.tar.gz

Http://ftp.gnu.org/gnu/glibc/glibc-linuxthreads-2.3.5.tar.gz

2.2.4 Linux Kernel
Linux-2.6.14.1.tar.bz2 name
:
Http://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.14.1.tar.bz2

2.2.5 GDB
Gdb-6.4.tar.gz name
:
Http://ftp.gnu.org/pub/gnu/gdb/gdb-6.4.tar.gz

2.3 prepare Patches
2.3.1 ioperm. C. Diff
Purpose: Call the corrected ioperm () function.
:
Http://frank.harvard.edu /~ Coldwell/toolchain/ioperm. C. Diff
2.3.2 flow. C. Diff
Purpose: modify a GCC bug.
:
Http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/flow.c.diff? Cvsroot = GCC & only_with_tag = CSL-arm-branch & R1 = 1.563.4.2 & r2 = 1.563.4.3

2.3.3 t-linux.diff
Purpose: This patch is used to generate crti. O and crtn. O files.
:
Http://frank.harvard.edu /~ Coldwell, toolchain, t-linux.diff

2.4 compile GNU binutils

Log on with an arm user again to make the newly set environment variables take effect.
Arm @ ubuntu :~ /Dev_home/btools/tchain3.4.4 $ tree-L 1
.
| -- BUILD
| -- Binutils-2.16
| -- Binutils-2.16.tar.gz
| -- Flow. c. diff
| -- Gcc-3.4.4
| -- Gcc-3.4.4.tar.bz2
| -- Gdb-6.4.tar.gz
| -- Glibc-2.3.5
| -- Glibc-2.3.5.tar.gz
| -- Glibc-linuxthreads-2.3.5.tar.gz
| -- Ioperm. c. diff
| -- Linux-2.6.14.1.tar.bz2
'-- T-linux.diff
Arm @ ubuntu :~ $ Su arm
Arm @ ubuntu :~ $ Cd $ {SRC}
Arm @ ubuntu :~ /Dev_home/btools/tchain3.4.4 $ tar zxvf binutils-2.16.tar.gz
Arm @ ubuntu :~ /Dev_home/btools/tchain3.4.4 $ mkdir-p BUILD/binutils-2.16
Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4 $ CD build/binutils-2.16
Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/binutils-2.16 $ .. /.. /binutils-2.16/configure -- prefix =$ {prefix} -- target =$ {target} -- With-sysroot =$ {sysroot}
Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/binutils-2.16 $ make
Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/binutils-2.16 $ su Root
Root @ Ubuntu:/home/ARM/dev_home/btools/tchain3.4.4/build/binutils-2.16 # make install
Root @ Ubuntu:/home/ARM/dev_home/btools/tchain3.4.4/build/binutils-2.16 # exit
Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/binutils-2.16 $

2.5 prepare the kernel header file
2.5.1 use the GCC of the current platform to compile the kernel header file
Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/binutils-2.16 $ CD $ {kernel}
Arm @ Ubuntu :~ /Dev_home/kernel $
Arm @ Ubuntu :~ /Dev_home/kernel $ tar jxvf ../btools/tchain3.4.4/linux-2.6.14.1.tar.bz2
Arm @ Ubuntu :~ /Dev_home/kernel $ CD linux-2.6.14.1/
Arm @ Ubuntu :~ /Dev_home/kernel/linux-2.6.14.1 $ cp arch/ARM/configs/smdk2410_defconfig. config
I use S3C2410 as the CPU and select a configuration file smdk2410_defconfig. You can select
Arm @ Ubuntu :~ /Dev_home/kernel/linux-2.6.14.1 $ Make arch = arm menuconfig
System type --->
Arm system type (Samsung S3C2410) --->
S3c24xx implementations --->
[] Simtec electronics Anubis
[] Simtec electronics BASt (eb2410itx)
[] Ipaq h1940
[] Acer N30

  • SMDK2410/A9M2410
    [] SMDK2440
    [] Thorcom VR1000
    [] HP iPAQ rx3715
    [] NexVision OTOM Board
    [] NexVision NEXCODER 2440 Light Board
    --- S3C2410 boot
    --- S3C2410 setup
    [] S3C2410 DMA support
    (0) S3C2410 UART to use for low-level messages
    --- Processor type
    --- Processor features
  • Support Thumb user binaries
    [] Disable I-Cache
    [] Disable D-Cache
    [] Force write through D-Cache
    Exit
    Do you wish to save your new Kernel configuration?
    No>
    Select Yes
    Arm @ Ubuntu :~ /Dev_home/kernel/linux-2.6.14.1 $ make

    2.5.2 copy the kernel header file
    Arm @ Ubuntu :~ /Dev_home/kernel/linux-2.6.14.1 $ su Root
    Root @ Ubuntu:/home/ARM/dev_home/kernel/linux-2.6.14.1 # mkdir-p $ {sysroot}/usr/include
    Root @ Ubuntu:/home/ARM/dev_home/kernel/linux-2.6.14.1 # cp-A include/Linux $ {sysroot}/usr/include/Linux
    Root @ Ubuntu:/home/ARM/dev_home/kernel/linux-2.6.14.1 # cp-A include/ASM-arm $ {sysroot}/usr/include/ASM
    Root @ Ubuntu:/home/ARM/dev_home/kernel/linux-2.6.14.1 # cp-A include/ASM-generic $ {sysroot}/usr/include/ASM-generic
    Root @ Ubuntu:/home/ARM/dev_home/kernel/linux-2.6.14.1 # exit
    Arm @ Ubuntu :~ /Dev_home/kernel/linux-2.6.14.1 $

    2.6 compile the glibc header file
    Arm @ Ubuntu :~ /Dev_home/kernel/linux-2.6.14.1 $ CD $ {SRC}
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4 $ tar zxvf glibc-2.3.5.tar.gz
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4 $ patch-D glibc-2.3.5-p1
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4 $ CD glibc-2.3.5
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/glibc-2.3.5 $ tar zxvf ../glibc-linuxthreads-2.3.5.tar.gz
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/glibc-2.3.5 $ CD ..
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4 $ mkdir-P build/glibc-2.3.5-headers
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4 $ CD build/glibc-2.3.5-headers/
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/glibc-2.3.5-headers $ .. /.. /glibc-2.3.5/configure -- prefix =/usr -- Host =$ {target} -- enable-add-ons = linuxthreads -- With-headers =$ {sysroot}/usr/include
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/glibc-2.3.5-headers $ su Root
    Root @ Ubuntu:/home/ARM/dev_home/btools/tchain3.4.4/build/glibc-2.3.5-headers # make cross-compiling = Yes install_root =$ {sysroot} install-headers
    Root @ Ubuntu:/home/ARM/dev_home/btools/tchain3.4.4/build/glibc-2.3.5-headers # Touch $ {sysroot}/usr/include/GNU/stubs. h
    Root @ Ubuntu:/home/ARM/dev_home/btools/tchain3.4.4/build/glibc-2.3.5-headers #
    Touch $ {sysroot}/usr/include/bits/stdio_lim.h
    Root @ Ubuntu:/home/ARM/dev_home/btools/tchain3.4.4/build/glibc-2.3.5-headers # exit
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/glibc-2.3.5-headers $

    2.7 first stage of GCC Compilation
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/glibc-2.3.5-headers $ CD $ {SRC}
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4 $ tar jxvf gcc-3.4.4.tar.bz2
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4 $ patch-D gcc-3.4.4-p1
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4 $ patch-D gcc-3.4.4-p1
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4 $ mkdir-P build/gcc-3.4.4-stage1
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4 $ CD build/gcc-3.4.4-stage1/
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/gcc-3.4.4-stage1 $ .. /.. /gcc-3.4.4/configure -- prefix =$ {prefix} -- target =$ {target} -- enable-versions = c -- With-sysroot =$ {sysroot}
    Note: -- disable-shared cannot be added.
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/gcc-3.4.4-stage1 $ make all-gcc
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/gcc-3.4.4-stage1 $ su Root
    Root @ Ubuntu:/home/ARM/dev_home/btools/tchain3.4.4/build/gcc-3.4.4-stage1 # make install-gcc
    Root @ Ubuntu:/home/ARM/dev_home/btools/tchain3.4.4/build/gcc-3.4.4-stage1 # exit
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/gcc-3.4.4-stage1 $

    2.8 complete glibc Compilation
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/gcc-3.4.4-stage1 $ CD $ {SRC}
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4 $ mkdir-P build/glibc-2.3.5
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4 $ CD build/glibc-2.3.5
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/glibc-2.3.5 $ build_cc = gcc cc =$ {cross_compile} GCC ar =$ {cross_compile} ar ranlib =$ {cross_compile} ranlib as =$ {cross_compile} as LD =$ {cross_compile} lD .. /.. /glibc-2.3.5/configure -- prefix =/usr -- Build = i386-ubuntu-linux -- Host = arm-unknown-Linux-GNU -- target = arm-unknown-Linux-GNU -- without-_ thread -- enable-add-ons = linuxthreads -- With-headers =$ {sysroot}/usr/include
    Note:
    -- Prefix: Specifies the installation path.
    -- Target: Specify the target platform.
    -- Host: Specifies the current platform.
    -- Build: Specify the compilation platform.
    -- With-sysroot: Specifies the header file and link library required for compilation.
    -- Enable-add-ons: add other libraries, such as the thread library.
    -- Enable-languages ages: Specifies the language supported by GCC.
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/glibc-2.3.5 $ make
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/glibc-2.3.5 $ su Root
    Root @ Ubuntu:/home/ARM/dev_home/btools/tchain3.4.4/build/glibc-2.3.5 # Make install_root =$ {sysroot} install
    Root @ Ubuntu:/home/ARM/dev_home/btools/tchain3.4.4/build/glibc-2.3.5 # exit
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/glibc-2.3.5 $

    2.9 compile the complete gcc
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/glibc-2.3.5 $ CD $ {SRC}
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4 $ mkdir-P build/gcc-3.4.4
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4 $ CD build/gcc-3.4.4
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/gcc-3.4.4 $ .. /.. /gcc-3.4.4/configure -- prefix =$ {prefix} -- target =$ {target} -- With-sysroot =$ {sysroot} -- disable-NLS -- enable-threads = POSIX -- enable- symvers = GNU -- enable-_ cxa_atexit -- With-softfloat-support = internal -- enable-versions ages = C, c ++ -- enable-shared -- enable-c99 -- enable-Long-long
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/gcc-3.4.4 $ make
    Arm @ ubuntu :~ /Dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4 $ su root
    Root @ ubuntu:/home/arm/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4 # make install
    Root @ ubuntu:/home/arm/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4 # exit
    Arm @ ubuntu :~ /Dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4 $
    Arm @ ubuntu :~ /Dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4 $ arm-linux-gcc-v
    Reading specs from/usr/local/arm/3.4.4/lib/gcc/arm-linux/3.4.4/specsConfigured :.. /.. /gcc-3.4.4/configure -- prefix =/usr/local/arm/3.4.4 -- target = arm-linux -- with-sysroot =/usr/local/arm/3.4.4/sysroot -- disable-nls -- enable-threads = posix -- enable-symvers = gnu -- enable-_ cxa_atexit -- with-softfloat-support = internal -- enable-versions ages = c, c ++ -- enable-shared -- enable-c99 -- enable-long
    Thread model: posix
    Gcc version 3.4.4
    Arm @ ubuntu:/usr/local/arm/3.4.4 $ tree-L 1
    .
    | -- Arm-Linux
    | -- Bin
    | -- Include
    | -- Info
    | -- Lib
    | -- Libexec
    | -- Man
    | -- Share
    '-- Sysroot
    Arm @ Ubuntu:/usr/local/ARM/3.4.4 $ Du-SH
    193 m.
    Arm @ Ubuntu:/usr/local/ARM/3.4.4/bin $ ls
    Arm-linux-addr2line arm-Linux-C ++ filt arm-linux-gcc-3.4.4 arm-Linux-nm arm-Linux-readelf
    Arm-Linux-ar arm-Linux-CPP arm-Linux-gccbug arm-Linux-objcopy arm-Linux-size
    Arm-Linux-as arm-Linux-G ++ arm-Linux-gcov arm-Linux-objdump arm-Linux-strings
    Arm-Linux-C ++ arm-Linux-GCC arm-Linux-LD arm-Linux-ranlib arm-Linux-strip

    2.10 test GCC, G ++
    Arm @ Ubuntu :~ $ VI hello_c.c
    # Include
    # Include
    Int main ()
    {
    Printf ("Hello, world ~ /N ");
    Return 0;
    }
    Arm @ Ubuntu :~ $ VI hello_cpp.cpp
    # Include
    Using STD: cout;
    Using STD: Endl;
    Int main ()
    {
    Cout
    Return 0;
    }
    Arm @ Ubuntu :~ $ Arm-Linux-GCC hello_c.c-O hello_c
    Arm @ Ubuntu :~ $ Arm-Linux-G ++-O hello_cpp hello_cpp.cpp
    Arm @ ubuntu :~ $ Tree-L 1
    .
    | -- Dev_home
    | -- Hello_c
    | -- Hello_c.c
    | -- Hello_cpp
    '-- Hello_cpp.cpp

    1 directory, 4 files
    Arm @ ubuntu :~ $ File hello_c
    Hello_c: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.0.0, dynamically linked (uses shared libs), for GNU/Linux 2.0.0, not stripped
    Arm @ ubuntu :~ $ File hello_cpp
    Hello_cpp: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.0.0, dynamically linked (uses shared libs), for GNU/Linux 2.0.0, not stripped

    2.11 compile gdb running on the host
    Arm @ ubuntu :~ /Dev_home/btools/tchain3.4.4 $ tar zxvf gdb-6.4.tar.gz
    Arm @ ubuntu :~ /Dev_home/btools/tchain3.4.4 $ mkdir-p BUILD/gdb-6.4-host
    Arm @ ubuntu :~ /Dev_home/btools/tchain3.4.4 $ cd BUILD/gdb-6.4-host
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/gdb-6.4-host $ export cc = gcc
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/gdb-6.4-host $.../gdb-6.4/configure -- target = arm-Linux
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/gdb-6.4-host $ make
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/gdb-6.4-host $ file GDB/GDB
    GDB/GDB: Elf 32-bit LSB executable, Intel 80386, Version 1 (sysv), for GNU/Linux 2.2.0, dynamically linked (uses SHARED libs), for GNU/Linux 2.2.0, not stripped

    2.12 create a gdbserver running on the target platform
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/gdb-6.4-host $ mkdir-P ../gdbserver-6.4
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/gdb-6.4-host $ CD ../gdbserver-6.4
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/gdbserver-6.4 $ export cc =/usr/local/ARM/3.4.4/bin/ARM-Linux-gcc
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/gdbserver-6.4 $.../gdb-6.4/GDB/gdbserver/configure -- Host = arm-Linux
    Arm @ Ubuntu :~ /Dev_home/btools/tchain3.4.4/build/gdbserver-6.4 $ make
    Arm @ Ubuntu :~ // Dev_home/btools/tchain3.4.4/build/gdbserver-6.4 $ file gdbserver
    Gdbserver: Elf 32-bit LSB executable, arm, Version 1 (ARM), for GNU/Linux 2.0.0, dynamically linked (uses SHARED libs), for GNU/Linux 2.0.0, not stripped

    3 download the GNU cross tool chain
    Tool chain official:
    Http://www.arm.linux.org.uk/
    You can download tool chains 2.95.3, 3.0, and 3.2 from this site.
    Ftp://ftp.arm.linux.org.uk/pub/armlinux/toolchain/cross-2.95.3.tar.bz2
    Ftp://ftp.arm.linux.org.uk/pub/armlinux/toolchain/cross-3.0.tar.bz2

    Ftp://ftp.handhelds.org/projects/toolchain/arm-linux-gcc-3.3.2.tar.bz2
    Ftp://ftp.handhelds.org/projects/toolchain/arm-linux-gcc-3.4.1.tar.bz2
    Http://ftp.snapgear.org/pub/snapgear/tools/arm-linux/gcc-3.4.4.tar.bz2

  • ��

    Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.