天天看點

Hi3515支援NFS-ROOT啟動

目前在做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”

          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