Sie sind auf Seite 1von 29

ARM-CLFS

Writen by Nguyen Ba Dzung Techburg company.

 

March -2011

.

Table of contents

 

I. PREFACE

 

3

II. BUILDING AN ARM CROSS-COMPILER

3

II.1

WHICH TYPE OF CROSS-COMPILER WILL BE USED

3

II.2

CLFS METHOD (HANDLING)

4

II.2.1

Adding the CLFS user

4

II.2.2

Creating Directories

4

II.2.3

Preparing sources and patches

5

II.2.4

Setting valuables

5

II.2.5

Linux Headers-2.6.30.5

6

II.2.6

GMP-4.2.4

6

II.2.7

MPFR-2.4.1

6

II.2.8

Cross Binutils-2.19.1

6

II.2.9

Cross Gcc-4.3.3-Static

7

II.2.10

uClibc 0.9.31

7

II.2.11

GCC-4.3.3-Cross Compiler Final

8

II.3 CROSS-TOOL NG METHOD (TOOL)

 

9

II.3.1

Introducing crosstool-ng

9

II.3.2

Installing crosstool-ng

9

II.3.3

Configuring crosstool-ng

10

II.3.4

Fixing the configuration path

14

II.3.5

Building the toolchain

14

II.3.6

Using the toolchain

14

II.3.7

Where are the libraries?

14

II.4

DRAFT

15

II.5

DRAFT

15

III.

CROSS-BUILDING EMBEDDED ROOT FILE SYSTEM FOR ARM

15

III.1

INTRODUCTION

15

III.2

SETTING UP VARIABLES

15

III.3 NCURSES-5.7

 

15

III.4

BASH-4.0

16

III.5

COREUTILS-7.4

18

III.6 DIFFUTILS-2.8.7

 

19

III.7

FINDUTILS-4.4.2

20

OREUTILS -7.4 18 III.6 D IFFUTILS -2.8.7   19 III.7 F INDUTILS -4.4.2 20 III.8 G

III.9 GETTEXT-0.17

21

III.10

GREP-2.5.4

22

III.11 TEXTINFO-4.13

22

III.12

CREATING DIRECTORIES

23

III.13 E2FSPROGS-1.41.8

23

III.14

SYSVINIT-2.86

24

III.15

MODULE-INIT-TOOLS-3.10

25

III.16

UTIL-LINUX-NG-2.16

25

III.17

UDEV-145

26

III.18

CREATING THE PASSWD, GROUP, AND LOGFILE

27

III.19

BOOTSCRIPT-1.2

28

III.20

POPULATING /DEV

28

IV.

SUMMARY

29

V.

RESOURCES

29

III.19 B OOTSCRIPT -1.2 28 III.20 P OPULATING / DEV 28 IV. SUMMARY 29 V. RESOURCES

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

II.

Building an ARM cross-compiler

II.1

Which type of cross-compiler will be used

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.

Example Processor Type, ABI, and Target Triplets

Processor

Endianess

ABI

Target Triplet

Generic arm

little

OABI

arm-unknown-linux-uclibc

Generic arm,

little

OABI

armv4-unknown-linux-

version 4

uclibc

OABI arm-unknown-linux-uclibc Generic arm, little OABI armv4-unknown-linux- version 4 uclibc

Processor

Endianess

 

ABI

Target Triplet

Generic arm,

little

 

EABI

armv5l-unknown-linux-

version 5

 

uclibceabi

Generic arm,

big

 

EABI

armv5b-unknown-linux-

version 5

 

uclibceabi

   

arm-unknown-linux-

Generic arm

little

 

EABI

uclibceabi

Generic arm,

little

 

EABI

armv7a-unknown-linux-

version 7-a

 

uclibceabi

 

ARM Archiecture Choices

 
 

armv2

armv2a

armv3

armv3m

 

armv4

armv4t

armv5

armv5t

armv5te

armv6

armv6j

armv6t2

armv6z

armv6zk

armv6-m

armv7

armv7-a

armv7-r

armv7-m

iwmmxt

iwmmxt2

ep9312

   

In this case in the type of cross-tools chain should be “armv5b-unknown-linux-uclibceabi

The way to build tool-chain for ARM is described below with 2 method: 1 is traditional CLFS method and another is tool using

II.2

CLFS method

II.2.1

Adding the CLFS user

root #groupadd clfs root #useradd -s /bin/bash -g clfs -m -k /dev/null clfs root #passwd clfs root #chown -R clfs /home/clfs

P.S.clfs's home directory is /home/clfs and is also the root directory of the cross-tool.

II.2.2

Creating Directories

/home/clfs/usr

/home/clfs/usr/include

and is also the root directory of the cross-tool. II.2.2 Creating Directories /home/clfs/usr /home/clfs/usr/include

/home/clfs/cross-tools/

/home/clfs/source/

# We put

Source here.

II.2.3 Preparing sources and patches You can see

for what should prepare. For a toolschain we onl y need Source:

Binutils(2.19.1), GCC(4.3.3) ,GMP(4.2.4) , Linux (2.6.30.5) , MPFR (2.4.1) , uClibc (0.9.31) (!! HERE we use 0.9.31 !!) Patch:

binutils-2.19.1-branch_update-1.patch

binutils-2.19.1-posix -1.patch

gcc-4.3.3-branch_update-5.patch

gcc-4.3.3-posix-1.patch

gmp-4.2.4-branch_update-1.patch

mpfr-2.4.1-branch_update-1.patch

II.2.4 Setting valuables You can touch a new bash script to define the variables as below:

#!/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"

export CLFS_ARCH=arm export CLFS_ENDIAN="LITTLE" export CLFS_NOT_ENDIAN="BIG"

II.2.5

Linux Headers-2.6.30.5

clfs $make mrproper clfs $make ARCH=${CLFS_ARCH} headers_check clfs $make ARCH=${CLFS_ARCH} INSTALL_HDR_PATH=dest headers_install clfs $cp -r /dest/include/* ${CLFS}/usr/include

II.2.6

GMP-4.2.4

clfs $patch -Np1 -i

clfs $./configure --prefix=/${CLFS}/cross-tools --enable-mpbsd clfs $make clfs $make install

/gmp-4.2.4.branch_update-1.patch

II.2.7

MPFR-2.4.1

clfs $patch -Np1 -i

clfs $LDFLAGS="Wl,-rpath,/${CLFS}/lib" ./configure -- prefix=${CLFS}/cross-tools \ --enable-shared --with-gmp=/${CLFS}/cross-tools clfs $make

clfs $make install

/mpfr-2.4.1-branch_update-1.patch

II.2.8

Cross Binutils-2.19.1

clfs $patch -Np1 -i clfs $patch -Np1 -i

clfs $mkdir -v

/binutils-2.19.1-branch_update-1.patch

/binutils-2.19.1-posix-1.patch

/binutils-build

clfs $cd

/binutils-build

clfs $

/binutils-2.19.1/configure

--prefix=${CLFS}/cross-tools \

--target=${CLFS_TARGET} --with-sysroot=${CLFS} --disable-nls \

--enable-shared --disable-multilib clfs $make configure-host clfs $make

--with-sysroot=${CLFS} --disable-nls \ --enable-shared --disable-multilib clfs $make configure-host clfs $make

clfs $make install

clfs $cp -v

/binutils-2.19.1/include/libiberty.h

${CLFS}/usr/include

P.S.!! if appears ------------------------------------------------- | tc-arm.c:3712: error: format not a string literal

| and no format arguments make[4]: *** [tc-arm.o] Error

--------------------------------------------------

|

|

|

The fix is quite eas y

|

II.2.9

Cross Gcc-4.3.3-Static

clfs $patch -Np1 -i clfs $patch -Np1 -i

clfs $mkdir -v

clfs $cd

clfs $AR=ar LDFLAGS="-Wl,-rpath,/cross-tools/lib"

4.3.3/configure --prefix=${CLFS}/cross-tools \ --build=${CLFS_HOST} --host=${CLFS_HOST} --target=${CLFS_TARGET} -- with-sysroot=$CLFS \ --disable-nls --disable-shared --with-mpfr=/$CLFS/cross-tools --with-

gmp=/$CLFS/cross-tools \ --without-headers --with-newlib --disable-decimal-float --disable- libgomp --disable-libmudflap \ --disable-libssp --disable-threads --enable-languages=c clfs $make clfs $make install

/gcc-4.4.4-branch_update-5.patch

/gcc-4.3.3-posix-1.patch

/gcc-build

/gcc-build

/gcc-

II.2.10 uClibc 0.9.31

/gcc-4.3.3-posix-1.patch /gcc-build /gcc-build /gcc- II.2.10 uClibc 0.9.31 clfs $make ARCH=arm delconfig

Target Architecture Features and Options

Target

Target Processor Endianness (Little Endian) ---> (/home/clfs/usr/include) Linux kernel header location Librar y Installation Options

(/)uClibc runtime library directory

(/usr) uClibc development environment directory uClibc development/debugging options

(arm-unknown-linux -gnueabi-)

ABI (EA BI) --->

Cross-compiling toolchain prefix

clfs $make oldconfig clfs $make CROSS=${CLFS_TARGET}- CC="${CLFS_TARGET}-gcc ${BUILD}" \ AS="${CLFS_TARGET}-as -meabi=4" clfs $make PREFIX=${CLFS} install

P.S.If appears------------------------------------------------------------------

----

|Rules.mak:583: *** Your binutils do not support --hash-st yle option |

---------------------------------------------------------------

-------

THEN:

clfs $vim .config # LDSO_GNU_HASH_SUPPORT=y

II.2.11 GCC-4.3.3-Cross Compiler Final

clfs $patch -Np1 -i clfs $patch -Np1 -i

clfs $mkdir -v

clfs

/gcc-4.4.4-branch_update-5.patch

/gcc-4.3.3-posix-1.patch

/gcc-build

$cd

/gcc-build

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

the Gcc , we put the unpressed gmp - 4.2.4.tar.bz2 named "gmp" and mpfr -2.4.1.tar.gz named

unpressed gcc-4.3.3.tar.bz2 named gcc-4.3.3 directory.

clfs $

build=${CLFS_HOST} \ --target=${CLFS_TARGET} --host=${CLFS_HOST} --with-sysroot=${CLFS} -- disable-nls \ --enable-shared --enable-languages=c --enable-c99 --enable-long-long -

-without-ppl --without-cloog clfs $make clfs $make install

/gcc-4.3.3/configure

--prefix=${CLFS}/cross-tools --

II.3

Cross-tool NG method (tool)

II.3.1

Introducing crosstool-ng

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

II.3.2

Crosstool-ng has a configure script. To configure it, just run the script using --prefix to set a location. For instance:

Installing crosstool-ng

the script using --prefix to set a location. For instance: Installing crosstool-ng $ ./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

Configuring crosstool-ng

II.3.3

Crosstool-ng uses a .config file similar to those used by the Linux kernel. You need to create a configuration file matching your target to use crosstool-ng. Make a working directory for a crosstool-ng build:

$ 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/*

.

Finally, rename the crosstool.config file:

$ mv crosstool.config .config

This copies in a configuration file that targets an armv5te processor, the model used on the AT91

Alternatively, in the manually configuring case the build requires a good understanding about architecture of each CPU family, floating point, CPU instruction set, big or little edian and so on

./ct-ng menuconfig

architecture of each CPU family, floating point, CPU instruction set, big or little edian and so
. It builds with uClibc, a libc variant intended for embedded systems. However, the configuration
. It builds with uClibc, a libc variant intended for embedded systems. However, the configuration

. It builds with uClibc, a libc variant intended for embedded systems. However, the configuration file does need one modification.

with uClibc, a libc variant intended for embedded systems. However, the configuration file does need one

II.3.4

The default target directory for a crosstool-ng build is $HOME/x-tools/$TARGET. For instance, on this build, it would come out as x-tools/arm-unknown-linux-uclibc. This is very useful if you are building for a lot of targets, but not so useful if you are building for only one. (Edit the .config file and change CT_PREFIX_DIR = /home/techburg/crosstool/toolchain/)

II.3.5

To build the toolchain, run the ct-ng script with the build argument. To improve performance, especially on a multi-core system, you may want to run with multiple jobs, specified as build.#. For example, this command builds with four jobs:

Fixing the configuration path

Building the toolchain

$ 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.3.6

For starters, add the directory containing the compiler to your path:

Using the toolchain

$ export PATH=~/crosstool/toolchain/bin:$PATH

With that in your path, you can now compile programs:

$ arm-unknown-linux-uclibc-gcc -o hello hello.c $ file hello

hello: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.4.17, dynamically linked (uses shared libs), not stripped

II.3.7

The libraries used by the toolchain to link binaries are stored in arm-unknown-linux-uclibc/sys- root, under the toolchain directory. This directory forms the basis of an eventual root file system, a topic we'll cover under Filesystems once the kernel is built.

Where are the libraries?

an eventual root file system, a topic we'll cover under Filesystems once the kernel is built.

II.4

Draft

II.5

Draft

III. Cross-building embedded root file system for ARM

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.

III.2 Setting up variables Setup target-specific variables for the compiler and linkers:

export CLFS_HOST=”$(echo $MACHTYPE | \

sed “s/$(echo $MACHTYPE | cut -d- -f2)/cross/")”

export CLFS = /home/techburg/CLFS

export CLFS_TARGET = ”arm-unknown-linux-uclibc”

export CC = "${CLFS_TARGET}-gcc"

export CXX = "${CLFS_TARGET}-g++"

export AR = "${CLFS_TARGET}-ar"

export AS = "${CLFS_TARGET}-as"

export RANLIB = "${CLFS_TARGET}-ranlib"

export LD = "${CLFS_TARGET}-ld"

export STRIP = "${CLFS_TARGET}-strip"

III.3 ncurses-5.7 Download

Source: ftp://invisible-island.net/ncurses/ncurses-5.7.tar.gz

"${CLFS_TARGET}-strip" III.3 ncurses-5.7 Download Source: ftp://invisible-island.net/ncurses/ncurses-5.7.tar.gz

Installation of Ncurses

The following patch contains updates from the 5.7 branch by the Ncurses developers:

patch -Np1 -i

/ncurses-5.7-branch_update-18.patch

This patch fixes an issue with some Bash versions:

patch -Np1 -i

/ncurses-5.7-bash_fix-1.patch

Prepare Ncurses for compilation:

./configure prefix = ${CLFS} --with-shared\ --build=${CLFS_HOST} host = ${CLFS_TARGET}\ --without-debug --without-ada\ --enable-overwrite --with-build-cc = gcc

Compile the package:

make

Install the package:

make install

III.4 Bash-4.0

Download

Source:

Installation of Bash

Installation of Bash patch -Np1 -i /bash-4.0-branch_update-6.patch

The following prevents future problems by skipping the check for named pipes, as well as other tests that can not run while cross-compiling or that do not run properly:

cat > config.cache << "EOF" ac_cv_func_mmap_fixed_mapped=yes ac_cv_func_strcoll_works=yes ac_cv_func_working_mktime=yes bash_cv_func_sigsetjmp=present bash_cv_getcwd_malloc=yes bash_cv_job_control_missing=present bash_cv_printf_a_format=yes bash_cv_sys_named_pipes=present bash_cv_ulimit_maxfds=yes bash_cv_under_sys_siglist=yes bash_cv_unusable_rtsigs=no gt_cv_int_divbyzero_sigfpe=yes EOF

./configure --prefix = ${CLFS}\ --build=${CLFS_HOST}--host=${CLFS_TARGET}\ --without-bash-malloc --cache-file=config.cache

Compile the package:

make

Install the package:

make install

Create /bin/sh:

ln -sfv bash ${CLFS}/bin/sh

Compile the package: make Install the package: make install Create /bin/sh: ln -sfv bash ${CLFS}/bin/sh

III.5 Coreutils-7.4 Download

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:

patch -Np1 -i

/coreutils-7.4-uname-1.patch

The following command updates the timestamps on the uname and hostname man pages so that the Makefile does not attempt to regenerate them:

touch man/uname.1 man/hostname.1

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:

cat > config.cache << EOF

fu_cv_sys_stat_statfs2_bsize=yes

gl_cv_func_rename_trailing_slash_bug=no

gl_cv_func_mbrtowc_incomplete_state=yes

gl_cv_func_mbrtowc_nul_retval=yes

gl_cv_func_mbrtowc_null_arg=yes

gl_cv_func_mbrtowc_retval=yes

gl_cv_func_btowc_eof=yes

gl_cv_func_wcrtomb_retval=yes

gl_cv_func_wctob_works=yes

EOF

Now prepare Coreutils for compilation:

./configure --prefix=${CLFS} --cache-file=config.cache \ --build=${CLFS_HOST} --host=${CLFS_TARGET}

for compilation: ./configure --prefix=${CLFS} --cache-file=config.cache \ --build=${CLFS_HOST} --host=${CLFS_TARGET}

Compile the package:

make

Install the package:

make install

III.6 Diffutils-2.8.7 Download

Source : ftp://alpha.gnu.org/gnu/diffutils/diffutils-2.8.7.tar.gz

Installation of Diffutils

patch -Np1 -i

/diffutils-2.8.7-i18n-1.patch

./configure --build=${CLFS_HOST} --host=${CLFS_TARGET} \ --prefix=${CLFS}

Diffutils wants ed as the default editor, the following sed will allow us to use vim:

sed -i 's@\(^#define DEFAULT_EDITOR_PROGRAM \).*@\1"vi"@' config.h

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

Compile the package:

make

Install the package:

the time on the files to prevent them from being recreated: touch man/*.1 Compile the package:

make install

III.7 Findutils-4.4.2 Download

Installation

When Cross Compiling the configure script does not run a select few tests, Set the values manually:

cat > config.cache << EOF gl_cv_func_wcwidth_works=yes gl_cv_header_working_fcntl_h=yes ac_cv_func_fnmatch_gnu=yes EOF

Prepare Findutils for compilation:

./configure --build=${CLFS_HOST} --host=${CLFS_TARGET} \ --prefix=${CLSF} --cache-file=config.cache \

Compile the package:

make

Install the package:

make install

III.8 Gawk-3.1.7 Download

Installation of Gawk

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:

./configure --build=${CLFS_HOST} --host=${CLFS_TARGET} \ --prefix=${CLFS}

make

make install

III.9 Gettext-0.17 Download

Installation of Gettext

When Cross Compiling the configure script does not run a select few tests, Set the values manually:

cat > config.cache << EOF am_cv_func_iconv_works=yes gl_cv_func_wcwidth_works=yes gt_cv_func_printf_posix=yes gt_cv_int_divbyzero_sigfpe=yes EOF

Prepare Gettext for compilation:

./configure --build=${CLFS_HOST} --host=${CLFS_TARGET} \ --prefix=${CLFS} --cache-file=config.cache

make

for compilation: ./configure --build=${CLFS_HOST} --host=${CLFS_TARGET} \ --prefix=${CLFS} --cache-file=config.cache make

make install

III.10 Grep-2.5.4 Download

Installation of Grep

patch -Np1 -i

/grep-2.5.4-i18n-1.patch

./configure --build=${CLFS_HOST} --host=${CLFS_TARGET} \ --prefix=${CLFS} --disable-perl-regexp

make

make install

III.11 Textinfo-4.13 Download

Installation

patch -Np1 -i

/texinfo-4.13a-new_compressors-1.patch

Installation patch -Np1 -i /texinfo-4.13a-new_compressors-1.patch

./configure --build=${CLFS_HOST} --host=${CLFS_TARGET} \ --prefix=${CLFS}

make

make install

III.12 Creating directories

mkdir pv ${CLFS}/{bin,boot,dev,{etc/,}opt,home,lib,mnt} mkdir pv ${CLFS}/{proc,media/{floppy,cdrom},sbin,srv,sys} mkdir -pv ${CLFS}/var/{lock,log,mail,run,spool} mkdir pv ${CLFS}/var/{opt,cache,lib/{misc,locate},local} install dv m 0750 ${CLFS}/root install -dv -m 1777 ${CLFS}{/var,}/tmp mkdir pv ${CLFS}/usr/{,local/}{bin,include,lib,sbin,src} mkdir pv ${CLFS}/usr/{,local/}share/{doc,info,locale,man} mkdir -pv ${CLFS}/usr/{,local/}share/{misc,terminfo,zoneinfo} mkdir pv ${CLFS}/usr/{,local/}share/man/man{1,2,3,4,5,6,7,8} for dir in ${CLFS}/usr{,/local};do ln sv share/{man,doc,info} $dir done

III.13 E2fsprogs-1.41.8 Download

Installation

mk v build

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

ln sv ${CLFS}/sbin/{fsck.ext2,fsck.ext3,e2fsck} ${CLFS}/sbin

III.14 Sysvinit-2.86 Download

Source: ftp://ftp.cistron.nl/pub/people/miquels/sysvinit/sysvinit-2.86.tar.gz

Installation of Sysvinit

patch -Np1 -i

/sysvinit-2.86-fixes-1.patch

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@\(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

make -C src clobber make -C src ROOT=${CLFS} CC="${CC}"

Install package

make -C src ROOT=${CLFS} INSTALL="install" install

III.15 Module-init-tools-3.10 Download

3.10.tar.bz2

Installation

./configure --build=${CLFS_HOST} --host=${CLFS_TARGET} \ --prefix=${CLFS}

make

make DESTDIR=${CLFS}install

III.16 Util-linux-ng-2.16 Download

2.16.tar.bz2

Installation of Util- linux…

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

Prepare Util-linux-ng for compilation:

./configure --build=${CLFS_HOST} --host=${CLFS_TARGET} \ --enable-arch --enable-partx --disable-wall \ --enable-write --disable-makeinstall-chown

The meaning of the configure options:

--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.

Compile the package:

make

Install the package:

make DESTDIR=${CLFS} install

III.17 Udev-145 Download

Installation

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}"

Install the package:

make DESTDIR=${CLFS} install

Create a directory for storing firmware that can be loaded by udev:

install -dv ${CLFS}/lib/firmware

III.18 Creating the passwd, group, and logfile To have the /proc and /dev/pts file systems mounted at boot time, the file etc/fstab must be created in the etc directory

/etc/fstab

proc

/proc

proc

defaults

0

0

none

/dev/pts

devpts mode=0622

0

0

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

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

# Stuff to do when restarting the init process ::restart:/sbin/init

# Stuff to do before rebooting

::ctrlaltdel:/sbin/reboot ::shutdown:/bin/umount -a -r

::shutdown:/sbin/swapoff -a

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

make DESTDIR=${CLFS} install-bootscripts

You can will need to run the following command to install support for Networking:

make DESTDIR=${CLFS} install-network

III.20 Populating /dev

mknod ${CLFS}/dev/console c 5 1

mknod ${CLFS}/dev/null c 1 3

make DESTDIR=${CLFS} install-network III.20 Populating /dev mknod ${CLFS}/dev/console c 5 1 mknod ${CLFS}/dev/null c 1 3

IV.

Summary After all, the building root file system for embedded system from CLFS method includes steps:

 

-

Building cross-toolchain is the most difficult and important step.

-

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

CLFS-1.0.0-mips by Jim Gifford and Ryan Oliver

m

http://book.opensourceproject.org.cn/embedded/addembed/index.html ?page=opensource/ch04.ht m