00. 目录
01. BusyBox概述
BusyBox 是一个集成了三百多个最常用Linux命令和工具的软件。BusyBox 包含了一些简单的工具,例如ls、cat和echo等等,还包含了一些更大、更复杂的工具,例grep、find、mount以及telnet。有些人将 BusyBox 称为 Linux 工具里的瑞士军刀。简单的说BusyBox就好像是个大工具箱,它集成压缩了 Linux 的许多工具和命令,也包含了 Linux 系统的自带的shell。
BusyBox 将许多具有共性的小版本的UNIX工具结合到一个单一的可执行文件。这样的集合可以替代大部分常用工具比如的GNU fileutils , shellutils等工具,BusyBox提供了一个比较完善的环境,可以适用于任何小的嵌入式系统。
02. 下载BusyBox
csdn下载:busybox-1.36.1.tar.bz2
03. 编译BusyBox
3.1 解压文件
deng@local:~/arm$ tar -xjvf busybox-1.21.1.tar.bz2
3.2 进入busybox目录
deng@local:~/arm$ cd busybox-1.21.1/
deng@local:~/arm/busybox-1.21.1$ pwd
/home/deng/arm/busybox-1.21.1
deng@local:~/arm/busybox-1.21.1$
3.3 执行make menuconfig
deng@local:~/arm/busybox-1.21.1$
deng@local:~/arm/busybox-1.21.1$ make menuconfig
3.4 选择设置选项
3.5 选择编译选项
3.6 设置交叉编译前缀
3.7 输入arm-linux-
3.7 编译busybox
deng@local:~/arm/busybox-1.21.1$ make
3.8 安装busybox
deng@local:~/arm/busybox-1.21.1$ make install
3.9 查看生成的文件
deng@local:~/arm/busybox-1.21.1$ ls _install
bin linuxrc sbin usr
deng@local:~/arm/busybox-1.21.1$
04. 最小文件系统制作
4.1 创建共享目录
deng@local:~/arm/busybox-1.21.1$ mkdir ~/filesystem
deng@local:~/arm/busybox-1.21.1$
4.2 拷贝busybox编译好的文件到rootfs中
deng@local:~/arm/busybox-1.21.1$ cp _install/* /home/deng/filesystem/ -rf
deng@local:~/arm/busybox-1.21.1$
4.3 拷贝etc目录
deng@local:~/arm/busybox-1.21.1$ cp examples/bootfloppy/etc ~/filesystem/ -rf
deng@local:~/arm/busybox-1.21.1$
4.4 拷贝库文件
deng@local:~/arm/busybox-1.21.1$ cp /usr/local/arm/4.5.1/arm-none-linux-gnueabi/lib/* ~/filesystem/lib/ -rf
deng@local:~/arm/busybox-1.21.1$
4.5 手动创建目录
deng@local:~/filesystem$ pwd
/home/deng/filesystem
deng@local:~/filesystem$ mkdir mnt media misc home sys proc tmp var dev boot net opt
deng@local:~/filesystem$
4.6 修改配置文件etc/profile
deng@local:~/filesystem$ pwd
/home/deng/filesystem
deng@local:~/filesystem$ cat etc/profile
# /etc/profile: system-wide .profile file for the Bourne shells
echo "=============================="
echo " welcom to deng system "
echo "=============================="
export PS1="[root@deng \W]"
deng@local:~/filesystem$
4.7 修改rcS配置文件
deng@local:~/filesystem$ vim etc/init.d/rcS
deng@local:~/filesystem$ cat etc/init.d/rcS
#! /bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
mount -t sysfs none /tmp
mount -t sysfs none /dev
/sbin/mdev -s
deng@local:~/filesystem$ pwd
/home/deng/filesystem
deng@local:~/filesystem$
4.8 修改inittab文件
deng@local:~/filesystem$ pwd
/home/deng/filesystem
deng@local:~/filesystem$ vim etc/inittab
deng@local:~/filesystem$ cat etc/inittab
::sysinit:/etc/init.d/rcS
#::respawn:-/bin/sh
ttySAC0::askfirst:-/bin/sh
#::ctrlaltdel:/bin/umount -a -r
deng@local:~/filesystem$
4.9 设置nfs共享
deng@local:~/filesystem$ sudo vim /etc/exports
# 最后一行添加以下内容
/home/deng/filesystem *(rw,sync,no_root_squash)
4.10 重启nfs服务
deng@local:~/filesystem$ chmod -R 755 /home/deng/filesystem/
deng@local:~/filesystem$ sudo systemctl restart nfs-kernel-server
deng@local:~/filesystem$
05. 设置开发板参数
5.1 进入Uboot
DengJin# setenv bootargs noinitrd root=/dev/nfs nfsroot=/fs ,rsize=1024,wsize=1024 ip=10.36.104.240:10.36.104.180:10.36.104.1:255.255.255.0::eth0:off init=/linuxrc console=ttySAC1,115200
DengJin# saveenv
Saving Environment to MMC...
Writing to MMC(2)... done
DengJin#
参数分析:
(1)root=/dev/nfs
告诉内核根文件系统是NFS;(2)nfsroot=10.36.104.180:/filesystem
告诉内核根文件系统在NFS服务器上的路径;
10.36.104.180:NFS服务器的ip地址;
/filesystem:根文件系统在NFS服务器上的路径;(3)ip=10.36.104.240:10.36.104.180:10.36.104.1:255.255.255.0::eth0:off
第一个参数为开发板ip地址;
第二个为服务器ip地址;
第三个是网关;
第四个是掩码;
第五个是开发板名字,可以不填;
第六个将ip地址复制给哪个网卡;
第七个关闭动态ip获取;
(4)init=/linuxrc
告诉内核init进程的路径是"/linuxrc";
(5)console=ttySAC1,115200
指定控制台是串口ttySAC1,波特率是115200;
补充:可以指定nfs版本,用"nfsvers=3"
5.2 重新启动uboot
DengJin#
DengJin# reset
5.3 启动之后的效果
[ 4.935000] ALSA device list:
[ 4.938000] #0: I2S-alc5623
[ 4.940000] #1: SPDIF-Transciever
[ 7.904000] PHY: stmmac-0:04 - Link is Up - 100/Full
[ 9.969000] VFS: Mounted root (nfs filesystem) on device 0:11.
[ 9.971000] devtmpfs: mounted
[ 9.973000] Freeing init memory: 248K
[ 9.976000] Write protecting the kernel text section c0008000 - c094d000
[ 9.985000] rodata_test: attempting to write to read-only section:
[ 9.989000] write to read-only section trapped, success
==============================
welcom to deng system
==============================
[deng@local /]#
06. 讨论
嵌入式开发企鹅群: 143847203