内容简介:fl2440添加3070实现无线上网
内核需要开启如下配置,在我移植的 3.0.56 内核已经集成了这些配置
[*] Networking support ---> <*> cfg80211 - wireless configuration API [*] enable powersave by default [*] cfg80211 wireless extensions compatibility [*] Wireless extensions sysfs files {*} Common routines for IEEE802.11 drivers <*> Generic IEEE 802.11 Networking Stack (mac80211) Device Drivers ---> [*] Include in-kernel firmware blobs in kernel binary [*] Network device support ---> [*] Wireless LAN ---> <*> Ralink driver support ---> <*> Ralink rt27xx/rt28xx/rt30xx (USB) support [*] Ralink debug output
安装驱动
插入 3070
网卡后,内核调试信息
> dmesg usb 1-1.1: new full speed USB device number 5 using s3c2410-ohci usb 1-1.1: New USB device found, idVendor=148f, idProduct=3070 usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 usb 1-1.1: Product: 802.11 n WLAN usb 1-1.1: Manufacturer: Ralink
下载对应的 3070
固件到 /lib/firmware
目录下,文件名保持 rt2870.bin
wget https://coding.net/u/sfantree/p/self_use_OSS/git/raw/master/source/rt2870.bin
开启无线网卡
ifconfig wlan0 up
ifconfig
打印出 wlan0
信息
>: ifconfig wlan0 Link encap:Ethernet HWaddr 00:A1:B0:40:6F:72 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
连接wifi
上面的步骤只是安装驱动,让无线网卡工作还要”插上网线”
移植openssl库
wget https://coding.net/u/sfantree/p/self_use_OSS/git/raw/master/source/openssl-1.0.0s.tar.gz tar zxvf openssl-1.0.0s.tar.gz cd openssl-1.0.0s ./config no-asm shared --prefix=`pwd`/_install
修改 Makefile
相应字段
CROSS=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux- CC= $(CROSS)gcc AR= $(CROSS)ar $(ARFLAGS) r RANLIB= $(CROSS)ranlib NM= $(CROSS)nm
继续编译
make make install
移植wpa_supplicant
编译
wget https://coding.net/u/sfantree/p/self_use_OSS/git/raw/master/source/wpa_supplicant-0.7.3.tar.gz tar zxvf wpa_supplicant-0.7.3.tar.gz cd wpa_supplicant-0.7.3/wpa_supplicant cp defconfig .config
修改 .config
相应字段,其中 OPENSSL_PATH
为上一步 openssl
的安装路径
CROSS=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux- OPENSSL_PATH=/root/fl2440/3rdapp/openssl/openssl-1.0.0s/_install CC= $(CROSS)gcc -L$(OPENSSL_PATH)/lib/openssl CFLAGS += -I$(OPENSSL_PATH)/include LIBS += -L$(OPENSSL_PATH)lib/openssl
make
过后会生成如下几个文件,将其拷贝到开发板 /usr/bin
- wpa_cli (打酱油)
- wpa_passphrase (一键生成配置文件)
- wpa_supplicant (连接WiFI)
查看相关依赖库,可见 wpa_supplicant
前置依赖属于 openssl
的 libcrypto.so
和 libssl.so
> arm-linux-readelf -d ./wpa_supplicant Dynamic section at offset 0x471e8 contains 24 entries: Tag Type Name/Value 0x00000001 (NEEDED) Shared library: [libssl.so.1.0.0] 0x00000001 (NEEDED) Shared library: [libcrypto.so.1.0.0] 0x00000001 (NEEDED) Shared library: [libdl.so.0] 0x00000001 (NEEDED) Shared library: [libc.so.0] ...
生成配置文件
wpa_supplicant.conf
配置文件保留着需要连接 AP
的 SSID
和 key
等信息,可以使用 wpa_supplicant.conf
一键生成
wpa_passphrase dlink-301 cnmbcnmb >> /etc/wpa_supplicant.conf
wpa_supplicant.conf
还需要稍微修改一下
ctrl_interface=/var/run/wpa_supplicant network={ ssid="dlink-301" key_mgmt=WPA-PSK proto=WPA2 group=TKIP CCMP pairwise=TKIP CCMP psk="cnmbcnmb" #psk=56466f08ff364ccbbec3266aeda88cb69619a3914834966cc7e90098985d225c }
启用 wpa_supplicant
wpa_supplicant -B -d -Dwext -i wlan0 -c /etc/wpa_supplicant.conf
网络配置
由于还没有开启 DHCP
,所以需要手动分配 IP
等各种配置,这里配置由你的网络环境决定,后面会介绍使用 DHCP
#配置IP地址 ifconfig wlan0 192.168.0.168 #配置默认网关 route add default gw 192.168.0.1 #配置DNS echo "nameserver 114.114.114.114" > /etc/resolv.conf
接下来进行 ping
测试
>: ping sfantree.com PING sfantree.com (123.56.22.253): 56 data bytes 64 bytes from 123.56.22.253: seq=0 ttl=51 time=34.019 ms 64 bytes from 123.56.22.253: seq=1 ttl=51 time=24.689 ms 64 bytes from 123.56.22.253: seq=2 ttl=51 time=25.622 ms 64 bytes from 123.56.22.253: seq=3 ttl=51 time=65.763 ms 64 bytes from 123.56.22.253: seq=4 ttl=51 time=74.489 ms
开启DHCP
busybox
已经集成了 DHCP
的客户端和服务端,源码编译过后的 examples/udhcp/simple.script
作为 DHCP
客户端的示例配置文件如下,将其重命名为 /usr/share/udhcpc/default.script
,特别注意必须给 default.script
执行权限
#!/bin/sh # udhcpc script edited by Tim Riker <Tim@Rikers.org> RESOLV_CONF="/etc/resolv.conf" [ -n "$1" ] || { echo "Error: should be called from udhcpc"; exit 1; } NETMASK="" [ -n "$subnet" ] && NETMASK="netmask $subnet" BROADCAST="broadcast +" [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" case "$1" in deconfig) echo "Setting IP address 0.0.0.0 on $interface" ifconfig $interface 0.0.0.0 ;; renew|bound) echo "Setting IP address $ip on $interface" ifconfig $interface $ip $NETMASK $BROADCAST if [ -n "$router" ] ; then echo "Deleting routers" while route del default gw 0.0.0.0 dev $interface ; do : done metric=0 for i in $router ; do echo "Adding router $i" route add default gw $i dev $interface metric $((metric++)) done fi echo "Recreating $RESOLV_CONF" echo -n > $RESOLV_CONF-$$ [ -n "$domain" ] && echo "search $domain" >> $RESOLV_CONF-$$ for i in $dns ; do echo " Adding DNS server $i" echo "nameserver $i" >> $RESOLV_CONF-$$ done mv $RESOLV_CONF-$$ $RESOLV_CONF ;; esac exit 0
执行 udhcpc -i wlan0
之后即可自动获取 IP
,执行这个命令后 udhcp
会以守护进程方式在后台运行
>: udhcpc -i wlan0 udhcpc (v1.20.2) started Setting IP address 0.0.0.0 on wlan0 Sending discover... Sending select for 192.168.0.103... Lease of 192.168.0.103 obtained, lease time 604800 Setting IP address 192.168.0.103 on wlan0 Deleting routers route: SIOCDELRT: No such process Adding router 192.168.0.1 Recreating /etc/resolv.conf Adding DNS server 192.168.0.1
以上所述就是小编给大家介绍的《fl2440添加3070实现无线上网》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。