开始系统学习Linux驱动,以前断断续续也玩玩了一下,开贴来系统学习Linux驱动。
硬件平台是JZ2440-4.3 ARM9开发板,开发板运行系统版本Linux3.4.2内核(内核移植,下载等相关其他篇幅)。
设置开发板系统IP,让开发板与主机、开发板与虚拟机互通。
查看开发板ip
/ # route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
127.0.0.0 * 255.255.255.0 U 0 0 0 lo
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
以上是我设置好的,如果没有设置过是没有IP的,如下:
/ # route
设置ip
ifconfig lo 127.0.0.1
route add -net 127.0.0.0 netmask 255.255.255.0 lo
ifconfig eth0 192.168.1.17
route add -net 192.168.1.17 netmask 255.255.255.0
注意:192.168.1.17这个是开发板ip,这个ip要与主机、虚拟机在同一个网段,简单说主机ip应该为192.168.1.xx、虚拟机ip也应该为192.168.1.xx,否则三者之间无法ping通。
测试ip是否可以ping通
开发板ping主机
/ # ping 192.168.1.10(主机ip)
PING 192.168.1.10 (192.168.1.10): 56 data bytes
64 bytes from 192.168.1.10: seq=0 ttl=64 time=1.888 ms
64 bytes from 192.168.1.10: seq=1 ttl=64 time=0.763 ms
64 bytes from 192.168.1.10: seq=2 ttl=64 time=0.733 ms
64 bytes from 192.168.1.10: seq=3 ttl=64 time=0.744 ms
64 bytes from 192.168.1.10: seq=4 ttl=64 time=0.769 ms
^C
--- 192.168.1.10 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 0.733/0.979/1.888 ms
开发板ping虚拟机
/ # ping 192.168.1.20(虚拟机ip)
PING 192.168.1.20 (192.168.1.20): 56 data bytes
64 bytes from 192.168.1.20: seq=0 ttl=64 time=22.074 ms
64 bytes from 192.168.1.20: seq=1 ttl=64 time=0.975 ms
64 bytes from 192.168.1.20: seq=2 ttl=64 time=1.100 ms
64 bytes from 192.168.1.20: seq=3 ttl=64 time=0.934 ms
64 bytes from 192.168.1.20: seq=4 ttl=64 time=1.090 ms
64 bytes from 192.168.1.20: seq=5 ttl=64 time=1.075 ms
64 bytes from 192.168.1.20: seq=6 ttl=64 time=1.004 ms
64 bytes from 192.168.1.20: seq=7 ttl=64 time=0.955 ms
^C
--- 192.168.1.20 ping statistics ---
8 packets transmitted, 8 packets received, 0% packet loss
round-trip min/avg/max = 0.934/3.650/22.074 ms
设置正确就可以相互ping通。
NFS挂载开发板到虚拟机nfs目录
mount -t nfs -o intr,nolock,rsize=1024,wsize=1024 192.168.1.20:/work/nfs_root /mnt
注意:
1、192.168.1.20为虚拟机ip(根据虚拟机ip的目录做相应改变)
2、/work/nfs_root为虚拟机nfs目录(根据nfs的目录做相应改变)