CLFS(cross linux from scratch)的 EMD方法

 http://blog.csdn.net/z642010820/article/details/5939999

前言: EMD(embedded desktop)是和 MEEGO类似的生态系统,所谓 CLFS的 EMD方法,就是构建 EMD生态系统的方法。因为和 CLFS官方的方法有些不同,故取了这个名字。附件在http://download.csdn.net/source/2754728可以下载,里面包含了本文章里的所有脚本和配置文件。

 

第一章:编译前的准备

 

第一节:所需软件包

1.busybox-1.17.2.tar.bz2

2.tslib-1.4.tar.gz

3.zlib-1.2.5.tar.gz

4.libpng-1.4.3.tar.gz

5.jpegsrc.v8b.tar.gz

6.libid3tag-0.15.1b.tar.gz

7.libmad-0.15.1b.tar.gz

8.glib-2.24.2.tar.bz2

9.libxml2-2.7.7.tar.gz

10.liboil-0.3.17.tar.gz

11.alsa-lib-1.0.23.tar.bz2

12.gstreamer-0.10.30.tar.gz

13.gst-plugins-good-0.10.25.tar.gz

14.gst-plugins-base-0.10.30.tar.gz

15.gst-plugins-bad-0.10.20.tar.gz

16.gst-plugins-ugly-0.10.16.tar.gz

17.gst-ffmpeg-0.10.11.tar.gz

18.expat-2.0.1.tar.gz

19.dbus-1.2.24.tar.gz

20.qt-everywhere-opensource-src-4.6.3.tar.gz

21.qwt-5.2.1.zip

22.emd.tar.gz

23.arm-linux-gcc-4.4.3-20100728.tar.gz ( mini2440官方网站提供的编译器,  可用于armv4的cpu, 如果你用其他的cpu要自己去挑选编译器)

以上软件包的功用会在后面提到。

 

第二节 : 准备编译环境

1. 本人只在 fedora13上进行过测试,只要你的 linux上有比较合适的开发环境都是可以的。

首先要创建一个新用户叫 clfs,这样可以使工作环境比较整洁。然后用 clfs这个用户登录 , 并且在 /etc/sudoer中添加

clfs ALL=(ALL) NOPASSWD: ALL

让用户 clfs执行 sudo时不需要密码。

 

2.下面是~ /.bashrc脚本

#/bin/sh

# .bashrc

 

# Source global definitions

if [ -f /etc/bashrc ]; then

. /etc/bashrc

fi

 

#set +h

#umask 022

CLFS=/home/clfs/workplace

SYSROOT=${CLFS}/sysroot

EMD_RUNNING_DIR=/opt/emdesktop-running-environment

PATH=/opt/FriendlyARM/toolschain/4.4.3/bin:/opt/qt-embedded/bin:~/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin

CLFS_HOST="$(echo $MACHTYPE | /

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

CLFS_TARGET="arm-linux"

export CLFS LC_ALL PATH CLFS_HOST CLFS_TARGET SYSROOT EMD_RUNNING_DIR

unset CFLAGS

unset CXXFLAGS

 

2.下面是~ /.bash_profile

# .bash_profile

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

. ~/.bashrc

fi

 

#exec env -i HOME=${HOME} TERM=${TERM} PS1='/u:/w/$ ' /bin/bash

 

3.然后用 clfs用户登录,后面的所有工作都是使用 clfs用户

source ~/.bash_profile

rm -rf /opt

ln -sv $SYSROOT/opt /opt

有些库比如 qt使用 gcc的 -rpath选项,会把编译时指定的库路径硬编码进库文件,如果在编译时指定让它去 $SYSROOT/opt/lib目录下找依赖的库,那么在运行时就会找不到 $SYSROOT/opt/lib下的依赖,因为在板上 $SYSROOT/opt/lib根本不存在。

CLFS的 EMD方法把所有需要安装的软件包 (除 glibc和 busybox)安装在 $SYSROOT/opt目录下,把 /opt链接到 $SYSROOT/opt, 在配置软件时可以把软件安装路径指向 /opt,把依赖库路径指向 /opt/lib,这样即使用 -rpath选项把 /opt/lib硬编码进库文件,也是和板上运行环境协调的。

 

4.创建工作目录

mkdir ~/workspace

cd $CLFS

mkdir sources image sysroot

cd sources

mkdir build

cd build

mkdir instruction

cd instruction

mkdir config

 

你的所有 clfs的工作都在 workspace目录下进行

把所有的下载的源码包都放在 sources里

sysroot里面是你的根文件系统

image里面将会存放用根文件系统打包制作的镜像。

Build目录存放软件包编译过程中的临时文件。

Instruction目录里存放编译各个软件包的脚本。

config目录里存放某些软件包的配置文件。

 

5.安装编译器

cd $CLFS/sources

tar zxvf arm-linux-gcc-4.4.3-20100728.tar.gz /opt

 

第二章:编译文件系统

 

第一节 : 创建文件系统目录结构和启动必要的设备节点

 

# !/bin/sh

set -e

 

cd ${SYSROOT}

mkdir -v bin dev etc lib proc sbin sys tmp usr var opt root home

cd opt

mkdir -v qt-embedded

cd ../usr

mkdir -v bin lib libexec sbin share

 

sudo mknod console c 5 1

sudo mknod null c 1 3

 

第二节: glibc

 

描述:由于使用了现成的编译器,所以 libc不用自己编译,下面给出 libc的安装脚本:

 

# !/bin/sh

set -e

GCC_SYSROOT=/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi/sys-root

sudo cp -Prv ${GCC_SYSROOT}/etc/* ${SYSROOT}/etc

sudo cp -Prv ${GCC_SYSROOT}/sbin/* ${SYSROOT}/sbin

sudo cp -Prv ${GCC_SYSROOT}/usr/bin/* ${SYSROOT}/usr/bin

sudo cp -Prv ${GCC_SYSROOT}/usr/sbin/* ${SYSROOT}/usr/sbin

sudo cp -Prv ${GCC_SYSROOT}/usr/libexec/* ${SYSROOT}/usr/libexec

sudo cp -Prv ${GCC_SYSROOT}/usr/share/locale ${SYSROOT}/usr/share/

sudo cp -Prv ${GCC_SYSROOT}/usr/share/i18n ${SYSROOT}/usr/share/

sudo cp -Prv ${GCC_SYSROOT}/usr/share/zoneinfo ${SYSROOT}/usr/share/

 

cp -Pv ${GCC_SYSROOT}/lib/libc[-.]*so* ${SYSROOT}/lib

cp -Pv ${GCC_SYSROOT}/lib/ld-*so* ${SYSROOT}/lib

cp -Pv ${GCC_SYSROOT}/lib/libdl[-.]*so* ${SYSROOT}/lib

cp -Pv ${GCC_SYSROOT}/lib/libgcc_s.so* ${SYSROOT}/lib

cp -Pv ${GCC_SYSROOT}/lib/libm[-.]*so* ${SYSROOT}/lib

cp -Pv ${GCC_SYSROOT}/lib/librt[-.]*so* ${SYSROOT}/lib

cp -Pv ${GCC_SYSROOT}/lib/libresolv[-.]*so* ${SYSROOT}/lib

cp -Pv ${GCC_SYSROOT}/lib/libpthread[-.]*so* ${SYSROOT}/lib

cp -Pv ${GCC_SYSROOT}/lib/libstdc++.so* ${SYSROOT}/lib

cp -Pv ${GCC_SYSROOT}/lib/libnss_* ${SYSROOT}/lib

 

 

cp -Pv ${GCC_SYSROOT}/usr/lib/libc.so ${SYSROOT}/usr/lib

cp -Pv ${GCC_SYSROOT}/usr/lib/libdl.so ${SYSROOT}/usr/lib

cp -Pv ${GCC_SYSROOT}/usr/lib/libm.so ${SYSROOT}/usr/lib

cp -Pv ${GCC_SYSROOT}/usr/lib/libpthread.so ${SYSROOT}/usr/lib

cp -Pv ${GCC_SYSROOT}/usr/lib/librt.so ${SYSROOT}/usr/lib

cp -Pv ${GCC_SYSROOT}/usr/lib/libresolv.so ${SYSROOT}/usr/lib

cp -Pv ${GCC_SYSROOT}/usr/lib/libnss_* ${SYSROOT}/usr/lib

 

第三节: busybox

 

被依赖:

依赖于:

 

#/bin/sh

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"

set -e

 

tar jxvf ${CLFS}/sources/busybox-1.17.2.tar.bz2 -C ${CLFS}/sources/build

cd ${CLFS}/sources/build/busybox-1.17.2

 

cp -v ${CLFS}/sources/build/instruction/config/busybox.config .config

make

make install

 

cd ..

rm -rf busybox-1.17.2

 

(以下过程在编译其他包时都雷同,将不再重复 )

将此脚本保存为 ${CLFS}/sources/build/instruction/busybox

chmod 755 ${CLFS}/sources/build/instruction/busybox

cd ${CLFS}/sources/build/instruction

./busybox

 

其中 busybox.config为提前配置好的配置文件,将和编译脚本一起在附件中提供。

 

第四节: tslib

 

被依赖 : qt

依赖于:

 

# !/bin/sh

set -e

 

tar zxvf ${CLFS}/sources/tslib-1.4.tar.gz -C ${CLFS}/sources/build

cd ${CLFS}/sources/build/tslib

cp -v ${CLFS}/sources/build/instruction/config/ts.conf etc/

aclocal

./autogen.sh

echo "ac_cv_func_malloc_0_nonnull=yes" >arm-linux.cache

./configure --build=${CLFS_HOST} --host=${CLFS_TARGET} --prefix=/opt --cache-file=arm-linux.cache

make

make install

 

cd ..

rm -rf tslib

 

第五节: zlib

 

被依赖: glib, qt等

依赖于:

 

# !/bin/sh

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"

set -e

 

tar zxvf ${CLFS}/sources/zlib-1.2.5.tar.gz -C ${CLFS}/sources/build

cd ${CLFS}/sources/build/zlib-1.2.5

 

./configure --prefix=/opt --shared

make

make install

 

cd ..

rm -rf zlib-1.2.5

 

第六节: libpng

被依赖: qt

依赖于:

 

# !/bin/sh

set -e

 

tar zxvf ${CLFS}/sources/libpng-1.4.3.tar.gz -C ${CLFS}/sources/build

cd ${CLFS}/sources/build/libpng-1.4.3

 

PKG_CONFIG_PATH=/opt/lib/pkgconfig ./configure --build=${CLFS_HOST} --host=${CLFS_TARGET} /

--prefix=/opt

make

make install

 

cd ..

rm -rf libpng-1.4.3

 

第七节: libjpeg

 

被依赖: qt

依赖于:

 

# !/bin/sh

set -e

 

tar zxvf ${CLFS}/sources/jpegsrc.v8b.tar.gz -C ${CLFS}/sources/build

cd ${CLFS}/sources/build/jpeg-8b

 

PKG_CONFIG_PATH=/opt/lib/pkgconfig ./configure --build=${CLFS_HOST} --host=${CLFS_TARGET} /

--prefix=/opt

make

make install

 

cd ..

rm -rf jpeg-8b

 

第八节: libid3tag

 

被依赖: libmad

依赖于:

 

# !/bin/sh

set -e

 

tar zxvf ${CLFS}/sources/libid3tag-0.15.1b.tar.gz -C ${CLFS}/sources/build

cd ${CLFS}/sources/build/libid3tag-0.15.1b

 

PKG_CONFIG_PATH=/opt/lib/pkgconfig/ ./configure --build=${CLFS_HOST} --host=${CLFS_TARGET} --prefix=/opt

make

make install

 

cd ..

rm -rf libid3tag-0.15.1b

 

第九节: libmad

 

被依赖:( gstream的一个 plugin,忘记了, 以后再补)

依赖于: libid3tag

 

# !/bin/sh

set -e

 

tar zxvf ${CLFS}/sources/libmad-0.15.1b.tar.gz -C ${CLFS}/sources/build

cd ${CLFS}/sources/build/libmad-0.15.1b

 

PKG_CONFIG_PATH=/opt/lib/pkgconfig/ ./configure --build=${CLFS_HOST} --host=${CLFS_TARGET} --prefix=/opt

sed 's/-fforce-mem//g' Makefile>Makefile.new

mv Makefile.new Makefile

 

make

make install

 

cd ..

rm -rf libmad-0.15.1b

 

第十节: glib

 

被依赖: gstreamer及其 plugin

依赖于: zlib

 

# !/bin/sh

set -e

 

tar jxvf ${CLFS}/sources/glib-2.24.2.tar.bz2 -C ${CLFS}/sources/build

cd ${CLFS}/sources/build/glib-2.24.2

 

echo ac_cv_type_long_long=yes>arm-linux.cache

echo glib_cv_stack_grows=no>>arm-linux.cache

echo glib_cv_uscore=no>>arm-linux.cache

echo ac_cv_func_posix_getpwuid_r=yes>>arm-linux.cache

echo ac_cv_func_posix_getgrgid_r=yes>>arm-linux.cache

 

CFLAGS=-I/opt/include LDFLAGS=-L/opt/lib /

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

--prefix=/opt --cache-file=arm-linux.cache

make

make install

 

cd ..

rm -rf glib-2.24.2

 

第 11节: libxml2

 

被依赖: gstreamer

依赖于: zlib

 

# !/bin/sh

set -e

 

tar zxvf ${CLFS}/sources/libxml2-2.7.7.tar.gz -C ${CLFS}/sources/build

cd ${CLFS}/sources/build/libxml2-2.7.7

 

PKG_CONFIG_PATH=/opt/lib/pkgconfig /

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

--prefix=/opt --with-python=/opt

make

make install

 

cd ..

rm -rf libxml2-2.7.7

 

第 12节: liboil

 

被依赖: gstreamer

依赖于:

 

# !/bin/sh

set -e

 

tar zxvf ${CLFS}/sources/liboil-0.3.17.tar.gz -C ${CLFS}/sources/build

cd ${CLFS}/sources/build/liboil-0.3.17

 

PKG_CONFIG_PATH=/opt/lib/pkgconfig /

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

--prefix=/opt

make

make install

 

cd ..

rm -rf liboil-0.3.17

 

第 13节: alsa

 

被依赖: gstreamer

依赖于:

 

# !/bin/sh

set -e

 

tar jxvf ${CLFS}/sources/alsa-lib-1.0.23.tar.bz2 -C ${CLFS}/sources/build

cd ${CLFS}/sources/build/alsa-lib-1.0.23

 

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

--prefix=/opt --disable-python

make

make install

 

cd ..

rm -rf alsa-lib-1.0.23

 

第 14节: gstreamer

 

被依赖: gstreamer的 plugin, qt的 phonon模块

依赖于: glib, liboil, libxml2

 

# !/bin/sh

set -e

 

tar zxvf ${CLFS}/sources/gstreamer-0.10.30.tar.gz -C ${CLFS}/sources/build

cd ${CLFS}/sources/build/gstreamer-0.10.30

 

PKG_CONFIG_PATH=/opt/lib/pkgconfig ./configure --build=${CLFS_HOST} --host=${CLFS_TARGET} /

--prefix=/opt --disable-valgrind --disable-largefile

make

make install

 

cd ..

rm -rf gstreamer-0.10.30

 

第 15节: gstreamer-base-plugin

 

被依赖:

依赖于: gstreamer

 

# !/bin/sh

set -e

 

tar zxvf ${CLFS}/sources/gst-plugins-base-0.10.30.tar.gz -C ${CLFS}/sources/build

cd ${CLFS}/sources/build/gst-plugins-base-0.10.30

 

PKG_CONFIG_PATH=/opt/lib/pkgconfig/ ./configure --build=${CLFS_HOST} --host=${CLFS_TARGET} --prefix=/opt /

--disable-valgrind --disable-x --disable-gnome_vfs --disable-ogg --disable-pango --disable-theora /

--disable-vorbis --disable-examples

make

make install

 

cd ..

rm -rf gst-plugins-base-0.10.30

 

第 16节: gstreamer-good-plugin

 

被依赖:

依赖于: gstreamer

 

# !/bin/sh

set -e

 

tar zxvf ${CLFS}/sources/gst-plugins-good-0.10.25.tar.gz -C ${CLFS}/sources/build

cd ${CLFS}/sources/build/gst-plugins-good-0.10.25

 

PKG_CONFIG_PATH=/opt/lib/pkgconfig/ ./configure --build=${CLFS_HOST} --host=${CLFS_TARGET} --prefix=/opt /

--disable-valgrind --disable-x --disable-cairo --disable-gdk_pixbuf --disable-annodex /

--disable-oss4 --disable-oss --disable-shout2 --disable-soup --disable-examples

make

make install

 

cd ..

rm -rf gst-plugins-good-0.10.25

 

 

第 17节: gstreamer-ugly-plugin

 

被依赖:

依赖于: gstreamer

 

# !/bin/sh

set -e

 

tar zxvf ${CLFS}/sources/gst-plugins-ugly-0.10.16.tar.gz -C ${CLFS}/sources/build

cd ${CLFS}/sources/build/gst-plugins-ugly-0.10.16

 

PKG_CONFIG_PATH=/opt/lib/pkgconfig/ ./configure --build=${CLFS_HOST} --host=${CLFS_TARGET} --prefix=/opt

make

make install

 

cd ..

rm -rf gst-plugins-ugly-0.10.16

 

第 18节: gstreamer-bad-plugin

 

被依赖:

依赖于: gstreamer

 

# !/bin/sh

set -e

 

tar zxvf ${CLFS}/sources/gst-plugins-bad-0.10.20.tar.gz -C ${CLFS}/sources/build

cd ${CLFS}/sources/build/gst-plugins-bad-0.10.20

 

PKG_CONFIG_PATH=/opt/lib/pkgconfig/ /

./configure --build=${CLFS_HOST} --host=${CLFS_TARGET} --prefix=/opt --disable-sdl /

--disable-apexsink --without-x --disable-librfb --disable-examples

make

make install

 

cd ..

rm -rf gst-plugins-bad-0.10.20

 

第 19节: gstreamer-ffmpeg

 

被依赖:

依赖于: gstreamer

 

# !/bin/sh

set -e

 

tar zxvf ${CLFS}/sources/gst-ffmpeg-0.10.11.tar.gz -C ${CLFS}/sources/build

cd ${CLFS}/sources/build/gst-ffmpeg-0.10.11

 

PKG_CONFIG_PATH=/opt/lib/pkgconfig ./configure --build=${CLFS_HOST} --host=${CLFS_TARGET} --prefix=/opt /

--enable-shared /

--disable-silent-rules -v /

--with-ffmpeg-extra-configure="--prefix=/opt --cross-prefix=${CLFS_TARGET}- /

--cpu=armv4 --arch=arm --host-cc=gcc --enable-cross-compile --target-os=linux --extra-cflags=-I/opt/include /

--extra-ldflags=-L/opt/lib"

 

 

make

make install

 

 

cd ..

rm -rf gst-ffmpeg-0.10.11

 

第 20节: expat

 

被依赖: dbus

依赖于:

 

# !/bin/sh

set -e

 

tar zxvf ${CLFS}/sources/expat-2.0.1.tar.gz -C ${CLFS}/sources/build

cd ${CLFS}/sources/build/expat-2.0.1

 

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

make

make install

 

cd ..

rm -rf expat-2.0.1

 

第 21节: dbus

 

被依赖: qt的 dbus模块

依赖于: expat

 

# !/bin/sh

set -e

 

tar zxvf ${CLFS}/sources/dbus-1.2.24.tar.gz -C ${CLFS}/sources/build

cd ${CLFS}/sources/build/dbus-1.2.24

 

CFLAGS=-I/opt/include LDFLAGS=-L/opt/lib /

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

--with-x=no ac_cv_have_abstract_sockets=yes --with-xml=expat --disable-silent-rules /

--enable-dnotify=no --enable-inotify

make

make install

 

cd ..

rm -rf dbus-1.2.24

 

第 22节: qt

 

被依赖: qwt, EMD

依赖于: dbus, gstreamer, tslib, libpng, libz, libjpeg

 

# !/bin/sh

set -e

 

tar zxvf ${CLFS}/sources/qt-everywhere-opensource-src-4.6.3.tar.gz -C ${CLFS}/sources/build

cd ${CLFS}/sources/build/qt-everywhere-opensource-src-4.6.3

cp -v ${CLFS}/sources/build/instruction/config/qmake.conf mkspecs/qws/linux-arm-g++/

 

PKG_CONFIG_PATH=/opt/lib/pkgconfig /

./configure -prefix /opt/qt-embedded -embedded arm -xplatform qws/linux-arm-g++ -fast -force-pkg-config /

-no-opengl -qt-freetype -depths 16,18,24 -little-endian /

-qt-mouse-tslib /

-nomake tools -nomake docs -opensource -confirm-license -no-largefile /

-qt-sql-sqlite -no-qt3support -no-xmlpatterns /

-multimedia -audio-backend -phonon -phonon-backend -svg /

-webkit -no-javascript-jit -script -no-scripttools -no-declarative /

-qt-gif -qt-libtiff -system-libpng -qt-libmng -system-libjpeg -no-openssl /

-system-zlib -no-nis -no-cups -dbus -no-mmx -no-3dnow -no-sse -no-sse2 /

-no-xcursor -no-xfixes -no-xrandr -no-xrender -no-separate-debug-info

 

make

make install

 

cd ..

rm -rf qt-everywhere-opensource-src-4.6.3

 

 

第 23节: qwt

 

被依赖: EMD

依赖于: qt

 

# !/bin/sh

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"

set -e

 

unzip ${CLFS}/sources/qwt-5.2.1.zip -d ${CLFS}/sources/build

cp ${CLFS}/sources/build/instruction/config/qwtconfig.pri ${CLFS}/sources/build/qwt-5.2.1

cd ${CLFS}/sources/build/qwt-5.2.1

qmake

make

make install

 

cd ..

rm -rf qwt-5.2.1

 

第 24节: EMD

 

被依赖:

依赖于: qt, qwt

 

# !/bin/sh

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"

set -e

 

cp -Rv ${CLFS}/sources/emd ${CLFS}/sources/build

cd ${CLFS}/sources/build/emd

cd emd

qmake

make clean

make

 

cd ..

cp -v wenquanyi/* /opt/qt-embedded/lib/fonts

cp -Rv emdesktop-running-environment /opt

cd emd

make install

 

cd ../..

rm -rf emd

 

第三章:启动脚本

第一节: /etc/init.d/rcS

 

描述:本脚本为上电后执行的第一个脚本,进行分区加载, 环境变量设置和某些构件的初始化

 

#!/bin/sh

umask 022

 

/bin/hostname zzz

 

#mdev

/bin/mount -t tmpfs -o size=64k,mode=0755 tmpfs /dev

mkdir -p /dev/pts

ln -s /dev /dev/snd

/bin/mount -t devpts devpts /dev/pts

/bin/mount -t proc proc /proc

/bin/mount -t sysfs sysfs /sys

echo /sbin/mdev > /proc/sys/kernel/hotplug

/sbin/mdev -s

#end mdev

 

mkdir -p /dev/shm

/bin/mount -n -t tmpfs tmpfs /dev/shm

/bin/mount -n -t ramfs none /tmp

/bin/mount -n -t ramfs none /var

mkdir -p /var/empty

mkdir -p /var/log

mkdir -p /var/lock

mkdir -p /var/run

mkdir -p /var/tmp

 

/sbin/hwclock -s

syslogd

 

/sbin/ifconfig lo 127.0.0.1

/etc/init.d/ifconfig-eth0

 

_ROOT=/opt

export PATH=/bin:/sbin:/usr/bin:/usr/sbin:${_ROOT}/bin:${_ROOT}/sbin

export LC_ALL="en_US.utf8"

 

#tslib

export TSLIB_CONSOLEDEVICE=none

export TSLIB_FBDEVICE=/dev/fb0

export TSLIB_TSDEVICE=/dev/input/event0

export TSLIB_CALIBFILE=/etc/pointercal

export TSLIB_CONFFILE=${_ROOT}/etc/ts.conf

export TSLIB_PLUGINDIR=${_ROOT}/lib/ts

 

if [ ! -f ${TSLIB_CALIBFILE} ]; then

${_ROOT}/bin/ts_calibrate

chmod 644 $TSLIB_CALIBFILE

fi

#end tslib

 

#Qt

export QWS_MOUSE_PROTO=TSLIB:/dev/input/event0

export QWS_DISPLAY=LinuxFb:/dev/fb0

#Qt

 

#gstreamer

export GST_PLUGIN_PATH=/opt/lib/gstreamer-0.10

#end gstreamer

 

#dbus

if [ ! -f /opt/var/lib/dbus/machine-id ]; then

dbus-uuidgen > /opt/var/lib/dbus/machine-id

fi

 

rm -fv /opt/var/run/messagebus.pid

 

#dbus-daemon --system --print-pid --print-address

 

if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then

## if not found, launch a new one

eval `dbus-launch --sh-syntax`

echo "D-Bus per-session daemon address is: $DBUS_SESSION_BUS_ADDRESS"

fi

#end dbus

 

cd /opt/emdesktop-running-environment

./emdesktop -qws&

 

第 2节: /etc/init.d/ifconfig-eth0

描述:解析 /etc/eth0-setting文件来配置网络

#!/bin/sh

 

echo -n Try to bring eth0 interface up......>/dev/ttySAC0

 

if [ -f /etc/eth0-setting ] ; then

source /etc/eth0-setting

 

if grep -q "^/dev/root / nfs " /etc/mtab ; then

echo -n NFS root ... > /dev/ttySAC0

else

ifconfig eth0 down

ifconfig eth0 hw ether $MAC

ifconfig eth0 $IP netmask $Mask up

route add default gw $Gateway

fi

 

echo nameserver $DNS > /etc/resolv.conf

else

 

if grep -q "^/dev/root / nfs " /etc/mtab ; then

echo -n NFS root ... > /dev/ttySAC0

else

/sbin/ifconfig eth0 192.168.1.230 netmask 255.255.255.0 up

fi

fi

 

echo Done > /dev/ttySAC0

 

第 3节: /etc/eth0-setting

 

描述:配置网络参数

 

IP=218.192.26.111

Mask=255.255.254.0

Gateway=218.192.26.1

DNS=202.116.0.1

MAC=08:90:90:90:90:90

 

第 3节: /etc/mdev.conf

 

描述:配置 mdev,创建设备节点和某些分区的自动加载

 

# system all-writable devices

full 0:0 0666

null 0:0 0666

ptmx 0:0 0666

random 0:0 0666

tty 0:0 0666

zero 0:0 0666

 

# console devices

tty[0-9]* 0:5 0660

vc/[0-9]* 0:5 0660

 

# serial port devices

s3c2410_serial0 0:5 0666 =ttySAC0

s3c2410_serial1 0:5 0666 =ttySAC1

s3c2410_serial2 0:5 0666 =ttySAC2

s3c2410_serial3 0:5 0666 =ttySAC3

 

# loop devices

loop[0-9]* 0:0 0660 =loop/

 

# i2c devices

i2c-0 0:0 0666 =i2c/0

i2c-1 0:0 0666 =i2c/1

 

# frame buffer devices

fb[0-9] 0:0 0666

 

# input devices

mice 0:0 0660 =input/

mouse.* 0:0 0660 =input/

event.* 0:0 0660 =input/

ts.* 0:0 0660 =input/

 

# rtc devices

rtc0 0:0 0644 >rtc

rtc[1-9] 0:0 0644

 

# misc devices

mmcblk0p[0-9] 0:0 600 @(mkdir -p /opt/emdesktop-running-environment/myfolder/$MDEV && mount /dev/$MDEV /opt/emdesktop-running-environment/myfolder/$MDEV)

mmcblk0 0:0 600 $(umount /opt/emdesktop-running-environment/myfolder/$MDEV* && rm -rf /opt/emdesktop-running-environment/myfolder/$MDEV*)

 

第 4节: /etc/inittab

 

::sysinit:/etc/init.d/rcS

::askfirst:-/bin/sh

::restart:/sbin/init

::ctrlaltdel:/sbin/reboot

::shutdown:/bin/umount -a -r

 

第 4节:其他

 

(1)/etc/passwd

root::0:0:root:/root:/bin/sh

ftp::14:50:FTP User:/var/ftp:

bin:*:1:1:bin:/bin:

daemon:*:2:2:daemon:/sbin:

nobody:*:99:99:Nobody:/:

plg:$1$wwtsqwnk$sWaEJGcJFTqaCW18sbUK7/:502:502:Linux User,,,:/home/plg:/bin/sh

messagebus:*:500:500::/:

 

(2)/etc/hosts

localhost 127.0.0.1

 

(3)/etc/host.conf

order hosts,bind

 

(4)/etc/group

 

root:*:0:

daemon:*:1:

bin:*:2:

sys:*:3:

adm:*:4:

tty:*:5:

disk:*:6:

lp:*:7:lp

mail:*:8:

news:*:9:

uucp:*:10:

proxy:*:13:

kmem:*:15:

dialout:*:20:

fax:*:21:

voice:*:22:

cdrom:*:24:

floppy:*:25:

tape:*:26:

sudo:*:27:

audio:*:29:

ppp:x:99:

500:x:500:plg

501:x:501:fa

 

第五章:制作镜像

不同的镜像需要不同的工具软件,下面的脚本制作了一个 yaffs2文件系统,要制作其他文件系统只需要改变脚本的第 2步。

首先把 mkyaffs2image-128M(来自 mini2440官网 )安装在 /home/clfs/bin目录下,然后执行以下脚本, 就会在 $CLFS/images目录下生成 sysroot.image镜像,这就是要烧写到板上的文件系统镜像。

 

# !/bin/sh

#第一步:删除运行时不需要的文件,移除库中的 debug信息

rm -rf ${CLFS}/sources/build/sysroot

sudo cp -Rv ${SYSROOT} ${CLFS}/sources/build

sudo chown -Rv clfs:clfs ${CLFS}/sources/build/sysroot

cd ${CLFS}/sources/build/sysroot

 

sudo rm -rfv opt/FriendlyARM

rm -fv {,usr/,opt/,opt/qt-embedded/}lib/{*.a,*.la,*.prl}

rm -fv opt/lib/gstreamer-0.10/{*.a,*.la,*.prl}

rm -rfv opt/{doc,man,include,lib/pkgconfig,qt-embedded/lib/pkgconfig} usr/include

rm -rfv opt/share/{doc,gtk-doc,man}

rm -rfv opt/qt-embedded/{bin,include,examples,demos,mkspecs,translations}

#strip debug symbol

sudo find {,usr/,opt/}{bin,lib,sbin,qt-embedded/lib} -type f /

-exec /opt/FriendlyARM/toolschain/4.4.3/bin/arm-linux-strip --strip-debug '{}' ';'

cd ..

sudo chown -Rv root:root sysroot

 

#第 2步:制作镜像

sudo /home/clfs/bin/mkyaffs2image-128M sysroot sysroot.image

#第 3步:安装镜像

sudo chown clfs:clfs sysroot.image

sudo chown -Rv clfs:clfs ${CLFS}/sources/build/sysroot

mv -v sysroot.image ${CLFS}/image

 

第六章:结束语

本文详细给出了一套构件嵌入式 linux系统的方法,这是在学习和开发过程中所积累的财富, 不敢独享,欢迎讨论和指点。

GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐