您的位置:首页 > 其它

基于busybox-1.10.1的简易根文件系统制作

2012-11-22 11:31 441 查看
1) 解压busybox,当前目录为/new_disk/weiyan/

tar jxf /new_disk/weiyan/busybox-1.10.1.tar.bz2
cd busybox-1.10.1

2) 修改体系架构并指定交叉编译器
vi Makefile,将175行和176行的
ARCH ?= $(SUBARCH)
CROSS_COMPILE ?=
修改为
ARCH ?= arm
CROSS_COMPILE ?= arm-linux-

3) 简单配置busybox
make defconfig #载入默认配置
make menuconfig
Busybox Settings --->
Busybox Library Tuning --->
[*] Additional editing keys
[*] vi-style line editing commands
[*] History saving
[*] Fancy shellprompts
#添加对转义命令提示符和快捷键的支持
Linux Module Utilities --->
[ ] Support version 2.2.x to 2.4.x Linux kernels
#取消对旧内核模块加载功能的支持
Miscellaneous Utilities --->
[ ] taskset #取消导致编译错误的CPU绑定支持,
Shells --->
[*] alias support #加入对命令别名的支持

4) 编译,并安装到_install目录
make && make install

5) 建立文件系统目录
mkdir /new_disk/weiyan/rootfs
cd /new_disk/weiyan/rootfs
mkdir lib dev etc etc/init.d

6) 复制busybox和库文件
cp /new_disk/weiyan/busybox-1.10.1/_install/* ./ -a
cp /usr/local/arm/3.4.1/arm-linux/lib/*so* lib -a
rm lib/libstdc++.so*
7) 建立必要的启动节点
mknod -m 660 dev/console c 5 1
mknod -m 660 dev/null c 1 3
mknod -m 660 dev/tty0 c 4 0
mknod -m 660 dev/tty1 c 4 1
mknod -m 660 dev/tty2 c 4 2
mknod -m 660 dev/tty3 c 4 3
mknod -m 660 dev/tty4 c 4 4

8) 建立初始化脚本
touch etc/init.d/rcS
chmod 777 etc/init.d/rcS

9) 建立并格式化ext2格式的ram盘镜像
cd ..
dd if=/dev/zero of=ramfs.img bs=1k count=4k
mkfs.ext2 -F -m0 ramfs.img

10) 挂载ram盘并导入文件
mkdir ramfs
mount -o loop ramfs.img ramfs
cp -a rootfs/* ramfs
umount ramfs
11) 生成压缩的ram盘镜像
gzip -9 ramfs.img
cp ramfs.img.gz /new_disk/tftp

12) 启动开发板,修改U-boot的启动参数
设置ram盘的加载地址为0x33000000,大小为0x200000
WEIYAN # setramopt root=/dev/ram0 initrd=0x33000000,0x200000
WEIYAN # set bootargs $(ramopt) console=ttySAC0
保存修改
save

13) 下载ram盘镜像和内核,并从sdram启动内核
WEIYAN # tftp 0x33000000 ramfs.img.gz
WEIYAN # tftp 0x31000000 uImage
WEIYAN # bootm 0x31000000

14) 启动运行结果
RAMDISK: Compressed image found at block 0
VFS: Mounted root (ext2 filesystem).
Freeing init memory: 136K
init started: BusyBox v1.10.1 (2008-03-02 02:33:43 CST)
starting pid 791, tty '': '/etc/init.d/rcS'
usb 1-1: new full speed USB device using s3c2410-ohci and address 2

Please press Enter to activate this console.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: