一, 根文件系統(tǒng)的基本結(jié)構(gòu) 建立目錄見:構(gòu)建嵌入式Linux系統(tǒng)-開發(fā)工具 $ cd ${PRJROOT}/rootfs 二, 鏈接庫(kù) 查看應(yīng)用程序依存哪些動(dòng)態(tài)鏈接庫(kù)(不可使用宿主機(jī)的ldd),示范使用readelf取回BusyBox工具程序的依存關(guān)系: $ arm-linux-readelf -a ${PRJROOT}/rootfs/bin/busybox | grep "Shared library" 復(fù)制必要glibc組件命令: $ cd ${TARGET_PREFIX}/lib $ for file in libc libcrypt libdl libm libpthread libresolv libutil > do > cp $file-*.so ${PRJROOT}/rootfs/lib > cp -d $file.so.[*0-9] ${PRJROOT}/rootfs/lib > done $ cp -d ld*.so* ${PRJROOT}/rootfs/lib $ arm-linux-strip ${PRJROOT}/rootfs/lib/*.so 三, 復(fù)制內(nèi)核模塊目錄到根文件系統(tǒng) $ cp -a ${PRJROOT}/images/modules-2.4.26/* ${PRJROOT}/rootfs 四, 內(nèi)核映像 如果準(zhǔn)備將引導(dǎo)加載程序設(shè)置成從根文件系統(tǒng)來啟動(dòng)內(nèi)核,則此刻將內(nèi)核映像復(fù)制到目標(biāo)板的根文件系統(tǒng): $ cd ${PRJROOT}/images $ cp zImage-2.4.26 ${PRJROOT}/rootfs/boot $ cp 2.4.26.config ${PRJROOT}/rootfs/boot 五, 設(shè)備文件 內(nèi)核源碼樹的Documentation/dvices.txt文檔是靜態(tài)設(shè)備主要和次要編號(hào)的正式信息來源. $ cd ${PRJROOT}/rootfs/dev $ su -m Password: # mknod -m 600 mem c 1 1 # mknod -m 666 null c 1 3 # mknod -m 666 zero c 1 5 # mknod -m 644 random c 1 8 # mknod -m 600 tty0 c 4 0 # mknod -m 666 tty c 5 0 # mknod -m 600 console c 5 1 # exit $ ln -s /proc/self/fd fd $ ln -s fd/0 stdin $ ln -s fd/1 stdout $ ln -s fd/2 stderr 六, BusyBox $ cd ${PRJROOT}/sysapps/busybox-0.60.5 $ make TARGET_ARCH=arm CROSS=arm-linux- PREFIX=${PRJROOT}/rootfs all install 七, 定制應(yīng)用程序 略 八, 系統(tǒng)初始化 Busybox init 1.配置/etc/inittab文件 #=================示例================================== # Boot-time system configuration/initialization script. # This is run first except when booting in single-user mode. # ::sysinit:/etc/init.d/rcS # /bin/sh invocations on selected ttys # # Start an "askfirst" shell on the console (whatever that may be) ::askfirst:-/bin/sh console::once:/usr/sbin/inetd # Stuff to do when restarting the init process ::restart:/sbin/init # Stuff to do before rebooting ::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1 ::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1 #=================end=================================== 2.配置/etc/init.d/rcS文件 #=================示例================================== #! /bin/sh ##set -x hostname S3C2410 echo "FSC2410 RootDisk" # Mount the /proc file system mount -t proc proc /proc mount -t usbdevfs none /proc/bus/usb mount -t devpts none /dev/pts echo "mount tmpfs filesystem to /tmp" mount -t ramfs none /var mkdir /var/log mkdir /var/lock mkdir /var/run mkdir /var/empty mkdir /var/tmp mount -t tmpfs none /var/tmp ln -s /dev/fb/0 /dev/fb0 ln -s /dev/touchscreen/0raw /dev/touchpanel cd /dev mknod tty0 c 4 0 cd / cp /usr/pen.cfg /tmp echo "mount yaffs file system to nand flash partition 3" mount -t yaffs /dev/mtdblock/3 /mnt export PATH=$PATH:/mnt/recorder/ ls / clear ifconfig lo 127.0.0.1 netmask 255.0.0.0 route add -net 127.0.0.0 netmask 255.0.0.0 dev lo alias ll=‘ls -l‘ # start up the logins (on serial ports) # finished echo "/etc/init.d/rcS done." # Fall through to a shell prompt #exit 0 echo "start recorder program" cd /mnt/recorder/ recorder #=================end=================================== |
|