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 ...
随机推荐
- isatty
isatty - test whether a file descriptor refers to a terminal #include <stdio.h> #include <u ...
- scrapy的CrawlSpider使用
1.创建项目 我这里的项目名称为scrapyuniversal,然后我创建在D盘根目录.创建方法如下 打开cmd,切换到d盘根目录.然后输入以下命令: scrapy startproject scra ...
- 【转】Spring MVC 解读——<mvc:annotation-driven/>
转载自:http://my.oschina.net/HeliosFly/blog/205343 一.AnnotationDrivenBeanDefinitionParser 通常如果我们希望通过注解的 ...
- OC学习篇之---代理模式
何实现代理模式的. 这里举一个简单的例子: 小孩类,护士类,保姆类,其中小孩类有两个方法:wash和play 这里代理对象就是:护士类.保姆类,小孩类是被代理对象. 看一下代码: 首先看一下小孩类: ...
- inside a shard
fsync sync fsync/syncsync is a standard system call in the Unix operating system, which commits to d ...
- Android局域网访问webservice以及其中的一些问题
应老师的要求,要做个安卓app,实现备份app上的数据到服务器上的mongodb上,网上搜了下相关的实现方式.利用webservice技术,具体来说就是客户端直接调用服务器端的接口.之前从来没接触这玩 ...
- Java关于时间日期的Date类和Calendar类概述
1. System.currentTimeMillis()方法 可以获取当前时间距离1970年01月01日00时00分00秒的秒数,如果程序运行在北京时区,则获取的数据是当前时间距离1970 ...
- Linux下Tomcat安装配置
买了台阿里云服务器,因为配置比较低,所以用Linux系统,这里记录一下我在Linux系统中Tomcat的安装配置. 前提JDK已经安装好. 安装 首先在/usr/local/下建立一个tomcat的文 ...
- Codeforces #432 Div2 D
#432 Div2 D 题意 给出一些数字,如果这些数字的的 \(gcd\) 不为1则称这些数字 \(good\). 可以有两种操作: 花费 x 删掉一个数 花费 y 将一个数加 1 问使这些数 \( ...
- 洛谷——P2371 EXCEEDED WARNING C(50)
P2371 EXCEEDED WARNING C 题目背景 第三道溢出警告... 机(wei)智(suo)的TMXi又搬题来坑大家了... 注意时空限制[坏笑] 题目描述 [li]1949年,阿三的数 ...