Beruflich Dokumente
Kultur Dokumente
dungnb@techburgcorp.com
March -2011 .
Table of contents
I. PREFACE .................................................................................................................................................... 3
IV. SUMMARY............................................................................................................................................ 29
V. RESOURCES............................................................................................................................................. 29
I. Preface
Learn how to build a custom Linux distribution to use in an embedded environment, in this case
to drive a ARM – AT91 Versatile single-board computer. This document notes the experiences
about cross-compiling, cross-compiler, file systems, the root file system for ARM system, all of
technique that’s used in this document is mainly based on the book “CLFS-1.0.0 for MIPS” and
the all version of packages are based on “CLFS-ARM-systemroot” on website “ www.cross-
clfs.org”
On the ARM architecture, there are two major ABI types to choose from: EABI and OABI.
There is also a Thumb ABI and an Intel IWMMX specific ABI.
The EABI (Embedded ABI) is newer and supports additional features, faster software floating
point operations, and Thumb interworking, but is only compatible with ARMv4t and newer
cores. The EABI has sub-ABIs of: aapcs-linux and aapcs. aapcs-linux has standard Linux 4 byte
enums while aapcs has variable length enums.
The OABI (old ABI) is called apcs-gnu and supports ARMv4 and older cores.
During the building of the cross-compile tools, you will need to set a few variables that will be
dependent on your particular needs. You will need to select the target triplet for the target
architecture, the CPU endianess, the CPU architecture, the CPU mode, the CPU floating point
hardware availability, and (if available) the type of floating point hardware. If you do not know
what values can be chosen for each of these, you can use the tables at the bottom of this page as a
reference.
The way to build tool-chain for ARM is described below with 2 method: 1 is traditional CLFS
method and another is tool using
http://cross-lfs.org/view/CLFS-SYSROOT-SVN-0.0.1-20090726/arm/materials/packages.html
#!/bin/bash
export CLFS=/home/clfs
export LS_ALL=POSIX
export PATH=${CLFS}/cross-tools/bin:$PATH
unset CFLAGS
unset CXXFLAGS
export BUILD="-mabi=aapcs-linux -mfloat-abi=soft"
export CLFS_HOST="${MACHTYPE}"
export CLFS_TARGET="arm5l-unknown-linux-uclibceabi"
export CLFS_ARCH=arm
export CLFS_ENDIAN="LITTLE"
export CLFS_NOT_ENDIAN="BIG"
II.2.5 Linux Headers-2.6.30.5
II.2.6 GMP-4.2.4
clfs $patch -Np1 -i ../gmp-4.2.4.branch_update-1.patch
clfs $./configure --prefix=/${CLFS}/cross-tools --enable-mpbsd
clfs $make
clfs $make install
II.2.7 MPFR-2.4.1
P.S.!! if appears-------------------------------------------------
| tc-arm.c:3712: error: format not a string literal |
| and no format arguments |
| make[4]: *** [tc-arm.o] Error |
--------------------------------------------------
http://sources.redhat.com/bugzilla/show_bug.cgi?id=7026
P.S.If appears------------------------------------------------------------------
----
|R ules.mak:583: *** Your binutils do not support --hash-st yle option |
---------------------------------------------------------------
-------
THEN:
clfs $vim .config
#LDSO_GNU_HASH_SUPPORT=y
P.S. Before we begin to configure the Gcc , we put the unpressed gmp -
4.2.4.tar.bz2 named "gmp" and mpfr-2.4.1.tar.gz named "mpfr" in the
unpressed gcc-4.3.3.tar.bz 2 named gc c-4.3.3 directory.
It is, in theory, quite possible to build a cross-compiler yourself, but it is rarely practical. The
series of bootstrap stages needed can be difficult and time-consuming, and it is often necessary to
build a very minimal compiler, which is used to partially configure and build libraries, the
headers of which are then used to rebuild the compiler so it can use them, and so on. A number
of commercial sources for working cross-compilers for various architecture combinations are
available, as well as several free cross-compilation toolkits.
Dan Kegel's crosstool collects a variety of expertise and a few specialized patches to
automatically build toolchains for a number of systems. Crosstool has not been updated in a
while, but the new crosstool-ng project builds on this work. For this tutorial, I used crosstool-ng
version 1.1.0, released in May of 2008. Download it from the distribution site
http://ymorin.is-a-geek.org/dokuwiki/projects/crosstool#overview
$ ./configure --prefix=$HOME/crosstool
Once you have configured it, build it using make and then make install. The build process creates
a crosstool directory in the $HOMEl working directory that holds the crosstool-ng build scripts.
Add the crosstool/bin subdirectory to your path:
$ PATH=$PATH:$HOME/crosstool/bin
$ mkdir toolchain-build
$ cd toolchain-build
Now, copy in a default configuration. It's possible to manually configure crosstool-ng, but one of
the sample configurations happens to fit the target perfectly:
$ cp ../crosstool/lib/ct-ng-1.9.1/samples/arm-unknown-linux-uclibc/* .
$ ct-ng build
$ ct-ng build.4
This may take quite a while, depending on your host system. When it's done, the toolchain is
installed in $HOME/crosstool/toolchain. The directory and its contents are marked read-only; if
you need to delete or move them, use chmod u+w The ct-ng script takes other arguments, such
as help. Note that ct-ng is a script for the standard make utility, and as a result, the output from --
help is just the standard make help; use ct-ng help to get the help for crosstool-ng.
If you haven't seen this trick before, it's a neat one. Modern UNIX systems interpret an
executable file in which the first line starts with #! as a script, specifically, a script for the
program named on the rest of the line. For instance, many shell scripts start with#!/bin/sh. The
name of the file is passed to the program. For programs that treat their first argument as a script
to run, this is sufficient. While make does not do that automatically, you can give it a file to run
with using the -f flag. The first line of ct-ng is#!/usr/bin/make -rf. The -r flag suppresses the
built-in default construction rules of make, and the -f flag tells it that the following word (which
is the script's file name) is the name of a file to use instead of one named Makefile. The result is
an executable script that uses make syntax instead of shell syntax.
II.5 Draft
III.1 Introduction
This part shows how to compile and install a minimal Linuxsystem. This system will contain just
enough tools to start constructing the final CLFS system in Installing Basic System Software and
allow a working environment with more user convenience than a minimum environment would.
However I this report building native Binutils and Gcc for ARM hit some issues, may be the
incompatibility between packages. Thus, this part focuses on how to build an embedded root file
system for ARM base on the book “CLFS-1.0.0-mips” and website www.cross-lfs.org with
difference of package’s versions.
export CC = "${CLFS_TARGET}-gcc"
export AR = "${CLFS_TARGET}-ar"
export AS = "${CLFS_TARGET}-as"
export LD = "${CLFS_TARGET}-ld"
III.3 ncurses-5.7
Download
Source: ftp://invisible-island.net/ncurses/ncurses-5.7.tar.gz
Patches: 1. http://patches.cross-lfs.org/sysroot-dev/ncurses-5.7-bash_fix-1.patch
2. http://patches.cross-lfs.org/sysroot-dev/ncurses-5.7-branch_update-18.patch
Installation of Ncurses
The following patch contains updates from the 5.7 branch by the Ncurses developers:
make
make install
III.4 Bash-4.0
Download
Source: http://ftp.gnu.org/gnu/bash/bash-4.0.tar.gz
Patches: http://patches.cross-lfs.org/sysroot-dev/bash-4.0-branch_update-6.patch
Installation of Bash
make
make install
Create /bin/sh:
Source : http://ftp.gnu.org/gnu/coreutils/coreutils-7.4.tar.gz
Patches: http://patches.cross-lfs.org/sysroot-dev/coreutils-7.4-uname-1.patch
Installation of Coreutils
A known issue with the uname program from this package is that the -p switch always
returns unknown. The following patch fixes this behavior for all architectures:
The following command updates the timestamps on the uname and hostname man pages so that
the Makefile does not attempt to regenerate them:
Configure can not properly determine how to get free space when cross-compiling - as a result,
the df program will not be built. Add the following entries to config.cache to correct this, and fix
various cross-compiling issues:
make
make install
III.6 Diffutils-2.8.7
Download
Source : ftp://alpha.gnu.org/gnu/diffutils/diffutils-2.8.7.tar.gz
Patches: http://patches.cross-lfs.org/sysroot-dev/diffutils-2.8.7-i18n-1.patch
Installation of Diffutils
Diffutils wants ed as the default editor, the following sed will allow us to use vim:
Diffutils man-pages want to be recreated, but it requires help2man. So we update the time on the
files to prevent them from being recreated:
touch man/*.1
make
III.7 Findutils-4.4.2
Download
Source : http://ftp.gnu.org/gnu/findutils/findutils-4.4.2.tar.gz
Installation
When Cross Compiling the configure script does not run a select few tests, Set the values
manually:
make
make install
III.8 Gawk-3.1.7
Download
Source: http://ftp.gnu.org/gnu/gawk/gawk-3.1.7.tar.bz2
Installation of Gawk
Prepare Gawk for compilation:
make install
III.9 Gettext-0.17
Download
Source : http://ftp.gnu.org/gnu/gettext/gettext-0.17.tar.gz
Installation of Gettext
When Cross Compiling the configure script does not run a select few tests, Set the values
manually:
make
make install
III.10 Grep-2.5.4
Download
Source : http://ftp.gnu.org/gnu/grep/grep-2.5.4.tar.bz2
Patches : http://patches.cross-lfs.org/sysroot-dev/grep-2.5.4-i18n-1.patch
Installation of Grep
make
make install
III.11 Textinfo-4.13
Download
Source : http://ftp.gnu.org/gnu/texinfo/texinfo-4.13a.tar.gz
Patches : http://patches.cross-lfs.org/sysroot-dev/texinfo-4.13a-new_compressors-1.patch
Installation
make
make install
III.13 E2fsprogs-1.41.8
Download
Source : http://downloads.sourceforge.net/e2fsprogs/e2fsprogs-1.41.8.tar.gz
Installation
mk –v build
cd build
../configure --prefix=${CLFS} \
--enable-elf-shlibs --disable-evms \
--build=${CLFS_HOST} --host=${CLFS_TARGET}
make
make install
make install-libs
III.14 Sysvinit-2.86
Download
Source: ftp://ftp.cistron.nl/pub/people/miquels/sysvinit/sysvinit-2.86.tar.gz
Patches: http://patches.cross-lfs.org/sysroot-dev/sysvinit-2.86-fixes-1.patch
Installation of Sysvinit
The following sed makes changes in the Makefile required for cross-compiling:
cp -v src/Makefile src/Makefile.orig
sed -e 's@/dev/initctl@$(ROOT)&@g' \
-e 's@\(mknod \)-m \([0-9]* \)\(.* \)p@\1\3p; chmod \2\3@g' \
-e '/^ifeq/s/$(ROOT)//' \
-e 's@/usr/lib@$(ROOT)&@' \
src/Makefile.orig > src/Makefile
Install package
III.15 Module-init-tools-3.10
Download
Source: http://www.kernel.org/pub/linux/utils/kernel/module-init-tools/module-init-tools-
3.10.tar.bz2
Installation
make
make DESTDIR=${CLFS}install
III.16 Util-linux-ng-2.16
Download
Source: http://www.kernel.org/pub/linux/utils/util-linux-ng/v2.16/util-linux-ng-
2.16.tar.bz2
Installation of Util-linux…
The FHS recommends using the /var/lib/hwclock directory instead of the usual /etc directory as
the location for the adjtime file. To make the hwclockprogram FHS-compliant, run the
following:
cp hwclock/hwclock.c{,.orig}
sed -e 's@etc/adjtime@var/lib/hwclock/adjtime@g' \
hwclock/hwclock.c.orig > hwclock/hwclock.c
mkdir -pv ${CLFS}/var/lib/hwclock
--enable-arch
This option allows the arch program to be installed.
--enable-partx
Enables building the addpart, delpart, partx programs.
--enable-write
This option allows the write program to be installed.
--disable-wall
Disables building the wall program, as the Sysvinit package installs its own version.
make
III.17 Udev-145
Download
Source: http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev-145.tar.bz2
Installation
make CROSS_COMPILE="${CLFS_TARGET}-" CC="${CC}" LD="${CC}"
/etc/fstab
The login utilities use the files group, hosts, and passwd in the etc directory for logging in. For
now, only root needs to be defined in group and passwd while hosts just needs to have localhost
defined.
/etc/group
root:x:0:root
/etc/passwd
root::0:0:root:/root:/bin/ash
/etc/host
127.0.0.1 localhost
The kernel starts “/sbin/init” after it boots (actually the kernel attempts to execute several known
programs until one succeeds). Init reads the etc/inittab file to determine what to do at start up,
shutdown, or when a user logs in. These inittab files can get quite complicated. A simple one is
shown below:
etc/inittab
::sysinit:/etc/init.d/rcS
# /bin/ash
#
# Start an "askfirst" shell on the serial port
ttyS0::askfirst:-/bin/ash
III.19 Bootscript-1.2
Download
Source: http://cross-lfs.org/files/packages/sysroot-0.0.1/bootscripts-cross-lfs-1.2-
pre8.tar.bz2
Installation of bootscripts
You can will need to run the following command to install support for Networking:
…..
- Building specific package, some packages have a dependence each other, they should
be built in order. Like a “hello world” program that shows some text string to console can run
properly after booting kernel without any root file-system, all utilities building is all independent
but they use shared libraries. That is important thing and often causes issues in building or
implementing the packages.
Because of incompatibility between the utility packages, the shared library may be lack
or causes system can not run. In this case we can copy the library in built cross-compiler
directory. It is quite full.
- Making boot-scripts …
- In normal, node file-systems will be created automatically after booting system, but in
some cases the necessary node file-systems may not be created. Thus such node file-systems
should be created before CLFS go to use on target.
V. Resources
http://cross-lfs.org/view/clfs-embedded-0.0.1/arm/index.html
http://ymorin.is-a-geek.org/dokuwiki/projects/crosstool
http://www.pierrox.net/cmsms/open-source/clfs.html
http://book.opensourceproject.org.cn/embedded/addembed/index.html?page=opensource/ch04.ht
m