所以第一步先去抓最新版的openssl,到下面的官網下載,我這邊抓的是openssl-1.0.1t
https://www.openssl.org/
抓完之後就準備開始做openssl的cross compile了
=========== cross compile openssl for arm ================
1. ./config --prefix=/home/danny/ARMv7/
2.成功config完成之後,手動進入Makefile更改toolchain的路徑
#++++++ Add+++
CROSS_COMPILE=/home/danny/x-tool/armv7-rpi2-linux-gnueabihf/bin/armv7-rpi2-linux-gnueabihf-
#======Modify =====
CC=$(CROSS_COMPILE)gcc
AR= $(CROSS_COMPILE)ar $(ARFLAGS) r
RANLIB= $(CROSS_COMPILE)ranlib
NM= $(CROSS_COMPILE)nm
3. make
在這個步驟之後,我遇到的情形,會出現如下面所秀出的一堆ERROR訊息
x86cpuid.s: Assembler messages:
x86cpuid.s:4: Error: unrecognized symbol type ""
x86cpuid.s:5: Error: alignment too large: 15 assumed
x86cpuid.s:8: Error: bad instruction `pushl %ebp'
x86cpuid.s:9: Error: bad instruction `pushl %ebx'
x86cpuid.s:10: Error: bad instruction `pushl %esi'
x86cpuid.s:11: Error: bad instruction `pushl %edi'
x86cpuid.s:12: Error: bad instruction `xorl %edx,%edx'
x86cpuid.s:13: Error: bad instruction `pushfl'
x86cpuid.s:14: Error: bad instruction `popl %eax'
x86cpuid.s:15: Error: bad instruction `movl %eax,%ecx'
x86cpuid.s:16: Error: bad instruction `xorl $2097152,%eax'
x86cpuid.s:17: Error: bad instruction `pushl %eax'
x86cpuid.s:18: Error: bad instruction `popfl'
x86cpuid.s:19: Error: bad instruction `pushfl'
x86cpuid.s:20: Error: bad instruction `popl %eax'
x86cpuid.s:21: Error: bad instruction `xorl %eax,%ecx'
x86cpuid.s:22: Error: bad instruction `xorl %eax,%eax' ..................
請在重新config一次並在後面加入一些參數如下面指令
./config --prefix=/home/danny/ARMv7/ shared no-zlib no-asm no-threads no-sse2 no-gmp no-rfc3779 no-krb5 no-rc5 no-zlib-dynamic no-hw no-cipher no-md2 no-mdc2 no-rc2 no-idea no-camellia no-ec no-ripemd no-rc4 no-bf no-cast no-perlasm
config完成之後,請記得再遵照步驟2,手動修改一下Makefile裡的toolchain路徑
4. make
make install
這樣openssl就編譯完成,並安裝在你指定的路徑了,openssl會編譯出兩個library 分別是openssl與crypt,而wpa_supplicant還需要另一個libnl
=================================================================
============== cross compile libnl for arm ==========================
libnl我是下載 libnl-3.2.28 載點如下
http://www.linuxfromscratch.org/blfs/view/svn/basicnet/libnl.html
1. ./configure ARCH=arm --prefix=/home/danny/ARMv7/ CC=/home/danny/x-tool/armv7-rpi2-linux-gnueabihf/bin/armv7-rpi2-linux-gnueabihf-gcc --host=arm-linux LD=/home/danny/x-tool/armv7-rpi2-linux-gnueabihf/bin/armv7-rpi2-linux-gnueabihf-ld
2. make
make install
這邊比較不會有甚麼問題,也可以成功編譯出libnl的library
================================================================
最後是編譯wpa_supplicant的部分
=============== cross compile wpa_supplicant for arm =================
首先新進入到下面的資料夾當中
1. cd wpa_supplicant-2.5/wpa_supplicant
2. cp defconfig .config
3. 進入Makefile做修改
CROSS_COMPILE=/home/danny/x-tools/armv7-rpi2-linux-gnueabihf/bin/armv7-rpi2-linux-gnueabihf-
CC=$(CROSS_COMPILE)gcc
export LIBDIR ?= /home/danny/ARMv7/wpa_supplicant/lib/
export INCDIR ?= /home/danny/ARMv7/wpa_supplicant/include/
export BINDIR ?= /home/danny/ARMv7/wpa_supplicant/bin/
LIBS += -L/home/danny/ARMv7/lib -lssl -lcrypto
4. make
Q1. 首先會出現錯誤訊息如下所示,這是因為找不到openssl的header檔
../src/crypto/tls_openssl.c:19:25: fatal error: openssl/ssl.h: No such file or directory
請進入Makefile修改增加下面這一行,路徑是先前openssl的安裝路徑
CFLAGS += -I/home/danny/ARMv7/include
Q2. 接著會出現錯誤訊息如下所示,這是因為找不到libnl的header檔
../src/drivers/driver_nl80211.c:17:31: fatal error: netlink/genl/genl.h: No such file or directory
請進入Makefile修改增加下面這一行,路徑是先前libnl安裝的include檔路徑
CFLAGS += -I/home/danny/ARMv7/include/libnl3
Q3. 接著會出現如下的undefined reference訊息
../src/drivers/driver_nl80211.o: In function `get_channel_width':
/home/danny/wpa_supplicant-2.5/wpa_supplicant/../src/drivers/driver_nl80211.c:6492: undefined reference to `genlmsg_attrdata'
/home/danny/wpa_supplicant-2.5/wpa_supplicant/../src/drivers/driver_nl80211.c:6492: undefined reference to `genlmsg_attrlen'
../src/drivers/driver_nl80211.o: In function `netdev_info_handler':
/home/danny/wpa_supplicant-2.5/wpa_supplicant/../src/drivers/driver_nl80211.c:519: undefined reference to `genlmsg_attrdata'
遇到這個問題,請修改.config檔,把原本被註解掉的這兩個項目打開
CONFIG_LIBNL20=y
CONFIG_LIBNL32=y
Q4. 遇到如下的錯誤訊息
Package libnl-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libnl-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libnl-3.0' found
請在terminal底下,設定如下環境變數,路徑為libnl安裝的資料夾底下lib有一個pkgconfig資料夾
export PKG_CONFIG_PATH=/home/danny/ARMv7/lib/pkgconfig
Q5. 遇到找不到libcrypto的問題,錯誤訊息如下
...armv7-rpi2-linux-gnueabihf/bin/ld.bfd: cannot find -lcrypto collect2: error: ld returned 1 exit status
請在Makefile中搜尋 -lcrypto,把找到的項目 前面都指定 先前編譯好安裝的openssl路徑,例如
LIBS += -L/home/danny/ARMv7/lib -lcrypto
LIBS_p += -L/home/danny/ARMv7/lib -lcrypto
LIBS_p += -L/home/danny/ARMv7/lib -lcrypto
總共有兩個地方要加
最後就可以順利make成功了!!!
沒有留言:
張貼留言