|
主机平台: UBUNTU14.04
硬件平台:明远智睿MY-IMX6-EK200
编译器: gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz
buildroot版本:buildroot-2017.02.5.tar.bz2
内核版本 linux-3.14.52
1.内核需要配置,配置完直接编译zImage
CONFIG_CFG80211=y
CONFIG_MAC80211=y
CONFIG_HOSTAP=y
CONFIG_USB_USBNET=y
2. 编译rtl8188eus模块
源码包:rtl8188EUS_linux_v4.3.0.9_15178.20150907%28myimx6%29.tar.xz
$ tar xvf rtl8188EUS_linux_v4.3.0.9_15178.20150907%28myimx6%29.tar.xz
$ cd rtl8188EUS_linux_v4.3.0.9_15178.20150907
$ vim Makefile
修改增加(源码路径和交叉编译工具路径)
ifeq ($(CONFIG_PLATFORM_ARM_MYIMX6), y)
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
ARCH := arm
CROSS_COMPILE ?= ~/IMX6/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf-
KVER ?= 3.14.52
KSRC ?= /home/linyn/rs485/linux-custom
endif
vim include/autoconf.h
修改:
#define CONFIG_IOCTL_CFG80211
#ifdef CONFIG_IOCTL_CFG80211
#define RTW_USE_CFG80211_STA_EVENT
//#defineCONFIG_CFG80211_FORCE_COMPATIBLE_2_6_37_UNDER
//#define CONFIG_DEBUG_CFG80211 1
#endif
...
...
#define CONFIG_CONCURRENT_MODE
…
最后编译模块8188eu.ko
3.移植hostapd和dhcpd
a)如果是用buildroot编译的话,直接用make menuconfig配置就行,这里不讲了
b)或者自己独立编译hostapd和dhcpd
独立编译可以看网站
https://blog.csdn.net/beesui/article/details/10227931
https://blog.csdn.net/hinyunsin/article/details/6029749
4.配置hostapd和dhcpd
a) 配置hostapd
vim /etc/hostapd.conf
interface=wlan0
driver=nl80211
ssid=MYZR
channel=9
hw_mode=g
macaddr_acl=0
ignore_broadcast_ssid=0
auth_algs=1
wpa=3
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
b)配置dhcpd
touch /var/db/dhcpd.leases
vim /etc/dhcpd.conf
在最后增加:
subnet 192.168.155.0 netmask 255.255.255.0
{
range 192.168.155.2 192.168.155.10;
option domain-name-servers 8.8.8.8;
option routers 192.168.155.1;
}
5.启动热点和自动获取IP
echo "1" >/proc/sys/net/ipv4/ip_forward
hostapd -B /etc/hostapd.conf
ifconfig wlan0 192.168.155.1
dhcpd wlan0
看图片“WIFIAP.png”
最后通过手机,可以搜索“MYZR”的热点,直接输入密码“12345678”,这样手机WIF连接成功,会自动分别192.168.155.*的IP.
注意:以上虽然分配到IP,但是不能上网,需要使用iptables开启本地的SNAT
经过前面几个步骤,无线网卡已经可以自动分配IP,现在只需要把无线网卡的数据都经过eth0(有线网络)发到外网去,这就需要IP转发了。
6.配置内核
Networking support --->
Networking options ---> Network packet filtering framework (Netfilter) --->
Core Netfilter Configuration ---> //除了下面列出的其他全选
< > Transparent proxying support (EXPERIMENTAL)
< > set target and match support
< > CHECKSUM target support
< > "CT" target support
< > "DSCP" and "TOS" target support
< > "NOTRACK" target support
< > "TCPOPTSTRIP" target support (EXPERIMENTAL)
< > "dscp" and "tos" match support
< > "ipvs" match support
<*> IP set support --->
(256) Maximum number of IP sets
<*> bitmap:ip set support
<*> bitmap:ip,mac set support
<*> bitmap:port set support
<*> list:set set support
<*> IP virtual server support ---> //除了下面列出的其他全选
[ ] IP virtual server debugging
[ ] SCTP load balancing support
< > FTP protocol helper
< > SIP persistence engine
IP: Netfilter Configuration ---> //里面的全选
<*> RF switch subsystem support --->
//注意要选最后一项,不然在使用hostapd命令时会出错,“rfkill: Cannot open RFKILL control device”.
7.移植iptables直接用buildroot配置编译就行,或者独立编译,這里不讲了udhcpc -i eth0
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
这样连接wifi,手机和ubuntu的WPA2-PSK的无线wifi AP设置完毕,可以正常使用了。
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|