Busybox工具(https://busybox.NET/):目前的最新版本是:busybox-1.27.2.tar.bz2(2017年8月17日)
Busybox工具就是一个集成了100多个Linxu常用命令和工具的软件,可以称为Linux里面的瑞士军刀吧,它是开源的,同时在不断更新,我们接下来就是用它来搭建我们的最小Linux系统。
网址:https://busybox.net/
BusyBox combines tiny versions of many common UNIX utilities into a single small executable. It provides replacements for most of the utilities you usually find in GNU fileutils, shellutils, etc. The utilities in BusyBox generally have fewer options than their full-featured GNU cousins; however, the options that are included provide the expected functionality and behave very much like their GNU counterparts. BusyBox provides a fairly complete environment for any small or embedded system.
百度机器翻译:BusyBox结合许多常见的UNIX工具小版本到一个单一的小的可执行文件。它提供了你最经常发现在GNU FileUtils,shellutils公用事业等替代,BusyBox的事业通常比功能齐全的GNU的表兄弟更少的选择;然而,选项,包括提供预期的功能和行为很像他们的GNU同行。BusyBox为小或嵌入式系统提供了比较完善的环境。
板子板运行一个完整的操作系统需要四个文件“u-boot-iTOP-4412.bin”,“zImage”,“ramdisk-uboot.img”,“system.img”,文件“u-boot-iTOP-4412.bin”不用烧写,出厂前就有的,是通用的。如果你是不同板子估计也有类似东西。
下载解压busybox
进入网址网址:https://busybox.net/ 官网下载busybox
下载好的busybox-1.27.2.tar.bz2拷贝到ubuntu系统的/home/minilinux下:我用的是virtualbox 装的ubantu16.04,拷贝文件用的共享文件夹。接下来解压它,
sudo tar -xvf busybox-1.27.2.tar.bz2
解压成功,cd到该文件夹里
cd busybox-1.27.2/
下面我们继续吧,接下来是编译和安装Busybox了,因为前面我们花了那么久终于配置好了:
busybox-1.27.2目录下执行: make
编译报错:
解决方法
MTD_FILE_MODE_RAW在/usr/include/mtd/mtd-abi.h中定义,于是将/usr/include/mtd/mtd-abi.h拷贝到busybox的include文件中,然后在nandwrite.c文件中包含该头文件
cd /usr/include/mtd/
sudo cp mtd-abi.h /home/minilinux/busybox-1.27.2/include
(配图没有给权限sudo,普通用户需要权限执行cp,root用户不用)
到/busybox-1.27.1/miscutils下找到nandwrite.c
编辑nandwrite.c的代码
cd /home/minilinux/busybox-1.27.2/miscutils
vim nandwrite.c或者是 gedit nandwrite.c
添加头文件#include “mtd-abi.h” 保存并关闭
注意 #include “mtd-abi.h” 的位置顺序,in出路头文件顺序不能错,#include “mtd-abi.h” 在中间
三个#include顺序必须与上图一样,顺序不一样还是错误。比如三行include让#include “mtd-abi.h”加到最后还是出错,需要加到中间。
cd .. 然后继续make 编译
继续报错:util-linux/blkdiscard.c: In function ‘blkdiscard_main’:
解决办法:
BLKSECDISCARD在/usr/include/linux/fs.h中定义,方法如上所述,将/usr/include/linux/fs.h拷贝到busybox的include文件夹中,然后修改util-linux/blkdiscard.c中头文件包含:
cd /usr/include/linux/
sudo cp fs.h /home/minilinux/busybox-1.27.2/include
退回目录cd .. 执行make ,重新编译
接着继续出错
解决办法:
make menuconfig
Linux System Utilities—>nsenter,去掉该选项,重新编译make。
重新编译,妈的智障,又双叒叕出错了。
解决办法:和前面很类似了,其实这些错误我们应该会很熟悉的,都是这些乱七八糟的错误,慢慢解决就好:
make menuconfig
Coreutils—>sync选项去掉,保存退出,
make重新编译
编译成功,松一口气。别高兴太早,还没结束呢,后面还有好多步骤呢。
安装生成system
接下来我们需要把编译生成的二进制文件安装到刚才我们指定的../system 目录里面,
使用命令“make install”命令安装二进制文件到“../system”目录。 root@zzz:/home/minilinux/busybox-1.27.2# cd ..
root@zzz:/home/minilinux# ls
busybox-1.27.2 busybox-1.27.2.tar.bz2 system
root@zzz:/home/minilinux# cd system/
root@zzz:/home/minilinux/system# ls
bin linuxrc sbin usr
root@zzz:/home/minilinux/system#