📄 00000006.htm
字号:
LD = $(CROSS_COMPILE)ld <BR> CC = $(CROSS_COMPILE)gcc <BR> KERNELPATH = /root/arm/src/linux <BR> <BR> <BR> <BR> <BR>3 内核 <BR> <BR>3.1 概述 <BR> kernel <BR>3.2 编译内核步骤 <BR># 配置内核 <BR># 复制缺省的内核配置文件 <BR>[root@lips gcc-g++]# cd $TOPDIR/src/linux <BR>[root@lips linux]# cp arch/arm/def-configs/iq80321 .config <BR>[root@lips linux]# make menuconfig <BR># 一般来说不需要修改缺省配置 <BR># 根据具体情况可以考虑加上或者去掉某些选项 <BR># 支持 initrd 机制 <BR>Block devices ---> <BR><*> Loopback device support <BR>[*] Initial RAM disk (initrd) support <BR>Character devices ---> <BR><*> Enhanced Real Time Clock Support <BR># 可以去掉这些选项,目前没有用 <BR>Multi-device support (RAID and LVM) ---> <BR>[ ] Multiple devices driver support (RAID and LVM) <BR>< > Include IDE/ATA-2 DISK support <BR>< > Include IDE/ATAPI CDROM support <BR># 修改 Makefile <BR># 如果在前面步骤(安装linux头文件)已经修改则可以跳过这里 <BR># 确认一下,如果定义 PREFIX=/usr/local/arm 这里就需要修改了 <BR># 必须将 CROSS_COMPILE 定义为交叉编译工具的路径前缀 <BR>CROSS_COMPILE = $(PREFIX)/bin/arm-linux- <BR># 编译 <BR>[root@lips linux]# make dep; make bzImage <BR># 最后生成的内核 arch/arm/boot/zImage <BR># 内核配置文件是 .config <BR> <BR> <BR> <BR> <BR>4 根文件系统 <BR> <BR>4.1 概述 <BR> 有了内核之后,还必须有根文件系统(root filesystem)才能使一个Linux系 <BR>统正常运行。根文件系统用于存放系统运行期间所需的应用程序、脚本、配置文件 <BR>等。 <BR>4.2 BusyBox <BR> 主页:<A HREF="http://www.busybox.net/">http://www.busybox.net/</A> <BR> 下载:<A HREF="http://busybox.net/downloads/">http://busybox.net/downloads/</A> <BR> 手册:<A HREF="http://www.busybox.net/downloads/BusyBox.html">http://www.busybox.net/downloads/BusyBox.html</A> <BR>4.2.1 简介 <BR> README <BR> BusyBox combines tiny versions of many common UNIX utilities into a <BR>single <BR> small executable. It provides minimalist replacements for most of th <BR>e utilities <BR> you usually find in GNU coreutils, util-linux, etc. The utilities in <BR> BusyBox <BR> generally have fewer options than their full-featured GNU cousins; h <BR>owever, the <BR> options that are included provide the expected functionality and beh <BR>ave very <BR> much like their GNU counterparts. <BR> BusyBox has been written with size-optimization and limited resource <BR>s in mind. <BR> It is also extremely modular so you can easily include or exclude co <BR>mmands (or <BR> features) at compile time. This makes it easy to customize your embe <BR>dded <BR> systems. To create a working system, just add /dev, /etc, and a Linu <BR>x kernel. <BR> BusyBox provides a fairly complete POSIX environment for any small o <BR>r embedded <BR> system. <BR> <BR> BusyBox目前的最新版本是1.00-pre10(1.0版的发布一再推迟)。 <BR> BusyBox是什么东西?为什么要使用BusyBox呢?正如手册所说,BusyBox是嵌入 <BR>式Linux的“瑞士军刀”。编译安装后的BusyBox只有一个二进制可执行文件busybo <BR>x,它实现了几乎所有常用、必须的应用程序(比如init,shell,getty,ls,cp等 <BR>等),而这些应用程序都以符号链接的形式存在。对用户来说,执行命令的方法并 <BR>没有改变,命令行调用会作为一个参数传给busybox,即可完成相应的功能。 <BR> 使用BusyBox大大简化了根文件系统的制作。如果没有BusyBox的话,在交叉开 <BR>发环境中为目标机准备根文件系统是非常麻烦的,需要分别取得这些应用程序的源 <BR>代码,然后放在前面准备的交叉编译环境中编译得到其可执行代码,全部工作量是 <BR>很大的。而使用BusyBox就可以用一个busybox代替了所有那些应用程序。 <BR> <BR>4.2.2 BusyBox的安装 <BR> INSTALL <BR> 1) Run 'make config' or 'make menuconfig' and select the <BR> functionality that you wish to enable. <BR> 2) Run 'make dep' <BR> 3) Check the Makefile for any Makefile setting you wish <BR> to adjust for your system (things like like setting <BR> your cross compiler, adjusting optimizations, etc) <BR> 4) Run 'make' <BR> 5) Go get a drink of water, drink a soda, visit the bathroom, <BR> or whatever while it compiles. It doesn't take very <BR> long to compile, so you don't really need to waste too <BR> much time waiting... <BR> 6) Run 'make install' or 'make PREFIX=/target install' to <BR> install busybox and all the needed links. Some people <BR> will prefer to install using hardlinks and will instead <BR> want to run 'make install-hardlinks'.... <BR> <BR> 首先,对BusyBox进行配置。 <BR>[root@lips busybox-1.00-pre10]# make menuconfig <BR>---------------- BusyBox Configuration ---------------- <BR>General Configuration ---> <BR>Build Options ---> <BR>Installation Options ---> <BR>Archival Utilities ---> <BR>Coreutils ---> <BR>Console Utilities ---> <BR>Debian Utilities ---> <BR>Editors ---> <BR>Finding Utilities ---> <BR>Init Utilities ---> <BR>Login/Password Management Utilities ---> <BR>Miscellaneous Utilities ---> <BR>Linux Module Utilities ---> <BR>Networking Utilities ---> <BR>Process Utilities ---> <BR>Another Bourne-like Shell ---> <BR>System Logging Utilities ---> <BR>Linux System Utilities ---> <BR>Debugging Options ---> <BR> <BR> Build Options ---> <BR> [*] Build BusyBox as a static binary (no shared libs) <BR> [*] Build with Large File Support (for accessing files > 2 GB) <BR> [*] Do you want to build BusyBox with a Cross Compiler? <BR> (/root/arm/arm-toolchain/bin/arm-linux-) Cross Compiler prefix <BR> () Any extra CFLAGS options for the compiler? <BR> 这里有几个选项要注意:静态编译,省得复制共享库;设置交叉编译器的路径 <BR>,根据我们的情况就要设置为 /root/arm/arm-toolchain/bin/arm-linux-,即 $P <BR>REFIX/bin/arm-linux-(与linux/Makefile中的设置相同)。 <BR> <BR> Installation Options ---> <BR> [*] Don't use /usr <BR> (/root/arm/fakeroot) BusyBox installation prefix <BR> 这里设置安装路径(/root/arm/fakeroot)。不使用/usr的意思是指全部安装在 <BR>/bin和/sbin,不在/usr/bin和/usr/sbin下面安装程序。 <BR> <BR> 其余几个部分用来配置所实现的工具,可以根据需要选择,或者使用缺省配置 <BR>即可。 <BR> 配置完成后,象配置Linux内核一样,当前配置信息会保存在.config文件中。 <BR> <BR> 然后,编译、安装。 <BR>[root@lips busybox-1.00-pre10]# make dep; make; make install <BR> <BR> BTW.BusyBox 版本 stable (0.60.5) 的安装需要手工修改 config.h 和 Mak <BR>efile 文件。 <BR>4.3 根文件系统内容 <BR># /root/arm/fakeroot 目录是将来的根文件系统 <BR># 现在我们已经有了 bin sbin usr ,下面来添加其他的内容, <BR># 关键是 dev 和 etc ,以及必要的 lib 。 <BR>[root@lips busybox-1.00-pre10]# cd /root/arm/fakeroot <BR>[root@lips fakeroot]# mkdir dev etc lib mnt proc root tmp var <BR>[root@lips fakeroot]# ls <BR>bin dev etc lib mnt proc root sbin tmp usr var <BR>[root@lips fakeroot]# <BR>4.3.1 bin, sbin, usr/bin, usr/sbin <BR> bin和sbin下面就是BusyBox编译安装的内容,usr没有用。 <BR>[root@lips fakeroot]# ls bin sbin <BR>bin: <BR>[ chown du gzip md5sum pwd tar uniq <BR>adduser chvt echo head mkdir readlink tee unzip <BR>ar clear egrep hexdump mkfifo reset telnet uptime <BR>arping cmp env hostname mknod rm test usleep <BR>ash cp expr id mktemp rmdir tftp vi <BR>awk cut false install more sed time wc <BR>basename date fgrep ip mount sh top wget <BR>bunzip2 dd find kill mv sleep touch which <BR>busybox deallocvt free killall openvt sort tr whoami <BR>bzcat deluser ftpget ln passwd strings true xargs <BR>cat df ftpput logger pidof su tty yes <BR>chgrp dirname grep login ping sync umount zcat <BR>chmod dmesg gunzip ls ps tail uname <BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -