ARM 根文件系统制作
1 交叉编译busybox
版本:busybox-1.22.0.tar.bz2
修改 Makefile 添加交叉编译器路径
ARCH ?= arm
CROSS_COMPILE ?= /opt/arm-2009q1/bin/arm-none-linux-gnueabi-
配置busybox
Build Options --->
[*] Build BusyBox as a static binary (no shared libs)
General Configuration --->
[*] Don't use /usr
Linux System Utilities --->
[*] mount
[*]Support mounting NFS file systems on Linux < 2.6.23
make
make install
生成文件在新建目录 _install 里
2 创建目录 filesys
cd filesys
创建目录 bin boot dev etc home lib media mnt opt proc root sbin srv sys tmp usr var
3 复制编译出的busybox _install里的内容到 filesys
注意链接文件的复制
cp -rf "src" "dest"
4 配置/etc
4.1 添加文件
/etc/group /etc/passwd /etc/mdev.conf
内容:
/etc/group
root:*:0:
/etc/passwd
root::0:0:root:/home/root:/bin/sh
/etc/mdev.conf
空
4.2 创建文件
/etc/fstab
内容:
proc /proc proc defaults 0 0
tmpfs /tmp tmpfs defaults,size=5M 0 0
#执行mount -a 命令时自动挂载
4.3 创建文件
/etc/inittab
内容:
::sysinit:/etc/init.d/rcS
::askfirst:/bin/sh
#ttyS0:2345:respawn:/sbin/getty 115200 ttyS0 # 还没有搞明白
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
::restart:/sbin/init
#init 进程执行
4.4 创建文件
/etc/init.d/rcS
内容:
#!/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin
runlevel=S
prevlevel=N
umask 022
export PATH runlevel prevlevel
echo "---------------mount all--------------"
mount -a
echo 'mount nand flash file system...'
mount -t jffs2 /dev/mtdblock4 /mnt/nand
# mount devpts in order to use telnetd
###########################################################################
########## Telnet Server ######################
echo "---------------mount devpts------------"
cp -rf /dev/* /tmp
mount -t tmpfs tmpfs /dev
cp -rf /tmp/* /dev
rm -rf /tmp/*
echo "---------------Start mdev-------------"
mount -t sysfs sysfs /sys
echo /sbin/mdev>/proc/sys/kernel/hotplug
mdev -s
echo "........Start Telnetd Server........."
./etc/init.d/telnetd start
mount -t devpts devpts /dev/pts
sleep 1
########## Telnet Server ######################
###########################################################################
echo "**************************************"
echo "Kernel version:linux-2.6.24"
echo "DM6467T rootfs"
echo "Date:2010.12.22"
echo "**************************************"
ifconfig eth0 192.168.1.7
添加可执行权限
chomd +x /etc/init.d/rcS
4.5 创建文件 /etc/init.d/telnetd
内容:
#! /bin/sh
telnetd=/sbin/telnetd
test -x "$telnetd" || exit 0
case "$1" in
start)
echo -n "Starting telnet daemon"
start-stop-daemon --start --quiet --exec $telnetd
echo "."
;;
stop)
echo -n "Stopping telnet daemon"
start-stop-daemon --stop --quiet --pidfile /var/run/telnetd.pid
echo "."
;;
*)
echo "Usage: /etc/init.d/telnetd {start|stop}"
exit 1
esac
exit 0
添加可执行权限
chomd +x /etc/init.d/telnetd
5 telnet 服务
./etc/init.d/telnetd start
mount -t devpts devpts /dev/pts
配置方式 1:
在rcS中添加:
cp -rf /dev/* /tmp
mount -t tmpfs tmpfs /dev
cp -rf /tmp/* /dev
rm -rf /tmp/*
mount -t sysfs sysfs /sys
echo /bin/mdev > /proc/sys/kernel/hotplug
mdev -s #映射系统驱动创建的设备节点(比较全)
配置方式 2:
手动创建节点 目录
mkdir /dev/pts
mknod ptmx c 5 2
mknod tty c 5 0
mknod tty0 c 4 0
mknod tty1 c 4 1
mknod tty2 c 4 2
mknod tty3 c 4 3
mknod tty4 c 4 4
6 配置/dev
创建节点
mknod console c 5 1
mknod null c 1 3
mknod mtdblock4 b 31 4
......
......
7 添加动态链接库
复制交叉编译链中的动态库
/opt/arm-2009q1/arm-none-linux-gnueabi/libc/lib /../..filesys/lib
/opt/arm-2009q1/arm-none-linux-gnueabi/libc/usr/lib /../..filesys/usr/lib
否则 执行程序时报 error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
到此 跟文件系统内容创建完毕
打包cramfs
工具mkcramfs 下载编译不是交叉编译
打包:
/opt/cramfs-1.1/mkcramfs /home/zhujinju/workspace/myrootfs/filesys cramfsImage_my6467T
解包:
cd /root/workspace/myfilefs
mkdir filesys
mkdir rdmnt2
mount -t cramfs -o loop cramfsImage_my6467T rdmnt2/
cd rdmnt2
tar -cf - . | tar -C ../filesys/ -xpf -
cd /root/workspace/dm6467t_root_fs
chown -R root filesys/
chmod -R a+rwx filesys/
umount rdmnt2/
烧写命令:
tftpboot 0x82000000 cramfsImage_my6467T #把文件上传到内存地址0x82000000
nand erase 0x560000 0x1000000 #擦除nand flash 地址0x560000 大小 (16M = 0x1000000)
nand write 0x82000000 0x560000 0x1000000 #把内存地址0x82000000 16M内容 写到nand flash 地址0x560000 大小 (16M = 0x1000000)