8188EU 在AM335X MC183上以AP+STA工作
【目的】
8188EU 在AM335X MC183上以AP+STA工作。
【环境】
1、 Ubuntu 16.04发行版
2、 linux-3.2.0-psp04.06.00.11
3、 MC183平台
4、 交叉编译器arm-linux-gnueabihf-gcc-4.7.3
【实验步骤】
1、 配置内核
Device Drivers ---> 开启WIRELESS LAN
Network device supports --->
[*] Wireless LAN --->
<*> IEEE 802.11 for Host AP (Prism2/2.5/3 and WEP/TKIP/CCMP)
[*] Support downloading firmware images with Host AP driver
[*] Support for non-volatile firmware download
[*] USB support --->
<*> USB Wireless Device Management support
2、 重新编译内核
$ ./build.sh
3、 8188eu 驱动生成
1.1解压RTL8188EUS_RTL8189ES_linux_v4.1.8_9499.20131104-am335.tar.gz
1.2进入RTL8188EUS_RTL8189ES_linux_v4.1.8_9499.20131104/driver/rtl8188EUS_rtl8189ES_linux_v4.1.8_9499.20131104 目录
1.3 移植
修该顶层的Makefile,如下红色部分为应该注意的地放,主要是编译器,内核版本,及内核源码所在的位置。
466 ifeq ($(CONFIG_PLATFORM_ARM_S3C2K4), y)
467 EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
468 ARCH := arm
469 CROSS_COMPILE := arm-linux-gnueabihf-
470 KVER := 3.2.0
471 #chy panzidong
472 #KSRC := /root/board/am335/project/xlsw/linux-3.2.0-psp04.06.00.11
473 KSRC := /home/vmuser/sdc/remote_svn/anosi-hardware/iotx-am335x/MC-183/trunk/kernel/linux-3.2.0-psp04.06.00.11
=====开启CONCURRENT_MODE模式,用于支持STA+AP MODE===
vim include/autoconf.h +114
vim autoconf_rtl8188e_usb_linux.h +114
114 // change by panzidong
115 #define CONFIG_CONCURRENT_MODE
116 #ifdef CONFIG_CONCURRENT_MODE
117 //#define CONFIG_HWPORT_SWAP //Port0->Sec , Port1 -> Pri
118 //#define CONFIG_STA_MODE_SCAN_UNDER_AP_MODE
119 #define CONFIG_TSF_RESET_OFFLOAD // For 2 PORT TSF SYNC.
120 #endif
编译驱动:
make
Building modules, stage 2.
MODPOST 1 modules
CC /home/vmuser/sdc/remote_svn/anosi-hardware/iotx-am335x/MC-183/package/source/RTL8188EUS_RTL8189ES_linux_v4.1.8_9499.20131104/driver/rtl8188EUS_rtl8189ES_linux_v4.1.8_9499.20131104/8188eu.mod.o
LD [M] /home/vmuser/sdc/remote_svn/anosi-hardware/iotx-am335x/MC-183/package/source/RTL8188EUS_RTL8189ES_linux_v4.1.8_9499.20131104/driver/rtl8188EUS_rtl8189ES_linux_v4.1.8_9499.20131104/8188eu.ko
在当前目录下面会生成8188eu.ko.
4、 交叉编译hostapd
交叉编译hostapd
cd RTL8188EUS_RTL8189ES_linux_v4.1.8_9499.20131104/wpa_supplicant_hostapd/wpa_supplicant_hostapd-0.8_rtw_r7475.20130812/hostapd
修该顶层的Makefile
1 CC=arm-linux-gnueabihf-gcc
2
3 ifndef CFLAGS
4 CFLAGS = -MMD -O2 -Wall -g
5 endif
编译:
Make
LD hostapd
CC hostapd_cli.c
CC ../src/common/wpa_ctrl.c
LD hostapd_cli
最终会在当前的目录下面生在hostapd hostapd_cli两个命令。其中hostapd为我们所需要的工具。
5、 交叉编译wpa相关的工具
交叉编译wpa_supplicant
cd RTL8188EUS_RTL8189ES_linux_v4.1.8_9499.20131104/wpa_supplicant_hostapd/wpa_supplicant_hostapd-0.8_rtw_r7475.20130812/wpa_supplicant
修该顶层的Makefile
1 CC=arm-linux-gnueabihf-gcc
2
3 ifndef CFLAGS
4 CFLAGS = -MMD -O2 -Wall -g
5 endif
编译:
Make
LD wpa_supplicant
CC wpa_passphrase.c
LD wpa_passphrase
CC wpa_cli.c
CC ../src/common/wpa_ctrl.c
CC ../src/utils/edit_simple.c
LD wpa_cli
最终会在当前的目录下面生在wpa_supplicant wpa_passphrase wpa_cli
三个命令。三者皆为我们所需要的工具
6、 交叉编译dnsmasq-2.73
Dnsmasq是个轻量级的DHCP服务,配合hostapd使有,提供本地DHCP功能。
通过如下命令解压 dnsmasq-2.73.tar.xz
dnsmasq-2.73.tar.xz
xz –d dnsmasq-2.73.tar.xz
tar vxf dnsmasq-2.73.tar
cd dnsmasq-2.7
修该Makefile
make
dnsmasq在当前的src目录下生成
7、 测试
1.1 AP测试
# mkdir /lib/modules/3.2.0/kernel/drivers/wifi
mkdir -p /lib/modules/3.2.0/kernel/drivers/wifi
# download 8188eu.ko
wget http://192.168.3.88/8188eu/8188eu.ko -O /lib/modules/3.2.0/kernel/drivers/wifi/8188eu.ko && chmod +x /lib/modules/3.2.0/kernel/drivers/wifi/8188eu.ko
# download hostapd
wget http://192.168.3.88/8188eu/hostapd -O /bin/hostapd && chmod +x /bin/hostapd
# download rtl_hostapd_2G.conf
wget http://192.168.3.88/8188eu/rtl_hostapd_2G.conf -O /etc/rtl_hostapd_2G.conf && chmod 0666 /etc/rtl_hostapd_2G.conf\
# download dnsmasq
wget http://192.168.3.88/8188eu/dnsmasq -O /sbin/dnsmasq && chmod +x /sbin/dnsmasq
# download dnsmasq.conf
wget http://192.168.3.88/8188eu/dnsmasq.conf -O /etc/dnsmasq.conf && chmod 0666 /etc/dnsmasq.conf
# mkdir /var/lib/misc ,如不创建的话,dnsmasq无法正常运行。
mkdir -p /var/lib/misc
sleep 2
# insmod 8818eu.ko
insmod /lib/modules/3.2.0/kernel/drivers/wifi/8188eu.ko
sleep 5
# 开启wlan0
ifconfig wlan0 up
# start hostapd
hostapd /etc/rtl_hostapd_2G.conf -B &
sleep 6
# set wlan0 static ip
ifconfig wlan0 192.168.188.1
# start dnsmasq
dnsmasq -C /etc/dnsmasq.conf
à 此时可联接到热点名称为rtwap的热点,密码为87654321。
其中rtl_hostapd_2G.conf内容如下所示
interface=wlan0
ctrl_interface=/var/run/hostapd
ssid=rtwap
channel=6
wpa=2
wpa_passphrase=87654321
eap_server=1
wps_state=2
uuid=12345678-9abc-def0-1234-56789abcdef0
device_name=RTL8192CU
manufacturer=Realtek
model_name=RTW_SOFTAP
model_number=WLAN_CU
serial_number=12345
device_type=6-0050F204-1
os_version=01020300
config_methods=label display push_button keypad
driver=rtl871xdrv
beacon_int=100
hw_mode=g
ieee80211n=1
wme_enabled=1
ht_capab=[SHORT-GI-20][SHORT-GI-40][HT40+]
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
max_num_sta=8
wpa_group_rekey=86400
其中dnsmasq.conf,内容如下所示
interface=wlan0
listen-address=192.168.188.1,127.0.0.1
domain=iotx.thekelleys.org.uk
dhcp-range=192.168.188.100,192.168.188.200,12h
1.2 STA测试:
连接点为BX240721的热点:
将热点名称和密码写入配置文件当中:
wpa_passphrase "TEST AP SSID" "TEST AP PASSWORD" > /etc/wpa_supplicant.conf
开启wpa_supplicant服务用来连接特定的热点:
wpa_supplicant –iwlan1 -c /etc/wpa_supplicant.conf –B
获取wlan1的IP地址:
udhcpc -i wlan1
如果正常的话,会发现wlan1拿到正确的IP地址。