rootfs根文件系统

一、下载并解压根文件系统的源码,进入根文件系统目录

二、配置BusyBox

1、修改Makefile文件        vim  Makefile

         CROSS_COMPILE = arm-linux-

         ARCH   =    arm

2、.配置编译选项     make   menuconfig

Busybox Settings --->
    Build Options --->
        [*] Build BusyBox as a static binary (no shared libs)

        这样能把BusyBox编译成静态链接可执行文件运行时才独立于其他函数库否则需要其他库文件才能运行BusyBox
    Busybox Library Tuning --->
        [*] vi-style line editing commands

选上VI风格的行编辑器命令。
        [*] Fancy shell prompts
Linux Module Utilities --->
        [ ] Simplified modutils
        [*] insmod
        [*] rmmod
        [*] lsmod
        [*] modprobe
        [*] depmod

取消选中Simplified modutils,使用完整的模块工具命令:insmodrmmod……

确保支持mdev,所以要确保以下几个选项被选中

Linux System Utilities ---> [*] mdev 
       [*] Support /etc/mdev.conf 
       [*] Support subdirs/symlinks 
       [*] Support regular expressions substitutions when renaming dev
       [*] Support command execution at device addition/removal 
       [*] Support loading of firmwares

3、编译busybox

         make &&   make install

4、制作根文件系统

       进入目录   cd    busybox-1.17.3/_install

       创建文件系统目录:  mkdir    dev    sys     proc    etc    lib     mnt    opt    tmp

       设置系统启动脚本: 进入etc目录  cd   etc;创建init.d目录    mkdir    init.d; 在该目录下创建rcS文件,文件内容如下:

#!/bin/sh 

/bin/mount -n -t proc none /proc 

/bin/mount -n -t sysfs none /sys 

/bin/mount -t tmpfs -o size=32m none /tmp 

/sbin/mdev -s

ln -s /dev/null /dev/tty2

ln -s /dev/null /dev/tty3

ln -s /dev/null /dev/tty4

5、修改启动脚本执行权限:     chmod   +x    init.d/rcS

6、创建基本设备文件:    cd  dev           mknod  console  c   5   1                      mknod    null   c   1   3 

7、拷贝必要的库文件到当前目录下的lib目录

cp /usr/local/4.4.1/arm-none-linux-gnueabi/libc/lib/ld-linux.so.3         ./lib 

cp /usr/local/4.4.1/arm-none-linux-gnueabi/libc/lib/libc.so.6            ./lib 

cp /usr/local/4.4.1/arm-none-linux-gnueabi/libc/lib/libm.so.6          ./lib 

cp /usr/local/4.4.1/arm-none-linux-gnueabi/libc/lib/libgcc_s.so.1     ./lib 

8、拷贝制作好的_install到、/nfs/,并改名为mini_rootfs

      cp     _install   /nfs/    -rf

      cd     /nfs/

      mv     _install      mini_rootfs

 

三、Udev移植

        解压udev-096.tar.bz2文件并进入udev-096目录,修改Makefile文件  vim  Makefile

        prefix = /nfs/mini_rootfs

        CROSS_COMPILE = arm-linux-

         编译:make    安装: make install

         生成udev,udevcontrol,udevd,udevinfo,udevmonitor,udevsettle,udevstart,udevtest,udevtrigger九个工具程序。(udevd和udevstart比较重要)

         在根文件系统mini_rootfs下的etc/init.d/rcS增加如下几行:

/bin/mount -t tmpfs tmpfs /dev 

/sbin/udevd --daemon 

/sbin/udevstart 

四、制作根文件系统镜像

1、获得mkyaffs2image工具源码包,解压源码包并进入目录,编译make,把经过编译的mkyaffs2image

复制到/usr/bin/目录下,开始制作文件系统镜像:mkyaffs2image   mini_rootfs     rootfs.img

2、根文件系统镜像rootfs.img的下载与烧写

        nand    erase   0xe00000   0xF200000

        tftp   0x40000000 rootfs.img

         ################################### 0x655200

         nand   write.yaffs     0x40000000 0xe00000    0x655200(要把最后一个数字改为传输的字节数!

          setenv bootargs 'console=ttySAC0,115200 root=/dev/mtdblock4 rootfstype=yaffs rw'

重新上电,启动开发板

五、配置文件系统为nfs挂载方式启动

1、将根文件系统拷贝到nfs目录下:cp    mini_rootfs/    /nfs    -rdf

2、配置NFS服务器

         vim    /etc/exports内容如下

         /nfs/mini_rootfs   *(rw,sync,no_root_squash)

       启动NFS服务器

       /etc/init.d/portmap   restart

       /etc/init.d/nfs-kernel-server   restart

3、在ubuntu里面测试NFS服务器是否安装成功

             # mount -t nfs 192.168.1.130:/nfs/mini_rootfs /mnt

            其中192.168.1.130是你的虚拟机系统的IP地址。

            # ls /mnt

           可以查看得到/nfs/mini_rootfs目录的文件。

           最后卸载:

           # umount /mnt 

六、配置内核以支持NFS启动

# cd /root/build_kernel/android-kernel-samsung-dev

# make menuconfig

IP要支持内核底层配置:

[*] Networking support  --->

               Networking options  --->

                         [*]   IP: kernel level autoconfiguration  

文件系统要支持NFS客户端和用NFS作根文件系统:

File systems  --->  

             [*] Network File Systems  --->

                            --- Network File Systems                        

                            <*>   NFS client support                                               

                           [*]     NFS client support for NFS version 3            

                           [*]       NFS client support for the NFSv3 ACL protocol extension 

                            [*]     NFS client support for NFS version 4 (EXPERIMENTAL)   

                            [*]       NFS client support for NFSv4.1 (DEVELOPER ONLY)     

                             [*]     Root file system on NFS

# make uImage -j 2

重新下载烧写新内核镜像。

                                  tftp 0x40000000 uImage         下载uImage到0x40000000地址

                                 nand erase 0x600000 0x500000    擦除kernel分区

                                  nand write 0x40000000 0x600000 0x500000  将uImage写入kernel分区

u-boot那里修改启动参数

                   新的内核从NFS启动:

SMDKV210 # setenv bootargs 'console=ttySAC0,115200  root=/dev/nfs  rw nfsroot=192.168.1.30:/nfs/mini_rootfs

 ip=192.168.1.20:192.168.1.130:192.168.1.1:255.255.255.0::eth0:off  init=/linuxrc'

                   /nfsroot=192.168.1.30 服务器IP        192.168.1.20 开发板IP   

原来的从NAND启动:

SMDKV210 # setenv bootargs 'console=ttySAC0,115200 root=/dev/mtdblock4 rootfstype=yaffs rw'

设置开机自动启动的两种方式

tftp服务器下载内核:

#setenv bootcmd tftp 40000000 uImage\; bootm\;

读取Nand 固化的kernel: 

#setenv bootcmd 'nand read 0x40000000 0x600000 0x500000; bootm 0x40000000'

#save

重新上电运行

 

猜你喜欢

转载自blog.csdn.net/guoyiyan1987/article/details/79137028