交叉编译使用 hostapd-2.0 在开发板上开机自启动无线网卡 AP 功能
文章目录
- 交叉编译
- 使用 hostapd
- 使用 DHCP 分配 IP
- 查看状态
- 开机自启动
- 1. MDEV 配置文件
- 2. MDEV 执行的脚本
- 参考链接
交叉编译
tar xzf hostapd-2.0.tar.gz
cd hostapd-2.0/hostapd
cp defconfig .config
vim Makefile{CC=arm-linux-gcc}
错误
…/src/drivers/driver_nl80211.c:19:31: fatal error: netlink/genl/genl.h: No such file or directory
在我的编译器库头文件中明明有这个路径和这个文件却找不到
vim Makefile
在第 6 行添加 --verbose 选项打印 gcc 编译信息
CFLAGS = -MMD -O2 -Wall -g --verbose
得到输出:
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:../src../src/utils/usr/lib/gcc/x86_64-linux-gnu/5/include/usr/local/include/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/usr/include/x86_64-linux-gnu/usr/include
End of search list.
GNU C11 (Ubuntu 5.4.0-6ubuntu1~16.04.12) version 5.4.0 20160609 (x86_64-linux-gnu)compiled by GNU C version 5.4.0 20160609, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
原来是在用gcc编译,可是我明明修改了 Makefile 为 arm-linux-gcc
再次 vim Makefile 发现,第一行有判断,所以我直接在第 25 行左右直接添加一行
CC=arm-linux-gcc
再次
make
报错:
/usr/local/arm/4.3.2/bin/…/lib/gcc/arm-none-linux-gnueabi/4.3.2/…/…/…/…/arm-none-linux-gnueabi/bin/ld: cannot find -lnl
返回上一层目录
搜索
grep "\-lnl" * -nRsrc/drivers/drivers.mk:31: DRV_LIBS += -lnl-3
src/drivers/drivers.mk:32: DRV_LIBS += -lnl-genl-3
src/drivers/drivers.mk:36: DRV_LIBS += -lnl-tiny
src/drivers/drivers.mk:38: DRV_LIBS += -lnl
src/drivers/drivers.mk:42: DRV_LIBS += -lnl-genl
src/drivers/drivers.mk:152: DRV_LIBS += -lnl-3
src/drivers/drivers.mk:153: DRV_LIBS += -lnl-genl-3
src/drivers/drivers.mk:154: DRV_LIBS += -lnl-route-3
src/drivers/drivers.mk:158: DRV_LIBS += -lnl-tiny
src/drivers/drivers.mk:160: DRV_LIBS += -lnl
src/drivers/drivers.mk:164: DRV_LIBS += -lnl-genl
src/drivers/drivers.mk:165: DRV_LIBS += -lnl-route
src/drivers/drivers.mak:31: DRV_LIBS += -lnl-3
src/drivers/drivers.mak:32: DRV_LIBS += -lnl-genl-3
src/drivers/drivers.mak:36: DRV_LIBS += -lnl-tiny
src/drivers/drivers.mak:38: DRV_LIBS += -lnl
src/drivers/drivers.mak:42: DRV_LIBS += -lnl-genl
src/drivers/drivers.mak:148: DRV_LIBS += -lnl-3
src/drivers/drivers.mak:149: DRV_LIBS += -lnl-genl-3
src/drivers/drivers.mak:150: DRV_LIBS += -lnl-route-3
src/drivers/drivers.mak:154: DRV_LIBS += -lnl-tiny
src/drivers/drivers.mak:156: DRV_LIBS += -lnl
src/drivers/drivers.mak:160: DRV_LIBS += -lnl-genl
src/drivers/drivers.mak:161: DRV_LIBS += -lnl-route
去编译器库看一看:
cd /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib
ls libnl*libnl-3.a libnl-genl-3.a libnl-nf-3.a
libnl-3.la libnl-genl-3.la libnl-nf-3.la
libnl-3.so libnl-genl-3.so libnl-nf-3.so
libnl-3.so.200 libnl-genl-3.so.200 libnl-nf-3.so.200
libnl-3.so.200.18.0 libnl-genl-3.so.200.18.0 libnl-nf-3.so.200.18.0
libnl-cli-3.a libnl-idiag-3.a libnl-route-3.a
libnl-cli-3.la libnl-idiag-3.la libnl-route-3.la
libnl-cli-3.so libnl-idiag-3.so libnl-route-3.so
libnl-cli-3.so.200 libnl-idiag-3.so.200 libnl-route-3.so.200
libnl-cli-3.so.200.18.0 libnl-idiag-3.so.200.18.0 libnl-route-3.so.200.18.0
打开 src/drivers/drivers.mk 发现
需要定义 CONFIG_LIBNL32 才能使用 -lnl-3 的库
30 ifdef CONFIG_LIBNL3231 DRV_LIBS += -lnl-332 DRV_LIBS += -lnl-genl-333 DRV_CFLAGS += -DCONFIG_LIBNL20 -I/usr/include/libnl334 else35 ifdef CONFIG_LIBNL_TINY36 DRV_LIBS += -lnl-tiny37 else38 DRV_LIBS += -lnl39 endif40 41 ifdef CONFIG_LIBNL2042 DRV_LIBS += -lnl-genl43 DRV_CFLAGS += -DCONFIG_LIBNL2044 endif45 endif46 endif
所以 vim .config
添加一行
CONFIG_LIBNL32=y
重新编译
make clean
make
编译成功
安装:
vim Makefile
搜索 install
847 install: all
848 mkdir -p $(DESTDIR)/usr/local/bin
849 for i in $(ALL); do cp -f $$i $(DESTDIR)/usr/local/bin/$$i; done
mkdir tmp
make DESTDIR=$PWD/tmp install
cd tmp/usr/local/bin
拷贝文件到开发板根文件系统
cp * /nfsroot/rootfs-1.20.0/bin/
使用 hostapd
hostapd.conf
/ # hostapd -h
hostapd v2.0
User space daemon for IEEE 802.11 AP management,
IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator
Copyright (c) 2002-2012, Jouni Malinen <j@w1.fi> and contributorsusage: hostapd [-hdBKtv] [-P <PID file>] [-e <entropy file>] \[-g <global ctrl_iface>] <configuration file(s)>options:-h show this usage-d show more debug messages (-dd for even more)-B run daemon in the background-e entropy file-g global control interface path-P PID file-K include key data in debug messages-t include timestamps in some debug messages-v show hostapd version
创建配置文件 /etc/hostapd.conf
无密码 AP 配置:
interface=wlan0
driver=nl80211
ssid=xhr_embedded
channel=1
WPA & WPA2 配置:
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=1234567890
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
执行命令,就可以使用手机搜索到名为 xhr_embedded 的 WLAN。
hostapd -B /etc/hostapd.conf
输入密码后,开发板打印信息已经可以看到连接成功,但手机上一直显示 “正在从 xhr_embedded 获取 IP 地址”,所以还需要设置 IP 才能正常使用。
使用 DHCP 分配 IP
修改 DHCP 的配置文件
vim /etc/dhcpd.conf
24 # add by xhr_embedded25 subnet 192.168.13.0 netmask 255.255.255.0 {26 range 192.168.13.10 192.168.13.255;27 option domain-name-servers 192.168.13.1;28 option domain-name "xhr_embedded";29 option routers 192.168.13.1;30 }
执行命令:
dhcpd -cf /etc/dhcpd.conf wlan0
报错:
For info, please visit https://www.isc.org/software/dhcp/
Can’t open lease database /var/db/dhcpd.leases: No such file or directory –
创建 /var/db/dhcpd.leases
mkdir -p /var/db
touch /var/db/dhcpd.leases
再次报错:
For info, please visit https://www.isc.org/software/dhcp/
Wrote 0 class decls to leases file.
Wrote 0 deleted host decls to leases file.
Wrote 0 new dynamic host decls to leases file.
Wrote 0 leases to leases file.
No subnet declaration for wlan0 (no IPv4 addresses).
** Ignoring requests on wlan0. If this is not what
you want, please write a subnet declaration
in your dhcpd.conf file for the network segment
to which interface wlan0 is attached. **
Not configured to listen on any interfaces!
没有配置 wlan0 的 ip,所以不知道使用配置文件里的哪一个配置。
ifconfig wlan0 192.168.13.1
ping 测试
/ # ping 192.168.13.10
PING 192.168.13.10 (192.168.13.10): 56 data bytes
64 bytes from 192.168.13.10: seq=0 ttl=64 time=170.872 ms
64 bytes from 192.168.13.10: seq=1 ttl=64 time=196.023 ms
64 bytes from 192.168.13.10: seq=2 ttl=64 time=213.892 ms
64 bytes from 192.168.13.10: seq=3 ttl=64 time=27.063 ms
已经可以 ping 通手机
查看状态
使用 hostapd_cli 来连接 hostapd,可以通过命令来获取状态。
hostapd_cli
报错:
Could not connect to hostapd - re-trying
在 /etc/hostapd.conf 中添加:
# /var/run/hostapd is the recommended directory for sockets and by default,
# hostapd_cli will use it when trying to connect with hostapd.
ctrl_interface=/var/run/hostapd
使用 hostapd_cli 不加命令进入交互模式。
all_sta
查看 DHCP 的地址分配
vi /var/db/dhcpd.leases
开机自启动
1. MDEV 配置文件
vim /etc/mdev.conf
wlan0 0:0 660 * /sbin/auto_ap.sh
2. MDEV 执行的脚本
vim /sbin/auto_ap.sh
chmod +x /sbin/auto_ap.sh
#!/bin/sh
if [ $ACTION = "add" ];
then ifconfig wlan0 192.168.13.1dhcpd -cf /etc/dhcpd.conf wlan0hostapd -B /etc/hostapd.conf
else killall hostapdkillall dhcpd
fi
参考链接
hostapd 官网
hostapd.conf
交叉编译使用 hostapd-2.0 在开发板上开机自启动无线网卡 AP 功能相关推荐
- linux 嵌入上电自动运行,如何在linux嵌入式开发板上开机自动运行用户应用程序...
开机后自动运行用户的应用程序或启动系统服务的命令保存在开发板根文件系统的/usr/etc/rc.local文件中.有的开发板开机后自动运行图形界面程序,需要按住ctrl+c让开发板进入到linux的S ...
- 海思开发板设置开机自启动方法
通过对ubuntu系统的开机自启动的更改,发现可以在海思平台下也进行开机自启动的更改,而且实际测试完全有效,但是尽量不要将一些耗费时间的应用进行开机启动. 设置步骤: 1.在虚拟机下将海思下的可执行文 ...
- 嵌入式开发板上基于RTL8188EUS搭建AP
最近发现,很多文章提及RTL8188EUS无法搭建AP,于是实际测试了下,发现可以,以下记录此次构建过程 博客地址:http://blog.csdn.net/pengrui18/article/det ...
- apache arm 交叉编译_Apache 2移植到Arm开发板的过程整理——如何交叉编译Apache 2
话说要在arm开发板的linux系统中运行apache服务器,需要在pc linux系统中交叉编译Apache源码,在网上参考了很多资料都是1.3版本的,最后终于找到apache 2移植到arm开发板 ...
- ubuntu交叉编译Qt-5库并移植ARM开发板
前言:本文将介绍Qt5源码方式的交叉编译及安装 下载源码包:qt-everywhere-src-5.12.8.tar.xz 官网下载网址:Index of / 依次选择: [official_rele ...
- 编译linux系统到开发板,Linux系统有关交叉编译和移植到6410开发板上的简单过程...
在进行移植之前,要检查一下目标机(这里指6410开发板)与宿主机之间的接线问题,即串口线.网线是否正确连接,目标机的电源是否插好!在接线问题解决后,才能保证交叉编译正常进行! 个人理解,移植的主要思想 ...
- win7下将rtt1.2.0移植到4088开发板上
1.准备工作: 下载rtt1.2.0源码: 安装python2.7: 安装scons: 安装编译器mdk 4.72; 安装串口工具putty; 2.编译源码包: 打开命令窗口cmd,进入rtt1.2. ...
- 普中科技HC6800-EM3 V3.0单片机开发板资料
HC6800-EM3 V3.0的开发板资料很难找,我也找了很久才找到,特此分享一下 点击阅读全文查看下载链接(百度云)
- ARMBoot-1.1.0 在 mini2440 开发板上的移植 之稻草人手记
ARMBoot-1.1.0 在 mini2440 开发板上的移植 之稻草人手记 < snallieATtomDOTcom > 作为U-boot的鼻祖-ARMboot以其小巧玲珑(代码压缩包 ...
最新文章
- 反arp攻击软件_谈谈电子欺骗中的ARP欺骗
- 制度缺陷,美国96%受访公司的人工智能项目陷于停顿,难怪封堵
- python鸡兔同笼编程输出不存在合理答案_Python 解答鸡兔同笼和五家共井问题
- windows 批处理程序语法
- zlib / win10 下 vs2019 编译 zlib 的方法
- session实现登录
- 点击文本框后页面变大
- jdbc读取mysql时分秒yyyy-mm-dd hh:_[转]JDBC中日期时间的处理技巧
- 已解决:手动打包war包结果无法在Tomcat中部署
- 在请求目标中找到无效字符。有效字符在RFC 7230和RFC 3986中定义
- 关于bootstrap--排版(标题、强调、背景、插入符等)
- read()/write()的生命旅程之四——第四章:writeback
- AI头发笔刷_笔刷总是不够用?我们整理精选了1000款笔刷给你
- PS学习笔记6-选区工具
- 数字孪生智慧高铁研究案例
- “去中心化”到底是什么?
- IDEA: 遇到问题Error during artifact deployment. See server log for details,解决
- python实现排序算法lowb三人组之插入排序
- 基于stm32单片机的台历日历计时器万年历Proteus仿真(源码+仿真+全套资料)
- python计算利息程序_Python——GUI编程 利息计算器 作业9(python programming)-Go语言中文社区...