FL2440 rt3070模块ap模式移植
------------------------------------------------------------------------------------------------------------------------------
交叉编译器:arm-linux-gcc-4.5.4
Linux内核版本:Linux-3.0
主机操作系统:Centos 6.5
开发板:FL2440
本文章的内核已经已经添加了DM9000的网卡,USB驱动,使用的是initramfs的文件系统。
------------------------------------------------------------------------------------------------------------------------------
大体移植过程:添加内核支持-->编译Openssl生成一些库函数,用作后面hostapd的编译-->编译libnl生成一些库函数,用作后面hostapd的编译-->编译hostapd生成开发板所需的命令文件hostapd以及配置文件hostapd.conf-->配置udhcpd的配置文件udhcpd.conf到开发板,完成dhcp服务器功能-->开发板上运行配置文件初次尝试连接wifi-->移植iptables命令完成上网功能。
一、内核移植
make menuconfig
[*] Networking support --->
Networking options --->
<*> Packet socket
<*> Unix domain sockets
[*] TCP/IP networking
[*] TCP/IP networking
[*] IP: kernel level autoconfiguration
[*] IP: multicast routing
[*] IP: DHCP support
[*] IP: BOOTP support
[*] IP: RARP support
[*] IP: multicast routing
[*] Network packet filtering framework (Netfilter) --->
[*] Advanced netfilter configuration
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
< > "TRACE" target 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 --->
(12) IPVS connection table size (the Nth power of 2)
*** IPVS transport protocol load balancing support ***
[*] TCP load balancing support
[*] UDP load balancing support
[*] ESP load balancing support
[*] AH load balancing support
<*> round-robin scheduling
<*> weighted round-robin scheduling
<*> least-connection scheduling
<*> weighted least-connection scheduling
<*> locality-based least-connection scheduling
<*> locality-based least-connection with replication scheduling
<*> destination hashing scheduling
<*> source hashing scheduling
<*> shortest expected delay scheduling
<*> never queue scheduling
*** IPVS application helper ***
[*] Netfilter connection tracking
IP: Netfilter Configuration ---> //此下的全选
<*> RF switch subsystem support --->
二、网络配置工具移植
所需文件:
openssl-0.9.8e.tar.gz 下载地址 http://www.openssl.org/source/old/0.9.x/
libnl-1.1.4.tar.gz 下载地址 http://www.infradead.org/~tgr/libnl/
hostapd-1.0.tar.gz 下载地址 http://download.chinaunix.net/download.php?id=40061&ResourceID=4450
(1)移植openssl-0.9.8e
[xiaohexiansheng@centos6 openssl-0.9.8e]$ mkdir install
[xiaohexiansheng@centos6 openssl-0.9.8e]$ vim Makefile
修改编译生成文件所放的位置和编译器的位置
INSTALLTOP=/home/xiaohexiansheng/fl2440/3rdparty/apwifi/openssl-0.9.8e/install
CC= /opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc
AR=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-ar $(ARFLAGS) r
RANLIB= /opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-ranlib
[xiaohexiansheng@centos6 openssl-0.9.8e]$ sudo make
[xiaohexiansheng@centos6 openssl-0.9.8e]$ sudo make install
(2)移植libnl-1.1.4
在这里不需要修改Makefile文件,用 configure命令来指定安装路径和软件运行的系统平台
[xiaohexiansheng@centos6 libnl-1.1.4]$ mkdir install
[xiaohexiansheng@centos6 libnl-1.1.4]$ ./configure --prefix=/home/xiaohexiansheng/fl2440/3rdparty/apwifi/openssl-0.9.8e/install --host=arm-linux
[xiaohexiansheng@centos6 libnl-1.1.4]$ sudo make CC=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc
[xiaohexiansheng@centos6 libnl-1.1.4]$ sudo make install
将install/lib/目录下的libnl.so.1文件发送到开发板的/lib/目录下
(3)移植hostapd-1.0
修改.config文件和Makefile文件
[xiaohexiansheng@centos6 hostapd]$ cp defconfig .config
[xiaohexiansheng@centos6 hostapd]$ vim .config
添加:
CONFIG_DRICER_NL80211=y
[xiaohexiansheng@centos6 hostapd]$ vim Makefile
添加:
CFLAGS +=-I/home/xiaohexiansheng/fl2440/3rdparty/apwifi/libnl-1.1.4/install/include
CFLAGS +=-I/home/xiaohexiansheng/fl2440/3rdparty/apwifi/openssl-0.9.8e/install/include
LIBS +=-L/home/xiaohexiansheng/fl2440/3rdparty/apwifi/libnl-1.1.4/install/lib
LDFLAGS +=-L/home/xiaohexiansheng/fl2440/3rdparty/apwifi/libnl-1.1.4/install/lib
LIBS +=-L/home/xiaohexiansheng/fl2440/3rdparty/apwifi/openssl-0.9.8e/install/lib
LDFLAGS +=-L/home/xiaohexiansheng/fl2440/3rdparty/apwifi/openssl-0.9.8e/install/lib
[xiaohexiansheng@centos6 hostapd]$ make CC=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc
[xiaohexiansheng@centos6 hostapd]$ sudo make install
参考网上的资料修改hostapd.conf配置文件
[xiaohexiansheng@centos6 hostapd]$ vim hostapd.conf
配置文件修改如下:
nterface=wlan0
driver=nl80211
ssid=guanlei
channel=3
hw_mode=g
ignore_broadcast_ssid=0
auth_algs=1
wpa=3
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK WPA-EAP
wpa_pairwise=TKIP CCMP
拷贝当前目录下生成的hostapd与hostapd.conf文件到开发板上,给hostapd可执行权限。
(4)配置udhcpd
参考网上的资料配置udhcpd.conf文件
udhcpd.conf在busybox下的/examples/udhcpd/目录下
修改如下:
start 192.168.2.20 //修改IP池,起始IP的后两位可以随意,但必须在一个网段。
end 192.168.2.254
interface wlan0 //修改执行dhcp功能的接口
opt dns 8.8.8.8 //修改DNS、网关、netmask
option subnet 255.255.255.0
opt router 192.168.2.1
三、开发板上运行配置文件
理一下所需的文件和文件要放的位置:
/lib/:libnl.so.1
hostapd(执行命令)、hostapd.conf(配置文件)、udhcpd(执行命令)、udhcpd.conf(配置文件)
如果想要启动wlan0还需要一个rt2870的固件。下载地址:
git clone git://git.kernel.org/pub/scm/linux/kernel/git/dwmw2/linux-firmware.git
在开发板下创建/lib/firmware文件夹,将下载下来的linux-firmware/rt2870.bin拷贝到开发板的firmware文件夹下。
接下来开始配置开发板
(1)配置hostapd
>:./hostapd -B hostapd.conf
Configuration file: hostapd.conf
phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 0 - CWmin: 3, CWmax: 4, Aifs: 2, TXop: 102.
phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 1 - CWmin: 4, CWmax: 5, Aifs: 2, TXop: 188.
phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 2 - CWmin: 5, CWmax: 10, Aifs: 3, TXop: 0.
phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 3 - CWmin: 5, CWmax: 10, Aifs: 7, TXop: 0.
Using interface wlan0 with hwaddr 00:a1:b0:40:6f:9a and ssid 'xiaohexiansheng'
phy0 -> rt2x00usb_watchdog_tx_status: Warning - TX queue 0 status timed out, invoke forced tx handler
phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 0 - CWmin: 2, CWmax: 3, Aifs: 1, TXop: 47.
phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 1 - CWmin: 3, CWmax: 4, Aifs: 1, TXop: 94.
phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 2 - CWmin: 4, CWmax: 6, Aifs: 3, TXop: 0.
phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 3 - CWmin: 4, CWmax: 10, Aifs: 7, TXop: 0.
若出现读取random随机数错误,可采用符号链接的方法解决:
# mv /dev/random /dev/random.org
# ln -s /dev/urandom /dev/random
若出现如下错误:
Failed to create interface mon.wlan0: -23 (Too many open files in system)
ctrl_iface exists and seems to be in use - cannot override it
Delete '/var/run/hostapd/wlan0' manually if it is not used anymore
Failed to setup control interface
wlan0: Unable to setup interface.
解决方案:删除./hostapd的进程,删除/var/run下面的hostapd messages这两个文件
>: ifconfig wlan0 192.168.2.1 netmask 255.255.255.0 (先把要接入点设备设置好)
(2)配置udhcpd
执行udhcpd命令之前需要一个udhcpd.release的租赁文件,在相应的文件夹下创建即可。
>:mkdir -p /var/lib/misc/
>:touch /var/lib/misc/udhcpd.leases
>:udhcpd -f /etc/udhcpd.conf
udhcpd (v1.20.2) started
Sending OFFER of 192.168.2.20
Sending ACK to 192.168.2.20
OK,手机可以连上自己的开发板了。
四、定义防火墙策略实现开发板上网功能
iptables-1.4.12.tar.bz2 下载地址:http://www.netfilter.org/projects/iptables/downloads.html
[xiaohexiansheng@centos6 iptables-1.4.12]$ mkdir install
[xiaohexiansheng@centos6 iptables-1.4.12]$ ./configure --host=/arm-linux --enable-static --disable-shared --prefix=/home/xiaohexiansheng/fl2440/3rdparty/apwifi/iptables-1.4.12/install --disable-ipv6 --disable-largefile
[xiaohexiansheng@centos6 iptables-1.4.12]$ make CC=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc CFALGS=--static LDFLAGS=-static
[xiaohexiansheng@centos6 iptables-1.4.12]$ sudo make install
[xiaohexiansheng@centos6 iptables]$ sudo /opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-strip xtables-multi //strip 减少大小用的
将/install/lib文件夹和xtables-multi打包放到开发板/lib和/bin目录下,赋予可执行权限后将xtables-multi改名为iptables
在开发板上配置nat表。
//将局域网内地址通过eth0接口伪装后转发出去
>:iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
//开启转发功能,允许已建立连接及相关连接对内转发
>: iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISH -j ACCEPT
//对外转发,数据包从wlan0流向eth0
>: iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
/*开启linux 的转发功能! Linux系统是默认进制数据包转发的,所谓的转发就是当主机拥有多块网卡的时候,其中一块收到数据包,根据数据包的目的ip转发到本机的另一张网卡上,该网卡根据路由表继续发送数据包首先保证硬件连通,然后打开系统的转发功能
less /proc/sys/net/ipv4/ip_forward,该文件内容为0,表示禁止数据包转发,1表示允许,将其修改为1。可使用命令echo "1" > /proc/sys/net/ipv4/ip_forward 修改文件内容,重启网络服务或主机后效果不再*/
>:echo "1" >/proc/sys/net/ipv4/ip_forward
到此,手机连上wifi模块就可以上网了。
FL2440 rt3070模块ap模式移植的更多相关文章
- FL2440 rt3070模块station模式移植
---------------------------------------------------------------------------------------------------- ...
- FL2440 rt3070模块station模式动态获取IP地址
---------------------------------------------------------------------------------------------------- ...
- MT7601 AP模式移植
MT7601 的 STA 模式和 AP 模式的驱动,是不一样的. 所以,需要另外移植驱动 驱动源码位置 https://github.com/eywalink/mt7601u 下载之后,先修改 Mak ...
- Android KitKat 4.4 Wifi移植AP模式和网络共享的调试日志
Tethering技术在移动平台上已经运用的越来越广泛了.它能够把移动设备当做一个接入点,其它的设备能够通过Wi-Fi.USB或是Bluetooth等方式连接到此移动设备.在Android中能够将Wi ...
- 3.1 wifi网卡RT3070在S3C2440的移植和使用
学习目标:熟悉RT3070在S3C2440的移植和使用,以及其中的相关工具的安装和使用: 一.配置内核选择WIFI驱动 1. 将usb wifi插到电脑,在ubuntu使用命令:# lsusb 查看w ...
- 关于 RTL8723BS 同时开启 STA/AP 模式
最近接到一个调试 wifi 驱动的任务,使用的是 rtl8723bs 芯片组.要求是让无线设备工作在 station 模式的时候同时开启一个 ap 热点.简单来讲就是连接其他 wifi 的同时发出一个 ...
- Marvell w8782 sdio wifi AP模式设置
http://blog.csdn.net/junllee/article/details/8895908 w8782工作在station模式一切正常,于是想试试AP模式(master mode): A ...
- Nacos源码结构和AP模式注册中心实现介绍
前言 NacosAP模式源码分析目录 微服务下的注册中心如何选择 Nacos使用和注册部分源码介绍 Nacos服务心跳和健康检查源码介绍 Nacos服务发现 Nacos源码结构介绍 Nacos版本基于 ...
- 树莓派配置AP模式
所需硬件:树莓派.无线网卡 1.查看无线网卡是否被识别 pi@raspberrypi ~ $ sudo lsusb Bus Device : ID : Standard Microsystems Co ...
随机推荐
- django中管理程序1
为了解决启动关闭程序方便,在django中启动结束任务的问题. urls.py ################DJANGO start kill job####################### ...
- 【C++】指针和new相关
看黄邦勇帅的笔记. 指针和new之前觉得已经掌握的很好了,可是看了资料还是get到了新知识.记录一下. 1.指针只支持 4 种算术运算符:++,――,+,-.指针只能与整数加减.指针运算的原则是:每当 ...
- Selenium2+python自动化61-Chrome浏览器(chromedriver)【转载】
前言 selenium2启动Chrome浏览器是需要安装驱动包的,但是不同的Chrome浏览器版本号,对应的驱动文件版本号又不一样,如果版本号不匹配,是没法启动起来的. 一.Chrome遇到问题 1. ...
- Java中的标记接口(zz)
1.什么是标记接口? Java中把没有定义任何方法和常量的接口称之为标记接口,我们经常使用的比较多的是“”Serializable“”,这个接口也是没有定义人任何方法和常量的. 2.标记接口的作用? ...
- Android xmlpull 方式解析xml文件
1.新建一个xml文件,放在res/xml目录下 <?xml version="1.0" encoding="utf-8"?> <citys& ...
- mysql主从怎么样使主为innodb辅为myisam
MySQL主从复制(linux主+windows从) http://blog.csdn.net/qq_20032995/article/details/54380290 mysql主从怎么样使主为in ...
- (7)case语句
(1)case 语法 case "变量" in 模式1) 命令序列1 ;; 模式2) 命令序列2 ;; 模式3) 命令序列3 ;; *) 无匹配后命令序列 esac (2)多系统配 ...
- 安装mezzanine时报:storing debug log for failure【已解决】
同时还提示: bz2 module is not found(貌似) 解决方法: 1.重新安装python wget http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz ...
- Codeforces 811 B. Vladik and Complicated Book
B. Vladik and Complicated Book time limit per test 2 seconds memory limit per test 256 megabytes i ...
- HDU 6213 Chinese Zodiac 【模拟/水题/生肖】
Problem Description The Chinese Zodiac, known as Sheng Xiao, is based on a twelve-year cycle, each y ...