1、wpa_supplicant源码下载
(1)源码下载地址:http://w1.fi/releases/;
(2)本文是以wpa_supplicant-2.6.tar.gz版本进行移植;
2、编译openssl
2.1、确定适配的openssl版本
Optional libraries for EAP-TLS, EAP-PEAP, and EAP-TTLS:
- OpenSSL (tested with 1.0.1 and 1.0.2 versions; assumed to
work with most relatively recent versions; this is likely to be
available with most distributions, http://www.openssl.org/)
- GnuTLS
- internal TLSv1 implementation
(1)在wpa_supplicant源码的README说明文档中对适配的openssl版本做了说明,从上面可以2.6版本的wpa_supplicant适配1.01和1.0.2版本的openssl;
(2)如果没有在编译wpa_supplicant源码没有指定openssl,则会报错:…/src/crypto/tls_openssl.c:19: fatal error: openssl/ssl.h: No such file or directory;
(3)源码下载地址:http://www.openssl.org/;
2.2、修改Makefile
#修改安装目录
# INSTALL_PREFIX is for package builders so that they can configure
# for, say, /usr/ and yet have everything installed to /tmp/somedir/usr/.
# Normally it is left empty.
INSTALL_PREFIX=
INSTALLTOP=/home/aston/S5PV210/USB_WIFI/openssl/openssl_install
# Do not edit this manually. Use Configure --openssldir=DIR do change this!
OPENSSLDIR=/home/aston/S5PV210/USB_WIFI/openssl/openssl_install
# 修改编译链
CC= /usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-gcc
AR= /usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-ar $(ARFLAGS) r
RANLIB= /usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-ranlib
NM= /usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-nm
在主Makefile中修改openssl的安装目录和编译链;
2.3、删除掉文档安装
#install: all install_docs install_sw
install: all install_sw
(1)在安装openssl时会报错:POD document had syntax errors at /usr/bin/pod2man line 69;
(2)是因为安装文档时报错,说明文档不是必须的且我们编译openssl是为了编译wpa_supplicant工具,不需要说明文档,将install目标后面的依赖install_docs删除;
2.4、编译指令
# 编译opensll源码
root@Ubunut220401:openssl-1.0.1# make -4
# 安装openssl
root@Ubunut220401:openssl-1.0.1# make install
# 安装目录的产物
root@Ubunut220401:openssl_install# ls
bin certs include lib man misc openssl.cnf private
3、wpa_supplicant源码编译
3.1、生成配置文件
Building and installing
-----------------------
In order to be able to build wpa_supplicant, you will first need to
select which parts of it will be included. This is done by creating a
build time configuration file, .config, in the wpa_supplicant root
directory. Configuration options are text lines using following
format: CONFIG_<option>=y. Lines starting with # are considered
comments and are ignored. See defconfig file for an example configuration
and a list of available options and additional notes.
The build time configuration can be used to select only the needed
features and limit the binary size and requirements for external
libraries. The main configuration parts are the selection of which
driver interfaces (e.g., nl80211, wext, ..) and which authentication
methods (e.g., EAP-TLS, EAP-PEAP, ..) are included.
(1)上面是摘抄自wpa_supplicant源码的README说明文档,里面是关于编译wpa_supplicant源码的步骤说明,其中要求必须在编译前先生成配置文件.config,这和内核编译的机制是一样的,.config里是对wpa_supplicant工具的配置;
(2)在源码中有默认的配置文件defconfig ,如果我们没有特殊需求则可以直接将defconfig文件拷贝成.config文件;
(3)在主Makefile中会引用.config文件,命令:-include .config;
3.2、修改编译链
ifndef CC
CC=gcc
endif
(1)在主Makefile中有编译链的设置,如果在调用Makefile时没有指定编译链则使用gcc,所以我们只需要在调用时指定编译链即可;
(2)例如:make CC=/usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-gcc
3.3、设置openssl的目录
# 指定openssl头文件的路径
CFLAGS+=-I /home/aston/S5PV210/USB_WIFI/openssl/openssl_install/include
# 指定openssl库的路径
LIBS+=-L /home/aston/S5PV210/USB_WIFI/openssl/openssl_install/lib
3.4、取消CONFIG_DRIVER_NL80211配置
# Driver interface for Linux drivers using the nl80211 kernel interface
#CONFIG_DRIVER_NL80211=y
(1)在编译时报错:…/src/drivers/driver_nl80211.c:17: fatal error: netlink/genl/genl.h: No such file or directory;
(2)报错的原因是开启了CONFIG_DRIVER_NL80211配置,这个配置是依赖libnl.a库,但是我当前并没有libnl.a库,所以报错;
(3)我不想去移植libnl.a库且也用不到 nl80211内核接口,所以我将此配置关闭;
推荐
给大家推荐一个学校嵌入式知识的网站,博主在大学时候学习嵌入式知识、找工作的时候都在用这个网站,网站里有C语言、Linux等等的笔试题、面试常问问题等等知识,无论是学习基础知识、面试刷题、交流工作经验都是不错的选择。大家一起进步,欢迎留言交流。
链接:学习神器跳转