嵌入式Linux之我行,主要讲述和总结了本人在学习嵌入式linux中的每个步骤。一为总结经验,二希望能给想入门嵌入式Linux的朋友提供方便。如有错误之处,谢请指正。
一、移植环境
- 主 机:VMWare--Fedora 9
- 开发板:Mini2440--64MB Nand
- 编译器:arm-linux-gcc-4.3.2
- yaffs补丁:cvs-root.tar.gz 这里下载
- Busybox:busybox-1.13.0.tar.tar
- yaffs制作工具:mkyaffs2image.tgz(友善提供)
二、移植步骤
1. 准备工作目录和进入工作目录
2. 给内核打上yaffs补丁,使内核对yaffs的支持
#tar -zxvf cvs-root.tar.gz #cd cvs/yaffs2/ #./patch-ker.sh c /root/my2440/linux-2.6.30.4/
|
3. 配置内核,使其对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) --->
|
4. 编译busybox生成文件系统所需要的应用程序
1)解压busybox源码,修改Makefile使之编译成ARM平台:
#tar -jxvf busybox-1.13.0.tar.tar #cd busybox-1.13.0 #gedit Makefile
|
大概164行改成CROSS_COMPILE = arm-linux- ,189行改成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 [ ] Support version 2.2/2.4 Linux kernels [*] Support tainted module checking with new kernels [*] Support for module.aliases file [*] Support for module.symbols fileLinux System Utilities --->
|
3)编译和安装busybox,安装完后会在
busybox-1.13.0/_install/目录下生成:bin、linuxrc、sbin、usr
5. 开始构建文件系统
1)新建一个目录root-2.6.30.4,把busybox-1.13.0/_install/目录下生成:bin、linuxrc、sbin、usr复制过来,并且在该目录下创建文件系统所需要的其他目录
#mkdir root-2.6.30.4 #cp -rf busybox-1.13.0/_install/* root-2.6.30.4/ #cd root-2.6.30.4/ #mkdir dev etc home lib mnt opt proc tmp var www
|
2)向各目录中添加文件系统所需要的目录或文件,没有提到的就不用添加。这里要注意各种文件的权限,建议都改为777,命令:#chmod 777 文件名
"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/sky:/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='[\u@\h \W]\# ' 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"目录:创建一个sky目录,与etc目录passwd文件中的sky相对应
"lib"目录:这个里面放的都是库文件,直接从交叉编译器的库文件目录中拷贝过来:
#cp -f /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib/*so* lib/ -a
|
6. 使用yaffs制作工具编译构建好的文件系统。先解压mkyaffs2image.tgz(这个工具是友善提供的,可以在他们的网站上下载),会自动解压到开发主机的/usr/sbin/目录下。编译后生成的文件系统镜像
root-2.6.30.4.bin也在这个目录下
#tar -zxvf mkyaffs2image.tgz #mkyaffs2image root-2.6.30.4/ root-2.6.30.4.bin
|
7. 下载文件系统镜像到开发板上测试,使用情况如下:
三、结束语
现在文件系统成功移植上去了,加上上一篇章的内核移植,至此开发板可以运行起来了。但是各种外设还不能正常使用,后续的篇章将逐步移植各种设备的驱动,使之完善。
阅读(12395) | 评论(13) | 转发(20) |