#tar -zxvf cvs-root.tar.gz #cd cvs/yaffs2/ #./patch-ker.sh c ~/work/embedded_linux/kernel/linux-2.6.31/ |
2. 配置内核,使其对yaffs2文件系统的支持。配置完后重新编译内核,下载到开发板上
File systems ---> < > Second extended fs support < > Ext3 journalling file system support < > The Extended 4 (ext4) filesystem < > Reiserfs support < > JFS filesystem support < > XFS filesystem support < > OCFS2 file system support < > Btrfs filesystem (EXPERIMENTAL) Unstable disk format [*] Enable POSIX file locking API [*] Dnotify support [*] Inotify file change notification support [*] Inotify support for userspace [ ] Quota support Kernel automounter support Kernel automounter version 4 support (also supports v3) FUSE (Filesystem in Userspace) support Caches ---> CD-ROM/DVD Filesystems ---> <*> ISO 9660 CDROM file system support [ ] Microsoft Joliet CDROM extensions [ ] Transparent decompression extension < > UDF file system support DOS/FAT/NT Filesystems ---> <*> MSDOS fs support <*> VFAT (Windows-95) fs support (437) Default codepage for FAT (iso8859-1) Default iocharset for FAT < > NTFS file system support Pseudo filesystems ---> [*] Miscellaneous filesystems ---> --- Miscellaneous filesystems < > ADFS file system support (EXPERIMENTAL) < > Amiga FFS file system support (EXPERIMENTAL) < > Apple Macintosh file system support (EXPERIMENTAL) < > Apple Extended HFS file system support < > BeOS file system (BeFS) support (read only) (EXPERIMENTAL) < > BFS file system support (EXPERIMENTAL) < > EFS file system support (read only) (EXPERIMENTAL) <*> YAFFS2 file system support -*- 512 byte / page devices [ ] Use older-style on-NAND data format with pageStatus byte [ ] Lets Yaffs do its own ECC -*- 2048 byte (or larger) / page devices [*] Autoselect yaffs2 format [ ] Disable lazy loading [ ] Turn off wide tnodes [ ] Force chunk erase check [*] Cache short names in RAM <*> Journalling Flash File System v2 (JFFS2) support (0) JFFS2 debugging verbosity (0 = quiet, 2 = noisy) [*] JFFS2 write-buffering support [ ] Verify JFFS2 write-buffer reads [*] JFFS2 summary support (EXPERIMENTAL) [ ] JFFS2 XATTR support (EXPERIMENTAL) [ ] Advanced compression options for JFFS2 <*> Compressed ROM file system support (cramfs) SquashFS 4.0 - Squashed file system support [ ] Additional option for memory-constrained systems < > FreeVxFS file system support (VERITAS VxFS(TM) compatible) < > Minix file system support < > SonicBlue Optimized MPEG File System support < > OS/2 HPFS file system support < > QNX4 file system support (read only) <*> ROM file system support RomFS backing stores (Block device-backed ROM file system support) -- < > System V/Xenix/V7/Coherent file system support < > UFS file system support (read only) < > NILFS2 file system support (EXPERIMENTAL) [*] Network File Systems ---> Partition Types ---> -*- Native language support ---> < > Distributed Lock Manager (DLM) ---> |
3. 下载并编译busybox生成文件系统所需要的应用程序,最新的busybo
1)解压busybox源码,修改Makefile使之编译成ARM平台:
#tar -jxvf busybox-1.18.5.tar.bz2 #cd busybox-1.18.5 #vi Makefile |
大概164行改成CROSS_COMPILE = arm-linux- ,190行改成ARCH = arm
2)配置busybox选项,下面只列出了要注意的地方,没有列出的默认即可
Busybox Settings ---> General Configuration ---> Buffer allocation policy (Allocate with Malloc) ---> [*] Show verbose applet usage messages [*] Store applet usage messages in compressed form [*] Support --install [-s] to install applet links at runtime [*] Enable locale support (system needs locale for this to work) [*] Support for --long-options [*] Use the devpts filesystem for Unix98 PTYs [*] Support writing pidfiles [*] Runtime SUID/SGID configuration via /etc/busybox.conf [*] Suppress warning message if /etc/busybox.conf is not readable (/proc/self/exe) Path to BusyBox executable Build Options ---> [*] Build BusyBox as a static binary (no shared libs) [*] Build with Large File Support (for accessing files > 2 GB) Installation Options ---> [ ] Don't use /usr Applets links (as soft-links) ---> (./_install) BusyBox installation prefix Busybox Library Tuning ---> (6) Minimum password length (2) MD5: Trade Bytes for Speed [*] Faster /proc scanning code ( 100 bytes) [*] Command line editing (1024) Maximum length of input [*] vi-style line editing commands (15) History size [*] History saving [*] Tab completion [*] Fancy shell prompts (4) Copy buffer size, in kilobytes [*] Use ioctl names rather than hex values in error messages [*] Support infiniband HW Linux Module Utilities ---> (/lib/modules) Default directory containing modules (modules.dep) Default name of modules.dep [*] insmod [*] rmmod [*] lsmod [*] modprobe --- Options common to multiple modutils
|
3)编译和安装busybox,安装完后会在busybox-1.18.5/_install/目录下生成:bin、linuxrc、sbin、usr
4. 开始构建文件系统
1)新建一个目录root-mini2440,把busybox-1.18.5/_install/目录下生成:bin、linuxrc、sbin、usr复制过来,并且在该目录下创建文件系统所需要的其他目录
#mkdir root-mini2440
#cp -rf busybox-1.18.5/_install/* root-mini2440/ #cd root-mini2440/ #mkdir dev etc home lib mnt opt proc tmp var www |
2)向各目录中添加文件系统所需要的目录或文件,没有提到的就不用添加。
"dev"目录,创建两个设备文件:
#mknod console c 5 1 #mknod null c 1 3 |
"etc"目录,创建各种配置文件并向里面添加内容,没有列出的就不用添加:
boa/boa.conf: boa WEB服务器配置文件,暂时为空。可以不加。
group: 系统用户组配置文件,内容如下:
root:*:0: daemon:*:1: bin:*:2: sys:*:3: adm:*:4: tty:*:5: disk:*:6: lp:*:7:lp mail:*:8: news:*:9: uucp:*:10: proxy:*:13: kmem:*:15: dialout:*:20: fax:*:21: voice:*:22: cdrom:*:24: floppy:*:25: tape:*:26: sudo:*:27: audio:*:29: ppp:x:99: 500:x:500:plg 501:x:501:fa |
inittab: 系统init进程配置文件,内容如下:
# /etc/inittab ::sysinit:/etc/init.d/rcS console::askfirst:-/bin/sh ::ctrlaltdel:/sbin/reboot ::shutdown:/bin/umount -a -r |
mime.types: 暂时为空。可以不加。
passwd: 系统密码文件,内容如下:
root::0:0:root:/:/bin/sh ftp::14:50:FTP User:/var/ftp: bin:*:1:1:bin:/bin: daemon:*:2:2:daemon:/sbin: nobody:*:99:99:Nobody:/: sky::502:502:Linux User,,,:/home/mxh2440:/bin/sh |
rc.d/init.d/httpd:可以不加。 内容如下:
#!/bin/sh
base=boa
# See how we were called. case "$1" in start) /usr/sbin/$base ;; stop) pid=`/bin/pidof $base` if [ -n "$pid" ]; then kill -9 $pid fi ;; esac
exit 0 |
sysconfig/HOSTNAME: 主机名称文件,内容如下:
fstab: 系统挂载文件系统列表,内容如下:
# device mount-point type options dump fsck order none /proc proc defaults 0 0 none /dev/pts devpts mode=0622 0 0 tmpfs /dev/shm tmpfs defaults 0 0 |
init.d/rcS: 系统启动加载项,内容如下:
#!/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin runlevel=S prevlevel=N umask 022 export PATH runlevel prevlevel
# # Trap CTRL-C &c only in this shell so we can interrupt subprocesses. # /bin/mount -t proc none /proc /bin/mount -t tmpfs none /tmp /bin/mount -t tmpfs none /var
/bin/mkdir -p /var/log
/bin/hostname -F /etc/sysconfig/HOSTNAME |
mdev.conf: mdev设备配置文件,暂时为空。可以不加。
net.conf: 网络配置文件,暂时为空。可以不加。
profile: 用户环境配置文件,内容如下:
# Ash profile # vim: syntax=sh
# No core files by default #ulimit -S -c 0 > /dev/null 2>&1
USER="`id -un`" LOGNAME=$USER PS1='[mxh2440]# ' PATH=$PATH:/usr/local/bin LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib HOSTNAME=`/bin/hostname`
export USER LOGNAME PS1 PATH LD_LIBRARY_PATH |
resolv.conf: DNS配置文件,内容如下:
"home"目录:创建一个mxh2440目录,与etc目录passwd文件中的sky相对应
"lib"目录:这个里面放的都是库文件,直接从交叉编译器的库文件目录中拷贝过来: 也可以不加载库等程序运行出错提示需要加载库的时候再传进去也可以。
#cp -f /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib/*so* ./ |
5. 使用yaffs制作工具编译构建好的文件系统。先解压yaffs_source_util_larger_page_nand.tar.bz2(这个工具是百问网韦东山提供的,可以在他的网站上下载)。
#tar xjvf yaffs_source_util_larger_page_nand.tar.bz2 #cd Development_util_ok/yaffs2/utils
#make 生成mkyaffs2image工具,将其copy到usr/local/bin下面即可. |
6. 用mkyaffs2image制作yaffs2文件系统.
#mkyaffs2image root_mini2440/ root_mini2440.bin |
烧到nandflash运行:
7.关于使用glibc库(修改: 2011.7.13)
可以先到google上搜索一下glibc了解大概,对于嵌入式系统的glibc库来说,只需加载器和动态库。
在制作交叉编译器的时候,已经生成了glibc库,可以直接使用。我使用的是openmoko团队制作的arm-linux-gcc 4.1.2版本编译器。加载器为/opt/toolchains/arm920t-eabi/arm-angstrom-linux-gnueabi/lib/目录下的ld-2.5.so 和 ld-linux.so.3文件。其他动态库可根据运行程序需要来加载。
eg:编写一个test.c程序。
- #include <stdio.h>
- int main()
- {
- printf("Hello,world!\n");
- return 1;
- }
编译:#arm-linux-gcc test.c -o test
查看库文件依赖关系:arm-linux-readelf -a test | grep "Shared
可知:程序test依赖的库文件为libc.so.6,到交叉编译器中找到该文件即是。
也可以直接把程序copy到开发板,运行该程序,或提示出现缺少libc.so.6库文件的。
阅读(1122) | 评论(0) | 转发(0) |