一、内核配置
配置内核支持cfg80211(802.11n协议)
Networking support --->
-*- Wireless --->
--- Wireless
<*> cfg80211 - wireless configuration API
enable powersave by default
cfg80211 wireless extensionscompatibility
<*> Common routines for IEEE802.11 drivers
Device Drivers --->
[*] Network device support --->
[*] Wireless LAN --->
<*> USB ZD1201 based Wireless device support
[*] USB support --->
<*> Support for Host-side USB
<*> USB Monitor
<*> USB Wireless Device Management support
配置完成后,保存退出。然后重新编译内核和内核模块
二、编译8188驱动
下载8188驱动 http://pan.baidu.com/s/1c27EdZa
我用的是4.0.2
在Makefile下添加
CONFIG_PLATFORM_ARM_AM335X = y
ifeq ($(CONFIG_PLATFORM_ARM_AM335X), y)
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
ARCH := arm
CROSS_COMPILE := arm-arago-linux-gnueabi-
KVER := 3.2.0
KSRC := /work/test/linux-3.2.0-psp04.06.00.11
endif
make
生成8192cu.ko
三、编译工具
需要四个
wpa_supplicant-0.7.3
wireless_tools.29
openssl-0.9.8e
libnl-2.0
3.1 编译wireless_tools.29
修改Makefile
## Compiler to use (modify this for cross compile).
CC = arm-arago-linux-gnueabi-gcc
## Other tools you need to modify for cross compile (static lib only).
AR = arm-arago-linux-gnueabi-ar
RANLIB = arm-arago-linux-gnueabi-ranlib
保存,make
将生成的iwpriv,iwconfig,iwlist,iwspy拷贝到开发板
3.2 编译libnl-2.0
CC=/usr/local/arm/arm-arago-linux-gnueabi/bin/arm-arago-linux-gnueabi-gcc ./configure --prefix=$PWD/_install --host=arm-arago-linux-gnueabi
make;make install
将生成的库文件和头文件拷贝到编译器usr目录
cd _install
tar czvf lib.tar.gz *
cp -rf lib.tar.gz /usr/local/arm/arm-arago-linux-gnueabi/usr
sudo tar xzvf lib.tar.gz
将这个库文件也拷贝到开发板
3.3 编译openssl-0.9.8e
cp wpa_supplicant-0.7.3/patches/openssl-0.9.8e-tls-extensions.patch openssl-0.9.8e
vi Makefile
INSTALLTOP=/usr/local/ssl
# Do not edit this manually. Use Configure --openssldir=DIR do change this!
OPENSSLDIR=/usr/local/ssl
CC= arm-arago-linux-gnueabi-gcc
AR= arm-arago-linux-gnueabi-ar $(ARFLAGS) r
RANLIB= /usr/local/arm/arm-arago-linux-gnueabi/bin/arm-arago-linux-gnueabi-ranlib
make
sudo make install
3.4 编译wpa_supplicant-0.7.3
cd wpa_supplicant-0.7.3/wpa_supplicant
cp defconfig .config
vi .config
CC=/usr/local/arm/arm-arago-linux-gnueabi/bin/arm-arago-linux-gnueabi-gcc -L/usr/local/ssl/lib
CFLAGS +=-I/usr/local/ssl/include
LIBS += -I/usr/local/arm/arm-arago-linux-gnueabi/usr/include
LIBS += -L/usr/local/ssl/lib
LIBS += -L/usr/local/arm/arm-arago-linux-gnueabi/usr/lib
LIBS_p += -L/usr/local/ssl/lib
CONFIG_LIBNL20=y
make
将生成的wpa_supplicant、wpa_cli、wpa_passphrase拷贝到开发板
3.5 编译hostapd-0.8
cd hostapd-0.8/hostapd
cp defconfig .config
vi .config
CROSS= /usr/local/arm/arm-arago-linux-gnueabi/bin/arm-arago-linux-gnueabi-
CC=${CROSS}gcc
CFLAGS+=-I/usr/loacal/ssl/include/
LDFLAGS+=-L/usr/loacal/ssl/lib/
CFLAGS += -I/usr/local/arm/arm-arago-linux-gnueabi/usr/include/
LIBS += -L/usr/local/arm/arm-arago-linux-gnueabi/usr/lib/
make
四、连接网络
4.1 STAION模式
insmod 8192cu.ko
ifconfig wlan0 up
iwconfig wlan0 essid CCC CCC wifi名称
wpa_passphrase CCC 12345678
network={
ssid="CCC"
#psk="12345678"
psk=e2815ba1cc2e174c517a2793f98b5c2824f5590d73df6f7079bdf6b49d786235
}
vi /etc/wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant
network={
ssid="CCC"
scan_ssid=1
key_mgmt=WPA-EAP WPA-PSK IEEE8021X NONE
proto=WPA
pairwise=TKIP CCMP
group=CCMP TKIP WEP104 WEP40
#psk="12345678"
psk=e2815ba1cc2e174c517a2793f98b5c2824f5590d73df6f7079bdf6b49d786235
}
连接
wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -B
自动获取ip
udhcpc -i wlan0
需要创建var/lib/misc/udhcpd.leases这个文件
Sending select for 192.168.0.144...
Lease of 192.168.0.144 obtained, lease time 7200
RTNETLINK answers: File exists
adding dns 192.168.0.1
ping -I wlan0 192.168.1.1 #ping路由
64 bytes from 192.168.1.1: seq=3 ttl=63 time=38.078 ms
64 bytes from 192.168.1.1: seq=4 ttl=63 time=123.281 ms
64 bytes from 192.168.1.1: seq=5 ttl=63 time=20.937 ms
4.2 AP模式
连接
insmod 8192cu.ko
hostapd -B /etc/hostapd.conf
ifconfig wlan0 192.168.3.1
udhcpd /etc/udhcpd.conf
ping -I wlan0 192.168.3.20
问题:
一开始使用的是wpa_supplicant-2.3
报错:
/work/debug/test/wirless/wpa_supplicant-2.3/wpa_supplicant/../src/drivers/driver_nl80211.c:10989: undefined reference to `genlmsg_attrdata'
/work/debug/test/wirless/wpa_supplicant-2.3/wpa_supplicant/../src/drivers/driver_nl80211.c:10989: undefined reference to `genlmsg_attrlen'
../src/drivers/driver_nl80211.o: In function `protocol_feature_handler':
/work/debug/test/wirless/wpa_supplicant-2.3/wpa_supplicant/../src/drivers/driver_nl80211.c:3461: undefined reference to `genlmsg_attrdata'
/work/debug/test/wirless/wpa_supplicant-2.3/wpa_supplicant/../src/drivers/driver_nl80211.c:3461: undefined reference to `genlmsg_attrlen'
../src/drivers/driver_nl80211.o: In function `get_sta_handler':
/work/debug/test/wirless/wpa_supplicant-2.3/wpa_supplicant/../src/drivers/driver_nl80211.c:9654: undefined reference to `genlmsg_attrdata'
/work/debug/test/wirless/wpa_supplicant-2.3/wpa_supplicant/../src/drivers/driver_nl80211.c:9654: undefined reference to `genlmsg_attrlen'
此时需要修改.config文件
# Use libnl v2.0 (or 3.0) libraries.
# CONFIG_LIBNL20=y
# Use libnl 3.2 libraries (if this is selected, CONFIG_LIBNL20 is ignored)
# CONFIG_LIBNL32=y
去掉CONFIG_LIBNL20、CONFIG_LIBNL32前面的#
重新编译又出现报错:
arm-arago-linux-gnueabi/bin/ld: cannot find -lnl-3
修改.config
CONFIG_LIBNL32 改为 #CONFIG_LIBNL32 这个#不能去掉
执行wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -B
Successfully initialized wpa_supplicant nl80211: 'nl80211' generic netlink not found Failed to initialize driver 'nl80211'
最后将wpa_supplicant 版本更换成wpa_supplicant-0.7.3,再编译没有问题