NFS就是網絡檔案系統,用NFS可以實作把主控端的目錄挂載到開發闆上,這樣用主控端進行交叉編譯時就不用用USB或者SD卡将編譯好的檔案拷貝到開發闆上運作了.
1.OK6410的闆子的網孔插上網線連接配接到PC網線接的那個路由器上
2.首先在linux虛拟機上準備nfs共享目錄:/nfs/root
linux虛拟機上:
mkdir nfs
chmod 777 nfs
cd nfs
mkdir root
chmod 777 root
cd root
mkdir succeed
3.在虛拟機上配置nfs服務
首先判斷linux上是否安裝有nfs
我的是在/etc/init.d檔案下看看是否有portmap nfs
/etc/init.d/portmap
/etc/init.d/nfs
如果沒有這些執行:
su - root
apt-get install portmap
apt-get install nfs-kernel-server
4.編輯exports檔案
vi /etc/exports
添加這個:/nfs/root *(rw,sync,no_root_squash)
5.啟動nfs服務
/etc/init.d/portmap restart
/etc/init.d/nfs restart
檢測運作狀态(也可以不檢測)
/etc/init.d/portmap status
出現 is running...
否則
/etc/init.d/portmap start
/etc/init.d/nfs start
6.ping通 開發闆跟虛拟機linux
再虛拟機linux上執行
ifconfig
知道虛拟主機IP為125.217.32.237
啟動開發闆進入到linux系統
再終端上輸入
ifconfig
得到開發闆linux的IP為。。。。。
如果IP跟虛拟主機的IP不在同一網段,就修改下
ifconfig eth0 125.217.23.32 (反正是125.217.32.xx同一網段)
ping一下
終端上輸入ping 125.217.32.237
得到PING 125.217.32.237 (125.217.32.237): 56 data bytes
64 bytes from 125.217.32.237: seq=0 ttl=64 time=24.942 ms
64 bytes from 125.217.32.237: seq=1 ttl=64 time=1.518 ms
64 bytes from 125.217.32.237: seq=2 ttl=64 time=1.025 ms
64 bytes from 125.217.32.237: seq=3 ttl=64 time=0.906 ms
64 bytes from 125.217.32.237: seq=4 ttl=64 time=0.743 ms
ctrl+c退出
packets transmitted, 5 packets received, 0% packet loss
這時候PING通了
7.挂載nfs檔案到開發闆上
再終端上輸入
mount -t nfs 125.217.32.237:/nfs/root /mnt -o nolock
含義是: 主控端IP:主控端的nfs目錄 開發闆挂載目錄
然後進入到/mnt下就看到/nfs/root下的目錄succeed了
8. umount /mnt
注意:
1.闆子跟電腦的linux系統可以PING通了,終端上還是出現 mount 提示: mount: RPC: Unable to receive; errno = No route to host》》》》??
這時候可能要關閉防火牆
在虛拟主機linux上執行
service iptables stop
service nfs restart
或者你mount露寫了一個 -o nolock
2.為了測試主機上NFS服務是否啟動,
先在虛拟主機上mount -t nfs 125.217.32.237:/nfs/root /mnt
然後用指令:ls /mnt檢視挂載内容(或者看能否在mnt目錄下看到nfs/root目錄)
成功後解除安裝umount
3. IP必須得ping通
4.如果要修改arm闆子上IP重新開機後不改變,如果是 yaffs2檔案的話
就在
/etc/init.d/rcS檔案,在/sbin/ifconfig lo 127.0.0.0
下添加一行/sbin/ifconfig eth0 125.217.32.23 up
修改/etc/eth0-settin
(不知道那個/etc/init.d/ifconfig-eth0要不要修改)
将其IP位址改成你想要設定的IP
重新開機開發闆,
使用ifconfig指令,就發現IP位址已經修改過來了
如果是cramfs檔案,隻能重做一個cramfs檔案,cramfs是隻讀的
1.确定自己用網線把電腦跟開發闆連接配接了起來,或者接到路由器或者交換機上
2.再虛拟機linux上service iptables stop
3. /etc/init.d/portmap start
4./etc/init.d/nfs start
5.啟動開發闆進入到uboot,在 u-boot 指令行下輸入以下指令設定 u-boot 啟動參數:
setenv bootargs "root=/dev/nfs nfsroot=192.168.0.231:/6410/root
ip=192.168.0.232:192.168.0.231:192.168.0.2 0 1:255.255.255.0:witech.com.
cn:eth0:off console=ttySAC0,115200"
saveenv
(注意nfsroot=192.168.0.231:/6410/root是自己挂載nfs的目錄,ip=192.168.0.232是自己開發闆的IP,自己設的,但要同一網段,後面的192.168.0.231:192.168.0.201:255.255.255.0是在虛拟機linux上的ifconfig看到的eth0看到的IP)
6.重新啟動開發闆,就挂載NFS網絡檔案系統了
7.在開發闆上的linux指令行輸入writeyaffs就可以開始自動燒寫(注意MY 6410_yaffs2_v1.0.tgz 一定要放在系統根目錄下)
8.要放在檔案系統根目錄下)
設定 u-boot 啟動參數:
setenv bootargs "root=/dev/mtdblock2 rootfstype=yaffs2
console=ttySAC0,115200"
saveenv
9. 重新開機啟動就可以使用yaffs2檔案系統了!!