前段时间在buildroot搭建的根文件系统中移植过wifi驱动并且调试成功,一般来说,buildroot构建的文件系统比较完整,但最近使用busybox来构建了根文件系统,后者就比较简陋,很多文件都是靠自己去创建等等,所以在移植wifi网卡的时候就出现了缺乏某些文件导致功能不能正常使用的问题,现在就记录一下使用busybox里的小工具udhcpc能成功动态获取ip地址,但没能自动设置DNS,也就没能上网的问题。
... wlan0: associated udhcpc: started, v1.32.0 udhcpc: sending discover udhcpc: sending select for 192.168.1.14 udhcpc: lease of 192.168.1.14 obtained, lease time 3599 / # / # ifconfig wlan0 wlan0 Link encap:Ethernet HWaddr 70:F1:1C:27:C6:A4 inet6 addr: fe80::72f1:1cff:fe27:c6a4/64 Scope:Link inet6 addr: 2408:8456:3000:abe4:72f1:1cff:fe27:c6a4/64 Scope:Global UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:28 errors:0 dropped:0 overruns:0 frame:0 TX packets:12 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:11065 (10.8 KiB) TX bytes:1832 (1.7 KiB) / #
将busybox-1.xx.x/examples/udhcp/目录下的simple.script文件(注意不是sample.script)拷贝到根文件系统的/usr/share/udhcpc/目录下,将它重命名为default.script,并且chmod +x default.script加上可执行权限即可。
完成之后就可以正常使用了:
... wlan0: associated udhcpc: sending discover udhcpc: sending select for 192.168.1.14 udhcpc: lease of 192.168.1.14 obtained, lease time 3599 Setting IP address 192.168.1.14 on wlan0 Deleting routers route: SIOCDELRT: No such process Adding router 192.168.1.228 Recreating /etc/resolv.conf Adding DNS server 192.168.1.228 / # / # ifconfig wlan0 wlan0 Link encap:Ethernet HWaddr 70:F1:1C:27:C6:A4 inet addr:192.168.1.14 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::72f1:1cff:fe27:c6a4/64 Scope:Link inet6 addr: 2408:8456:3000:abe4:72f1:1cff:fe27:c6a4/64 Scope:Global UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:20 errors:0 dropped:0 overruns:0 frame:0 TX packets:11 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:7416 (7.2 KiB) TX bytes:1690 (1.6 KiB) / # / # ping www.baidu.com PING www.baidu.com (163.177.151.109): 56 data bytes 64 bytes from 163.177.151.109: seq=0 ttl=53 time=47.980 ms ...