转载至:
http://blog.csdn.net/kuangzuxiaoN/article/details/75028643
开发环境: ubuntu
16.04LTS
目标环境:
iTOP4412精英板
交叉编译器:
arm-2014.05
到官网下载最新的版本wpa_supplicant-2.6
在官网可以看到wpa_supplicant-2.6的依赖程序
WPA Supplicant
Dependencies
Recommended
libnl-3.3.0 and
OpenSSL-1.1.0f
Optional
dbus-1.10.20,
libxml2-2.9.4, and Qt-5.9.1
主要依赖于libnl-3.3.0和OpenSSL-1.1.0f,这里给出下载地址:
libnl-3.3.0:
OpenSSL-1.1.0f:
移植步骤:
(1)首先移植openssl-1.1.0f
1.
解压并进入到openssl-1.1.0f主目录
-
tar -xvf openssl-1.1.0f
-
cd openssl-1.1.0f
2. 执行
-
./Configure linux-armv4 --prefix=/usr/local/arm/openssl
配置目标环境,根据自己的板子具体修改,Exynos4412是armv7架构,并且给定路径参数,我要安装的绝对路径是/usr/local/arm/openssl
配置成功后,可以看到
-
Configuring for linux-armv4
-
CC =gcc
-
CFLAG =-Wall -O3 -pthread
-
SHARED_CFLAG =-fPIC -DOPENSSL_USE_NODELETE
-
DEFINES =DSO_DLFCN HAVE_DLFCN_H NDEBUG OPENSSL_THREADS OPENSSL_NO_STATIC_ENGINE OPENSSL_PIC OPENSSL_BN_ASM_MONT OPENSSL_BN_ASM_GF2m SHA1_ASM SHA256_ASM SHA512_ASM AES_ASM BSAES_ASM GHASH_ASM ECP_NISTZ256_ASM POLY1305_ASM
-
LFLAG =
-
PLIB_LFLAG =
-
EX_LIBS =-ldl
-
APPS_OBJ =
-
CPUID_OBJ =armcap.o armv4cpuid.o
-
UPLINK_OBJ =
-
BN_ASM =bn_asm.o armv4-mont.o armv4-gf2m.o
-
EC_ASM =ecp_nistz256.o ecp_nistz256-armv4.o
-
DES_ENC =des_enc.o fcrypt_b.o
-
AES_ENC =aes_cbc.o aes-armv4.o bsaes-armv7.o aesv8-armx.o
-
BF_ENC =bf_enc.o
-
CAST_ENC =c_enc.o
-
RC4_ENC =rc4_enc.o rc4_skey.o
-
RC5_ENC =rc5_enc.o
-
MD5_OBJ_ASM =
-
SHA1_OBJ_ASM =sha1-armv4-large.o sha256-armv4.o sha512-armv4.o
-
RMD160_OBJ_ASM=
-
CMLL_ENC =camellia.o cmll_misc.o cmll_cbc.o
-
MODES_OBJ =ghash-armv4.o ghashv8-armx.o
-
PADLOCK_OBJ =
-
CHACHA_ENC =chacha-armv4.o
-
POLY1305_OBJ =poly1305-armv4.o
-
BLAKE2_OBJ =
-
PROCESSOR =
-
RANLIB =ranlib
-
ARFLAGS =
-
PERL =/usr/bin/perl
-
-
THIRTY_TWO_BIT mode
-
BN_LLONG mode
-
RC4 uses unsigned char
-
-
Configured for linux-armv4.
3.
这里就需要修改交叉编译器,修改Makefile
添加交叉编译器:
-
CROSS_COMPILE=/usr/local/arm/arm-2014.05/bin/arm-none-linux-gnueabi-
配置参数中已经指定了路径,因此在Makefile不用修改,可以看到:
-
51: INSTALLTOP=/usr/local/arm/openssl
-
52: OPENSSLDIR=/usr/local/arm/openssl/ssl
-
53: LIBDIR=lib
-
54: ENGINESDIR=/usr/local/arm/openssl/lib/engines-1.1
4. 执行make,完成编译
5. 执行sudo make
install,完成安装
6.
可以看到openssl被编译成静态库,放在指定目录/usr/local/arm/openssl下
-
yang@yang:/usr/local/arm/openssl$ ls
-
bin include lib share ssl
-
yang@yang:/usr/local/arm/openssl/lib$ ls
-
engines-1.1 libcrypto.so libssl.a libssl.so.1.1
-
libcrypto.a libcrypto.so.1.1 libssl.so pkgconfig
-
yang@yang:/usr/local/arm/openssl/lib$
7.
将lib中的libcrypto.a、libcrypto.so.1.1、libssl.so.1.1和libssl.a文件拷贝到开发板文件系统的/lib目录下,bin中的openssl文件拷贝到开发板的/bin中
(2)移植libnl-3.3.0
1.解压并进入到主目录
2.配置交叉编译选项
-
sudo ./configure --host=arm-linux --prefix=/usr/local/arm/libnl --enable-static --enable-shared CC=/usr/local/arm/arm-2014.05/bin/arm-none-linux-gnueabi-gcc
在这里交叉编译器用的是绝对路径。
可能会出现如下错误:
-
configure: WARNING: bison not found. Please install before continuing.
-
configure: WARNING: flex not found. Please install before continuing.
-
configure: error: Required packages are missing. Please install them and rerun ./configure
根据提示,安装bison和flex
-
sudo apt-get install bison
-
sudo apt-get install flex
再次使用配置编译选项命令,最终看到如下输出
-
-------------------------------------------------------------------------------
-
NOTE
-
-
There have been some changes starting with 3.2 regarding where and how libnl
-
is being installed on the system in order to allow multiple libnl versions
-
to be installed in parallel:
-
-
- Headers will be installed in ${prefix}/include/libnl3, therefore
-
you will need to add "-I/usr/include/libnl3" to CFLAGS
-
-
- The library basename was renamed to libnl-3, i.e. the SO names become
-
libnl-3.so., libnl-route-3.so, etc.
-
-
- libtool versioning was assumed, to ease detection of compatible library
-
versions.
-
-
If you are using pkg-config for detecting and linking against the library
-
things will continue magically as if nothing every happened. If you are
-
linking manually you need to adapt your Makefiles or switch to using
-
pkg-config files.
-
-
-------------------------------------------------------------------------------
配置成功。
3.
开始编译,执行make命令
4. 安装,执行make
install命令
在/usr/local/arm/libnl目录下有以下文件
-
yang@yang:/usr/local/arm/libnl$ ls
-
bin etc include lib share
-
yang@yang:/usr/local/arm/libnl$ ls lib/
-
libnl libnl-genl-3.so libnl-route-3.a
-
libnl-3.a libnl-genl-3.so.200 libnl-route-3.la
-
libnl-3.la libnl-genl-3.so.200.25.0 libnl-route-3.so
-
libnl-3.so libnl-idiag-3.a libnl-route-3.so.200
-
libnl-3.so.200 libnl-idiag-3.la libnl-route-3.so.200.25.0
-
libnl-3.so.200.25.0 libnl-idiag-3.so libnl-xfrm-3.a
-
libnl-cli-3.a libnl-idiag-3.so.200 libnl-xfrm-3.la
-
libnl-cli-3.la libnl-idiag-3.so.200.25.0 libnl-xfrm-3.so
-
libnl-cli-3.so libnl-nf-3.a libnl-xfrm-3.so.200
-
libnl-cli-3.so.200 libnl-nf-3.la libnl-xfrm-3.so.200.25.0
-
libnl-cli-3.so.200.25.0 libnl-nf-3.so pkgconfig
-
libnl-genl-3.a libnl-nf-3.so.200
-
libnl-genl-3.la libnl-nf-3.so.200.25.0
5.
安装成功,将libnl-3.so.200.25.0、libnl-genl-3.so.200.25.0放到开发板的/lib目录,并创建软链接
-
ln -s libnl-3.so.200.25.0 libnl-3.so
-
ln -s libnl-3.so.200.25.0 libnl-3.so.200
-
ln -s libnl-genl-3.so.200.25.0 libnl-genl-3.so
-
ln -s libnl-genl-3.so.200.25.0 libnl-genl-3.so.200
(3)移植wpa_supplicant-2.6
1.
解压并进入到wpa_supplicant-2.6主目录,并生成.config文件
-
cd wpa_supplicant-2.6
-
cp defconfig .config
2. 修改.config文件
-
CC=/usr/local/arm/arm-2014.05/bin/arm-none-linux-gnueabi-gcc -L/usr/local/arm/openssl/lib
-
CFLAGS += -I/usr/local/arm/openssl/include
-
LIBS += -L/usr/local/arm/openssl/lib
-
-
CONFIG_DRIVER_NL80211=y
-
-
CONFIG_LIBNL32=y
-
CFLAGS += -I/usr/local/arm/libnl/include
-
LIBS += -L/usr/local/arm/libnl/lib
这里只给出主要的修改部分,其他使用默认设置就好。注意,这里一定要添加libnl的配置,否则会出现错误:
-
../src/drivers/driver_nl80211.c:17:31: fatal error: netlink/genl/genl.h: No such file or directory
-
#include
-
^
-
compilation terminated.
-
Makefile:1776: recipe for target '../src/drivers/driver_nl80211.o' failed
-
make: *** [../src/drivers/driver_nl80211.o] Error 1
3. 编译,执行make
4. 将生成的wpa_cli、wpa_passphrase、
wpa_supplicant等工具添加到开发板文件系统/bin目录下,并且拷贝配置文件到开发板文件系统/etc目录下。
-
cp examples/wpa-psk-tkip.conf rootfs/etc/wpa_supplicant.conf
5.
修改wpa_supplicant.conf
-
# WPA-PSK/TKIP
-
-
ctrl_interface=/var/run/wpa_supplicant
-
-
network={
-
ssid="yang" #无线网络名称
-
key_mgmt=WPA-PSK
-
proto=WPA
-
pairwise=TKIP
-
group=TKIP
-
psk="57b559b778" #无线网络密码
-
}
(4)测试wpa_supplicant
1.
在开发板的/var/run/下创建文件wpa_supplicant
2. 使用命令:
-
wpa_passphrase yang 57b559b778 >> wpa_supplicant.conf
创建连接暗文密码(PSK密码),通过明码转换,修改wpa_supplicant.conf,用PSK密码替换明文密码
-
# WPA-PSK/TKIP
-
-
ctrl_interface=/var/run/wpa_supplicant
-
-
network={
-
ssid="yang"
-
key_mgmt=WPA-PSK
-
proto=WPA
-
pairwise=TKIP
-
group=TKIP
-
psk=725e926081647954f9af00e46904fd6382b2cbc91b8ab7b5655a8d8db146c5dc
-
}
3.
在开发板的终端命令行使用命令wpa_supplicant,出现如下信息,说明wpa_supplicant移植成功
-
Successfully initialized wpa_supplicant
-
wpa_supplicant v2.6
-
Copyright (c) 2003-2016, Jouni Malinen and contributors
-
-
This software may be distributed under the terms of the BSD license.
-
See README for more details.
-
-
This product includes software developed by the OpenSSL Project
-
for use in the OpenSSL Toolkit (http://)
-
-
usage:
-
wpa_supplicant [-BddhKLqqtvW] [-P] [-g] \
-
[-G] \
-
-i -c [-C] [-D] [-p] \
-
[-b] [-e] \
-
[-o] [-O] \
-
[-N -i -c [-C] [-D] \
-
[-p] [-b] [-I] ...]
-
-
drivers:
-
nl80211 = Linux nl80211/cfg80211
-
wext = Linux wireless extensions (generic)
-
wired = Wired Ethernet driver
-
options:
-
-b = optional bridge interface name
-
-B = run daemon in the background
-
-c = Configuration file
-
-C = ctrl_interface parameter (only used if -c is not)
-
-d = increase debugging verbosity (-dd even more)
-
-D = driver name (can be multiple drivers: nl80211,wext)
-
-e = entropy file
-
-g = global ctrl_interface
-
-G = global ctrl_interface group
-
-h = show this help text
-
-i = interface name
-
-I = additional configuration file
-
-K = include keys (passwords, etc.) in debug output
-
-L = show license (BSD)
-
-N = start describing new interface
-
-o = override driver parameter for new interfaces
-
-O = override ctrl_interface parameter for new interfaces
-
-p = driver parameters
-
-P = PID file
-
-q = decrease debugging verbosity (-qq even less)
-
-t = include timestamp in debug messages
-
-v = show version
-
-W = wait for a control interface monitor before starting
-
example:
-
wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wpa_supplicant.conf
4.
加载网卡驱动,并且配置IP地址
-
ifconfig wlan0 up
-
ifconfig wlan0 10.42.0.12 netmask 255.255.255.0
注意:此处设置的IP需要与你将要连接的局域网IP在同一网段,或者是直接移植DHCP
5.
用ifconfig命令查看无线网卡
-
eth0 Link encap:Ethernet HWaddr 08:90:90:90:90:90
-
inet addr:192.168.1.230 Bcast:192.168.1.255 Mask:255.255.255.0
-
inet6 addr: fe80::a90:90ff:fe90:9090/64 Scope:Link
-
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
-
RX packets:19520 errors:0 dropped:123 overruns:0 frame:0
-
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
-
collisions:0 txqueuelen:1000
-
RX bytes:1323355 (1.2 MiB) TX bytes:480 (480.0 B)
-
-
lo Link encap:Local Loopback
-
inet addr:127.0.0.1 Mask:255.0.0.0
-
inet6 addr: ::1/128 Scope:Host
-
UP LOOPBACK RUNNING MTU:16436 Metric:1
-
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
-
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
-
collisions:0 txqueuelen:0
-
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
-
-
wlan0 Link encap:Ethernet HWaddr 48:8A:D2:3A:9E:24
-
inet addr:10.42.0.12 Bcast:10.42.0.255 Mask:255.255.255.0
-
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
-
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
-
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
-
collisions:0 txqueuelen:1000
-
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
6. 加载网卡成功,连接无线局域网
这里根据wpa_supplicant命令的提示,使用提示命令
-
wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wpa_supplicant.conf
会出现如下错误:
-
nl80211: deinit ifname=wlan0 disabled_11b_rates=0
-
wlan0: Failed to initialize driver interface
可见wlan0驱动不支持Linux
nl80211/cfg80211, 因此改用
-
wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf
注:关于nl80211和wext无线驱动接口的区别
nl80211 = Linux
nl80211/cfg80211
wext = Linux wireless
extensions (generic)
可参考: http://blog.csdn.net/dickjtk/article/details/11862815
7.
测试无线局域网,将要连接的无线网IP: 10.42.0.1
-
PING 10.42.0.1 (10.42.0.1): 56 data bytes
-
64 bytes from 10.42.0.1: seq=0 ttl=64 time=8.918 ms
-
64 bytes from 10.42.0.1: seq=1 ttl=64 time=1.402 ms
-
64 bytes from 10.42.0.1: seq=2 ttl=64 time=1.315 ms
-
64 bytes from 10.42.0.1: seq=3 ttl=64 time=3.993 ms
-
64 bytes from 10.42.0.1: seq=4 ttl=64 time=3.141 ms
-
64 bytes from 10.42.0.1: seq=5 ttl=64 time=2.574 ms
-
64 bytes from 10.42.0.1: seq=6 ttl=64 time=2.136 ms
-
64 bytes from 10.42.0.1: seq=7 ttl=64 time=1.561 ms
-
^C
-
--- 10.42.0.1 ping statistics ---
-
8 packets transmitted, 8 packets received, 0% packet loss
-
round-trip min/avg/max = 1.315/3.130/8.918 ms
网络连接成功。
阅读(2580) | 评论(0) | 转发(0) |