1 百度搜索busybox進入busybox官網(https://busybox.net/)做者:恆久力行 QQ:624668529 html
2 將其複製到服務器並解壓縮
tar xjf busybox-1.24.2.tar.bz2
3進入根目錄,在其根目錄下有一個INSTALL文件告訴咱們怎麼使用busybox
什麼都不設置,但要保存設置。而後執行下列指令更改CROSS_COMPILE ?=arm-linux-
CROSS_COMPILE ?=arm-linux-
而後執行make
錯誤1
miscutils/i2c_tools.c: At top level:
miscutils/i2c_tools.c:1046: error: `I2C_FUNC_SMBUS_PEC‘ undeclared here (not in a function)
miscutils/i2c_tools.c:1046: error: initializer element is not constant
miscutils/i2c_tools.c:1046: error: (near initialization for `i2c_funcs_tab[12].value‘)
miscutils/i2c_tools.c:1047: error: initializer element is not constant
miscutils/i2c_tools.c:1047: error: (near initialization for `i2c_funcs_tab[12]‘)
miscutils/i2c_tools.c:1049: error: initializer element is not constant
miscutils/i2c_tools.c:1049: error: (near initialization for `i2c_funcs_tab[13]‘)
miscutils/i2c_tools.c:1051: error: initializer element is not constant
miscutils/i2c_tools.c:1051: error: (near initialization for `i2c_funcs_tab[14]‘)
miscutils/i2c_tools.c:1052: error: initializer element is not constant
miscutils/i2c_tools.c:1052: error: (near initialization for `i2c_funcs_tab[15]‘)
make[1]: *** [miscutils/i2c_tools.o] Error 1
make: *** [miscutils] Error 2
錯誤1 解決方法
別急沒事我們一點一點的解決,首先進入make menuconfig,
去掉 i2c 相關模塊
miscutils/ionice.c: In function `ioprio_set‘
miscutils/ionice.c:23: error: `SYS_ioprio_set‘ undeclared (first use in this function)
miscutils/ionice.c:23: error: (Each undeclared identifier is reported only once
miscutils/ionice.c:23: error: for each function it appears in.)
miscutils/ionice.c: In function `ioprio_get‘:
miscutils/ionice.c:28: error: `SYS_ioprio_get‘ undeclared (first use in this function)
make[1]: *** [miscutils/ionice.o] Error 1
make: *** [miscutils] Error
錯誤2解決方法:
根據提示是ionice出問題了,進入make menuconfig 屏蔽它
去掉 ionice 相關模塊
miscutils/nandwrite.c:117: error: storage size of 'meminfo' isn't known
miscutils/nandwrite.c:118: error: storage size of 'oob' isn't known
miscutils/nandwrite.c:145: error: `MEMGETINFO' undeclared (first use in this function)
miscutils/nandwrite.c:252: error: `MEMREADOOB' undeclared (first use in this function)
miscutils/nandwrite.c:117: warning: unused variable `meminfo'
miscutils/nandwrite.c:118: warning: unused variable `oob'
scripts/Makefile.build:197: recipe for target 'miscutils/nandwrite.o' failed
make[1]: *** [miscutils/nandwrite.o] Error 1
Makefile:741: recipe for target 'miscutils' failed
make: *** [miscutils] Error 2
錯誤3解決方法:
make menuconfig 去掉 nandwrite,nanddump模塊
再次make
錯誤4
miscutils/ubi_tools.c:106: error: `UBI_DEV_NUM_AUTO' undeclared (first use in this function)
miscutils/ubi_tools.c:106: error: (Each undeclared identifier is reported only once
miscutils/ubi_tools.c:106: error: for each function it appears in.)
miscutils/ubi_tools.c:107: error: `UBI_VOL_NUM_AUTO' undeclared (first use in this function)
miscutils/ubi_tools.c:115: error: field `attach_req' has incomplete type
miscutils/ubi_tools.c:116: error: field `mkvol_req' has incomplete type
miscutils/ubi_tools.c:117: error: field `rsvol_req' has incomplete type
miscutils/ubi_tools.c:181: error: `UBI_IOCATT' undeclared (first use in this function)
miscutils/ubi_tools.c:194: error: `UBI_IOCDET' undeclared (first use in this function)
miscutils/ubi_tools.c:237: error: `UBI_DYNAMIC_VOLUME' undeclared (first use in this function)
miscutils/ubi_tools.c:239: error: `UBI_STATIC_VOLUME' undeclared (first use in this function)
miscutils/ubi_tools.c:242: error: `UBI_MAX_VOLUME_NAME' undeclared (first use in this function)
miscutils/ubi_tools.c:247: error: `UBI_IOCMKVOL' undeclared (first use in this function)
miscutils/ubi_tools.c:260: error: `UBI_IOCRMVOL' undeclared (first use in this function)
miscutils/ubi_tools.c:278: error: `UBI_IOCRSVOL' undeclared (first use in this function)
miscutils/ubi_tools.c:294: error: `UBI_IOCVOLUP' undeclared (first use in this function)
scripts/Makefile.build:197: recipe for target 'miscutils/ubi_tools.o' failed
make[1]: *** [miscutils/ubi_tools.o] Error 1
Makefile:741: recipe for target 'miscutils' failed
make: *** [miscutils] Error 2
錯誤4解決辦法:
make menuconfig 去掉 ubi 相關模塊
再次make
錯誤5
util-linux/umount.c: In function `umount_main':
util-linux/umount.c:87: error: `MNT_DETACH' undeclared (first use in this function)
util-linux/umount.c:87: error: (Each undeclared identifier is reported only once
util-linux/umount.c:87: error: for each function it appears in.)
scripts/Makefile.build:197: recipe for target 'util-linux/umount.o' failed
make[1]: *** [util-linux/umount.o] Error 1
Makefile:741: recipe for target 'util-linux' failed
make: *** [util-linux] Error 2
錯誤5解決辦法:
umount 這裏不能去掉了,由於這個功能是須要的 打開源碼看看
// MNT_FORCE and MNT_DETACH (from linux/fs.h) must match
// OPT_FORCE and OPT_LAZY.
{
typedefchar bug[
(OPT_FORCE != MNT_FORCE || OPT_LAZY != MNT_DETACH)?-1:1
];
改爲
// MNT_FORCE and MNT_DETACH (from linux/fs.h) must match
// OPT_FORCE and OPT_LAZY.
{
typedefchar bug[
(OPT_FORCE != MNT_FORCE || OPT_LAZY !=2)?-1:1
];
}
這裏
MNT_DETAC直接改爲2
再次make
錯誤6
debianutils/lib.a(mktemp.o)(.text.mktemp_main+0x9c): In function `mktemp_main':
: warning: the use of `mktemp' is dangerous, better use `mkstemp'
coreutils/lib.a(touch.o)(.text.touch_main+0x1ac): In function `touch_main':
: warning: warning: lutimes is not implemented and will always fail
/work/tools/gcc-3.4.5-glibc-2.3.6/lib/gcc/arm-linux/3.4.5/../../../../arm-linux/bin/ld: Warning: gc-sections option ignored
coreutils/lib.a(sync.o)(.text.sync_main+0x80): In function `sync_main':
: undefined reference to `syncfs'
collect2: ld returned 1 exit status
Makefile:716: recipe for target 'busybox_unstripped' failed
make: *** [busybox_unstripped] Error 1
錯誤6解決辦法:
vi ./coreutils/sync.c
/*
* syncfs is documented to only fail with EBADF,
* which can‘t happen here. So, no error checks.
*/
86行 syncfs(fd);linux
18 行 //config: bool "Enable -d and -f flags (requres syncfs(2) in libc)"服務器
找了一個 arm-libc 中並無這個函數網絡
下載了 busybox-1.23.0.tar.bz2 找到同名文件,發現這個內容明顯要簡單不少。用 1.23 的版本替換 1.24 的。
#include "libbb.h"app
/* This is a NOFORK applet. Be very careful! */ionic
int sync_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int sync_main(int argc UNUSED_PARAM, char **argv IF_NOT_DESKTOP(UNUSED_PARAM))
{
/* coreutils-6.9 compat */
bb_warn_ignoring_args(argv[1]);ide
sync();函數
return EXIT_SUCCESS;
}工具
再次編譯就經過了ui
Your linker does not support --sort-section,alignment
Trying libraries: crypt m
Library crypt is not needed, excluding it
Library m is needed, can't exclude it (yet)
Final link with: m
DOC busybox.pod
DOC BusyBox.txt
DOC busybox.1
DOC BusyBox.html
既然編譯過了,就安裝上吧,執行下列指令安裝。
make CONFIG_PREFIX=/work/nfs_root/first_fs install
安裝上后里面有下列文件
waobot@waobot:/work/nfs_root/first_fs$ ls
bin linuxrc sbin usr
4最小根文件系統:
①/dev/console /dev/null
②init自己,即busybox
③/etc/inittab
④配置文件裏指定的應用程序
⑤c庫
①/dev/console /dev/null
waobot@waobot:/work/nfs_root/first_fs$ mkdir dev
waobot@waobot:/work/nfs_root/first_fs$ cd dev/
waobot@waobot:/work/nfs_root/first_fs/dev$ sudo mknod console c 5 1
[sudo] waobot 的密碼:
waobot@waobot:/work/nfs_root/first_fs/dev$ sudo mknod null c 1 3
作③/etc/inittab:
作⑤c庫:
waobot@waobot:/work/nfs_root/first_fs$ mkdir lib
waobot@waobot:/work/nfs_root/first_fs$ cd /work/tools/gcc-3.4.5-glibc-2.3.6/arm-linux/lib
waobot@waobot:/work/tools/gcc-3.4.5-glibc-2.3.6/arm-linux/lib$ cp *.so* /work/nfs_root/first_fs/lib -d
waobot@waobot:/work/tools/gcc-3.4.5-glibc-2.3.6/arm-linux/lib$ cd /work/nfs_root/first_fs
waobot@waobot:/work/nfs_root/first_fs$ ls
bin dev etc lib linuxrc sbin usr
最小根文件系統已經作好了
5製做yaffs映像文件,完善最小根文件系統
製做工具
waobot@waobot:/work/nfs_root/first_fs$ cd /work/system/
waobot@waobot:/work/system$ tar xjf yaffs_source_util_larger_small_page_nand.tar.bz2
waobot@waobot:/work/system$ cd Development_util_ok/
waobot@waobot:/work/system/Development_util_ok$ cd yaffs2
waobot@waobot:/work/system/Development_util_ok/yaffs2$ cd utils/
waobot@waobot:/work/system/Development_util_ok/yaffs2/utils$ pwd
/work/system/Development_util_ok/yaffs2/utils
waobot@waobot:/work/system/Development_util_ok/yaffs2/utils$ make
waobot@waobot:/work/system/Development_util_ok/yaffs2/utils$ sudo cp mkyaffs2image /usr/local/bin/
waobot@waobot:/work/system/Development_util_ok/yaffs2/utils$ sudo chmod +x /usr/local/bin/mkyaffs2image
waobot@waobot:/work/system/Development_util_ok/yaffs2/utils$ cd /work/nfs_root/
waobot@waobot:/work/nfs_root$ mkyaffs2image first_fs first_fs.yaffs2
遇到一個問題,不能啓動提示:kernel panic - not syncing: No init found. Try passing init= option to kernel.
問題解決:主要緣由是編譯器的問題,我用的是高版本的編譯器,可是庫加載的是低版本的編譯器。換成低版本的編譯器後,改一下環境變量以下
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/work/tools/gcc-3.4.5-glibc-2.3.6/bin"
建立其餘引導文件
①etc/inittab
②etc/init.d/rcS
③etc/fstab
①etc/inittab
若是不想手工掛載,要加一個配置文件:
book@book-desktop:/work/nfs_root/first_fs$ vi etc/inittab
console::askfirst:-/bin/sh
::sysinit:/etc/init.d/rcS
②etc/init.d/rcS增長mdev機制 建立proc路徑和sys路徑
book@book-desktop:/work/nfs_root/first_fs$ vi etc/init.d/rcS
#mount -t proc none /proc
mount -a
mkdir /dev/pts
mount -t devpts devpts /dev/pts
echo /sbin/mdev >/proc/sys/kernel/hotplug
mdev -s
③etc/fstab
book@book-desktop:/work/nfs_root/first_fs$ vi etc/fstab
#device mount-point type options dump fsck order
proc /proc proc defaults 00
sysfs /sys sysfs defaults 00
tmpfs /dev tmpfs defaults 00
到這裏最小根文件系統已經很完善了
6直接從NFS啓動:
重啓能夠看到啓動參數:
bootargs=noinitrd root=/dev/mtdblock3 rootfstype=jffs2 init=/linuxrc console=ttySAC0
修改啓動參數:在linux-2.6.22.6\Documentation的nfsroot.txt裏面有參數的說明
nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]
ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>
bootargs noinitrd root=/dev/nfs nfsroot=192.168.1.51:/work/nfs_root/first_fs ip=192.168.1.11:192.168.1.51:192.168.1.1:255.255.255.0::eth0:off init=/linuxrc console=ttySAC0
OpenJTAG> set bootargs noinitrd root=/dev/nfs nfsroot=192.168.1.51:/work/nfs_root/first_fs ip=192.168.1.11:192.168.1.51:192.168.1.1:255.255.255.0::eth0:off init=/linuxrc console=ttySAC0
OpenJTAG> save
OpenJTAG> boot
到這裏網絡文件系統已經搭建好了,這樣你能夠在服務器上面編輯代碼,編譯,而後在單板上面運行了。
做者:恆久力行 QQ:624668529