Hi3515支持NFS-ROOT启动 分类: HI3531 arm-linux-Ubuntu 2013-08-28 10:14 858人阅读 评论(0) 收藏

目前在做Hi3515平台监控项目,前期开发一直使用SDK里推荐的mount nfs方式来调试代码,虽然也算方便,但是我一直觉得用法NFS-ROOT才是最省事的方法,而且最接近最终用户使用环境,因为如果NFS-ROOT调试完成后,就直接可以出firmware了.

由于SDK几乎将所有用到的驱动都独立编译成了ko文件,所以为了将驱动编译到内核中,还是需要做一番工作的,由于初次接触内核和驱动,所以很多东西都是刚了解的。通过不断的试错和调试,终于搞定了网卡驱动和NFS-ROOT的支持。

若想内核支持NFS-ROOT,主要是两个方面的功能配置,一是ethernet,让网卡在内核运行时驱动自动加载,这样才不会导致eth0找不到的情况,而是nfs内核中的相关配置选项。

step 0. 复制使用到的config配置文件

cp arch/arm/configs/hi3515v100_full_release_defconfig .config

step 1.在内核代码中增加网卡驱动

     step 1.0 在驱动目录下增加hiether文件夹,用来存放hi3515的网卡驱动

                  mkdir linux-2.6.24/drivers/net/hiether

     step 1.1 复制已有的网卡驱动到新添加的文件夹中

                  cp Hi3515_SDK_V1.0.5.0.c1/source/drv/hi3515v100-sfv300 linux-2.6.24/drivers/net/hiether

     step 1.2 修改驱动文件夹中的代码

                  由于原有驱动是用来编译为独立的ko文件的,所以里面的部分函数使用了__exit标志,用来表示只用来作为模块退出使用的函数,如果不将次函数的__exit标志去掉,在编译内核的时候会打印

              “ `.exit.text’ referenced in section `.init.text’ of drivers/built-in.o: defined in discarded section `.exit.text’ of drivers/built-in.o`.exit.text’ referenced in section `.data’ of drivers/built-in.o: defined in discarded section `.exit.text’ of drivers/built-in.o`.exit.text’ referenced in section `.data’ of drivers/built-in.o: defined in discarded section `.exit.text’ of drivers/built-in.omake: *** [.tmp_vmlinux1] 错误 1”

                  简单的将__exit标志去掉,就能顺利通过编译了。

     step 1.3 增加菜单选项

                  要想通过menuconfig来选择是否选择hiether驱动,要做一下修改:

                    step 1.3.0 修改Kconfig文件

                                    在net/Kconfig中config DM9000下面的位置增加下面内容

config DM9000

    tristate “DM9000 support”

    depends on ARM || BLACKFIN || MIPS

    select CRC32

    select MII

    —help—

      Support for DM9000 chipset.

      To compile this driver as a module, choose M here.  The module

      will be called dm9000.

config HIETHER

    tristate “HIETHER support”

    —help—

          step 1.3.1 修改net/Makefile,增加需要编译的文件夹

                          obj-$(CONFIG_HIETHER) += hiether/

          step 1.3.2 在hiether文件夹中增加Makefile文件,内容如下

                          obj-$(CONFIG_HIETHER) += hiether.o
hiether-objs := mdio.o mii-drv.o mac.o ctrl.o glb.o net-drv.o mm.o sys.o proc.o

          step 1.3.3 make menuconfig 选择新增加的驱动

                         [*] Network device support  —>  [*]   Ethernet (10 or 100Mbit)  —> <*>   hiether support

step 2. 内核增加对NFS-ROOT的支持

         Networking  —>Networking options  —>[*]   IP: kernel level autoconfiguration

                                                                    [*]     IP: DHCP support

                                                                    [*]     IP: BOOTP support

                                                                    [*]     IP: RARP support

         File systems  —> [*] Network File Systems  —> <*>   NFS file system support

                                                                                 [*]     Allow direct I/O on NFS files

                                                                                 [*]   Root file system on NFS

                                                                                 [*]   Support for rpcbind versions 3 & 4 (EXPERIMENTAL)

step 3.重新编译内核

          make; make uImage

step4. 测试

          宿主机要安装nfs,tftp,这些网上教程很多,这里就不罗嗦了

          启动参数setenv bootargs busclk=220000000 mem=64M console=ttyAMA0,115200 root=/dev/nfs rw nfsroot=192.168.6.141:/tftpboot/hi3515.filesys, nolock eth=00:1e:9a:04:5c:4d ip=192.168.6.143:192.168.6.100:192.168.6.254:255.255.255.0:tocore:eth0:off pcimod=host pciclksel=1

          下载最新内核并运行

            tftp 0xc1000000 uImage; bootm 0xc1000000

—————————启动打印信息————————————————–

IP-Config: Complete:
device=eth0, addr=192.168.6.143, mask=255.255.255.0, gw=192.168.6.254,
host=tocore, domain=, nis-domain=(none),
bootserver=192.168.6.100, rootserver=192.168.6.141, rootpath=
Looking up port of RPC 100003/2 on 192.168.6.141
PHY: 0:01 – Link is Up – 100/Full
Looking up port of RPC 100005/1 on 192.168.6.141
VFS: Mounted root (nfs filesystem).
Freeing init memory: 112K

版权声明:本文为博主原创文章,未经博主允许不得转载。

posted @ 2013-08-28 10:14  毛毛虫的薄刻  阅读(246)  评论(0编辑  收藏  举报