建立嵌入式Linux系统
一、Makefile 目标
在Linux顶层目录键入make help,会看到所有目标列表。如下:
$ make ARCH=arm help
Cleaning targets:
clean - remove most generated files but keep the config
mrproper - remove all generated files + config + various backup files
Configuration targets:
config - Update current config utilising a line-oriented program
menuconfig - Update current config utilising a menu based program
xconfig - Update current config utilising a QT based front-end
gconfig - Update current config utilising a GTK based front-end
oldconfig - Update current config utilising a provided .config as base
randconfig - New config with random answer to all options
defconfig - New config with default answer to all options
allmodconfig - New config selecting modules when possible
allyesconfig - New config where all options are accepted with yes
allnoconfig - New minimal config
Other generic targets:
all - Build all targets marked with [*]
* vmlinux - Build the bare kernel
* modules - Build all modules
modules_install - Install all modules
dir/ - Build all files in dir and below
dir/file.[ois] - Build specified target only
dir/file.ko - Build module including final link
rpm - Build a kernel as an RPM package
tags/TAGS - Generate tags file for editors
cscope - Generate cscope index
kernelrelease - Output the release version string
Static analysers
buildcheck - List dangling references to vmlinux discarded sections and
init sections from non-init sections
checkstack - Generate a list of stack hogs
namespacecheck - Name space analysis on compiled kernel
Kernel packaging:
rpm-pkg - Build the kernel as an RPM package
binrpm-pkg - Build an rpm package containing the compiled kernel and
modules
deb-pkg - Build the kernel as an deb package
tar-pkg - Build the kernel as an uncompressed tarball
targz-pkg - Build the kernel as a gzip compressed tarball
tarbz2-pkg - Build the kernel as a bzip2 compressed tarball
Documentation targets:
Linux kernel internal documentation in different formats:
xmldocs (XML DocBook), psdocs (Postscript), pdfdocs (PDF)
htmldocs (HTML), mandocs (man pages, use installmandocs to install)
Architecture specific targets (arm):
* zImage - Compressed kernel image (arch/arm/boot/zImage)
Image - Uncompressed kernel image (arch/arm/boot/Image)
* xipImage - XIP kernel image, if configured (arch/arm/boot/xipImage)
bootpImage - Combined zImage and initial RAM disk
(supply initrd image via make variable INITRD=<path>)
install - Install uncompressed kernel
zinstall - Install compressed kernel
Install using (your) ~/bin/installkernel or
(distribution) /sbin/installkernel or
install to $(INSTALL_PATH) and run lilo
assabet_defconfig - Build for assabet
badge4_defconfig - Build for badge4
bast_defconfig - Build for bast
cerfcube_defconfig - Build for cerfcube
clps7500_defconfig - Build for clps7500
collie_defconfig - Build for collie
corgi_defconfig - Build for corgi
ebsa110_defconfig - Build for ebsa110
edb7211_defconfig - Build for edb7211
enp2611_defconfig - Build for enp2611
ep80219_defconfig - Build for ep80219
epxa10db_defconfig - Build for epxa10db
footbridge_defconfig - Build for footbridge
fortunet_defconfig - Build for fortunet
h3600_defconfig - Build for h3600
h7201_defconfig - Build for h7201
h7202_defconfig - Build for h7202
hackkit_defconfig - Build for hackkit
integrator_defconfig - Build for integrator
iq31244_defconfig - Build for iq31244
iq80321_defconfig - Build for iq80321
iq80331_defconfig - Build for iq80331
iq80332_defconfig - Build for iq80332
ixdp2400_defconfig - Build for ixdp2400
ixdp2401_defconfig - Build for ixdp2401
ixdp2800_defconfig - Build for ixdp2800
ixdp2801_defconfig - Build for ixdp2801
ixp4xx_defconfig - Build for ixp4xx
jornada720_defconfig - Build for jornada720
lart_defconfig - Build for lart
lpd7a400_defconfig - Build for lpd7a400
lpd7a404_defconfig - Build for lpd7a404
lubbock_defconfig - Build for lubbock
lusl7200_defconfig - Build for lusl7200
mainstone_defconfig - Build for mainstone
mx1ads_defconfig - Build for mx1ads
neponset_defconfig - Build for neponset
netwinder_defconfig - Build for netwinder
omap_h2_1610_defconfig - Build for omap_h2_1610
pleb_defconfig - Build for pleb
poodle_defconfig - Build for poodle
pxa255-idp_defconfig - Build for pxa255-idp
rpc_defconfig - Build for rpc
s3c2410_defconfig - Build for s3c2410
shannon_defconfig - Build for shannon
shark_defconfig - Build for shark
simpad_defconfig - Build for simpad
smdk2410_defconfig - Build for smdk2410
spitz_defconfig - Build for spitz
versatile_defconfig - Build for versatile
make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build
make O=dir [targets] Locate all output files in "dir", including .config
make C=1 [targets] Check all c source with $CHECK (sparse)
make C=2 [targets] Force check of all c source with $CHECK (sparse)
Execute "make" or "make all" to build all targets marked with [*]
For further info see the ./README file
二、内核配置
Kconfig(或Kconfig.ext文件)在大约300个内核子目录中存在。Kconfig用于配置处理,其内容被配置子系统解析,表示用于对配置的选择。
配置工具(如gconf)读入来自arch子目录的Kconfig文件,如下:
gconfig:$(obj)/gconf
$< arch/$(ARCH)/Kconfig
取决于你建立的架构,gconf读入指定架构的Kconfig作为顶层配置定义。Kconfig包含大量代码行,看起来如下:
source "drivers/pci/Kconfig"
注:GConf是在基于GNOME2的系统中用于应用程序属性配置和管理的工具,完成类似于Windows操作系统注册表的功能。GConf 包括一个配置数据库系统。
ARM架构的部分Kconfig列表如下:
arch/arm/Kconfig <<<<<< (top level Kconfig)
|-> init/Kconfig
| ...
|-> arch/arm/mach-iop3xx/Kconfig
|-> arch/arm/mach-ixp4xx/Kconfig
| ...
|-> net/Kconfig
| |-> net/ipv4/Kconfig
| | |-> net/ipv4/ipvs/Kconfig
| ...
|-> drivers/char/Kconfig
| |-> drivers/serial/Kconfig
| ...
|-> drivers/usb/Kconfig
| |-> drivers/usb/core/Kconfig
| |-> drivers/usb/host/Kconfig
| ...
|-> lib/Kconfig
三、定制配置选项
为指定硬件平台定制配置选项,如…/arch/arm/Kconfig片段:
source "init/Kconfig"
menu "System Type"
choice
prompt "ARM system type"
default ARCH_RPC
config ARCH_CLPS7500
bool "Cirrus-CL-PS7500FE"
config ARCH_CLPS711X
bool "CLPS711x/EP721x-based"
...
source "arch/arm/mach-ixp4xx/Kconfig
四、内核文档
Linux源码树包含大量的有效信息,在Documentation目录包含大约42个子目录,至少650个文档。虽然这些文档很容易过时,但它提供了各种特定内核子系统或概念的基础信息。
五、所需的组件
除了Linux内核,还需要下列组件来开发、测试和运行你的嵌入式Linux widget:
1)Bootloader移植和配置指定的硬件平台
2)支持所选架构的交叉编译器和相关的toolchain
3)包含支持本地硬件架构/处理器的打包的可执行文件和库的文件系统
4)目标板板载设备的设备驱动器
5)开发环境,包括主机工具软件(tools和utilities)
6)支持特定处理器和主板的Linux内核源码树