Prior to the blog to achieve the compiler RT3070 driver Implementation STA mode and SOFTAP mode of WiFi, here to implement another way, seemingly is now relatively new, the two can also be implemented is slightly old.
Host development environment: ubuntu14.04
Cross-Compiler: ARM-XILINX-LINUX-GNUEABI-GCC
Linux kernel version: Linux-3.6.0
Development platform: ZYNQ Digital Board
Author: Zhu
Thank http://blog.csdn.net/zhengnice/article/details/51694474
and http://www.07net01.com/2015/07/888012.html two blog for this development to provide valuable experience. 1: Kernel compilation
The kernel is the use of the official Xilinx kernel linux-digilent-master of de Lun,
GitHub address: de-lun Linux-xilinx-master
My csdn Download Address:
Previous configuration file for kernel configuration: digilent_zed_1_defconfig,
Configuration file
Then refer to the configuration on the Web:
[*]
Networking Support--->-*-Wireless---> <*> cfg80211-wireless configuration API [] nl80211 testmode Command [] enable developer warnings [] cfg80211 regulatory debugging [*]
Enable PowerSave by default [] cfg80211 Debugfs Entries [*] cfg80211 Wireless extensions compatibility [*] Wireless extensions-SYSFS fil es {*} Common routines for IEEE802.11 drivers [] L
ib80211 Debugging Messages <*> Generic IEEE 802.11 networking Stack (mac80211) Default Rate Control Algorithm (MINSTREL)---> [] Enable mac80211 Mesh NetworKing (pre-802.11s) support [] Export mac80211 internals in Debugfs [ ] Select mac80211 Debugging features---> Device Drivers---> Generic Driver Options---> (/S Bin/hotplug) path to uevent Helper [] maintain a DEVTMPFS filesystem to mount at /dev [] Select only drivers that don ' t need compile-time external firmware [] prevent fi Rmware from being built-*-userspace firmware loading support [*] Include In-kernel firmware blobs in kernel binary () External firmware-to builds into the BLOBs kernel ry [] Driver Core verbose debug messages [] Managed device ES verbose debug messages [*] Network device Support---> [*] Wireless LAN---> &L T;*> Ralink DriverSupport---> < > Ralink rt2500 (USB) support < > Ralink rt2501/rt73 (USB) support <*> Ralink Rt27xx/rt
28XX/RT30XX (USB) support [] rt2800usb-include support for rt33xx devices [] rt2800usb-include support for RT35XX devices (experimental) [ ] Rt2800usb-include support for RT53XX devices (experimental) [] Rt2800usb-include Suppor T for unknown (USB) devices [*] Ralink debug output
This is the first step of the kernel configuration to achieve the STA mode, which is mainly loaded with the Linux kernel source inside the driver. 2:wifi Tool Transplant
You can now use the Wireless-tools or Wpa_supplicant tools to configure your wireless network. However, be aware that the configuration of the wireless network is global, not specific to the interface. Wpa_supplicant is a good choice, but the downside is that it does not support all drivers. In addition, Wpa_supplicant currently can only connect to those wireless networks that you have configured to Essid. While Wireless-tools supports almost all wireless network adapters and drivers, it cannot connect to those APs that only support WPA.
I have two transplant, but when debugging wpa_supplicant not very good, also did not bother to tune, use Wireless-tools to connect the router without the password.
Wireless Tools for Linux is a Linux command-line toolkit for setting up wireless devices that support Linux Wireless extension.
Download: wireless_tools.29.tar.gz
Wireless-tools
Extract:
#tar zxvf wireless_tools.29.tar.gz
#cd wireless_tools.29
Modify Makefile
Ifndef PREFIX
PREFIX =/home/zhu/my_project/arm/wifi_sta/wifi_lib/wirelesstool/
endif
# # Compiler to use (Modify this for cross compile).
CC =/HOME/ZHU/CODESOURCERY/SOURCERY_CODEBENCH_LITE_FOR_XILINX_GNU_LINUX/BIN/ARM-XILINX-LINUX-GNUEABI-GCC
# # Other tools you need to modify for cross compile (static lib only).
AR =/home/zhu/codesourcery/sourcery_codebench_lite_for_xilinx_gnu_linux/bin/arm-xilinx-linux-gnueabi-ar
Ranlib =/home/zhu/codesourcery/sourcery_codebench_lite_for_xilinx_gnu_linux/bin/arm-xilinx-linux-gnueabi-ranlib
#CC =/usr/local/arm/2.95.3/bin/arm-linux-gcc
#AR =/usr/local/arm/2.95.3/bin/arm-linux-ar
#RANLIB =/ Usr/local/arm/2.95.3/bin/arm-linux-ranlib
Compiling: Make
Copy the generated command tools: Iwlist, Iwconfig, iwpriv,libiw.so.29, and so on to the target board by placing them in the/bin and/lib directory of the Development Board, and assigning permissions chmod 777 iw*
I wrote a script here on arm. SH
Ln-s/mnt/wifi_lib/libiw.so.29/lib/libiw.so.29
ln-s/mnt/wifi_lib/iwconfig/bin/iwconfig
ln-s/mnt/wifi_ Lib/iwspy/bin/iwspy
ln-s/mnt/wifi_lib/iwevent/bin/iwevent
ln-s/mnt/wifi_lib/iwpriv/bin/iwpriv
ln-s /mnt/wifi_lib/iwlist/bin/iwlist
ln-s/mnt/wifi_lib/iwgetid/bin/iwgetid
Because my ramdisk mirror set is relatively small, copy past words space is not enough, made a link. Effect.
Next transplant OpenSSL
Download: openssl-0.9.8e.tar.gz
After decompression modify makefile:
Installtop=/home/zhu/my_project/7z030/software/wifi_sta/wifi_lib/ssl
# Don't edit this manually. Use Configure--openssldir=dir does change this!
Openssldir=/home/zhu/my_project/7z030/software/wifi_sta/wifi_lib/ssl
cc=/home/zhu/codesourcery/sourcery_ CODEBENCH_LITE_FOR_XILINX_GNU_LINUX/BIN/ARM-XILINX-LINUX-GNUEABI-GCC
cflag=-o
depflag=-DOPENSSL_NO_ camellia-dopenssl_no_gmp-dopenssl_no_mdc2-dopenssl_no_rc5-dopenssl_no_rfc3779
PEX_LIBS=
EX_LIBS=
exe_ext=
arflags=
ar=/home/zhu/codesourcery/sourcery_codebench_lite_for_xilinx_gnu_linux/bin/ Arm-xilinx-linux-gnueabi-ar $ (arflags) r
ranlib=/home/zhu/codesourcery/sourcery_codebench_lite_for_xilinx_ Gnu_linux/bin/arm-xilinx-linux-gnueabi-ranlib
perl=/usr/bin/perl
tar= TAR
tarflags=-- No-recursion
Makedepprog=makedepend
Compile:
sudo make & make install and copy libcrypto.a LIBSSL.A to the/lib of the Development Board
Also made a soft link
Ln-s/MNT/WIFI_LIB/LIBSSL.A/LIB/LIBSSL.A
ln-s/mnt/wifi_lib/libcrypto.a/lib/libcrypto.a
Because no wpa_supplicant tools to set up WiFi, here is not expressed, the online compilation of wpa_supplicant article a lot, Baidu reference under the good. 3: Start the WiFi connection router
Here, start the WiFi connection router, this version does not use the driver source code compiled Rt3070.sta and. Ko, with the Linux kernel source code check add Rt2870.bin loading completed.
Rt2870.bin Download Address: Rt2870.bin
You can also go to the kernel site
git clone git://git.kernel.org/pub/scm/linux/kernel/git/dwmw2/linux-firmware.git
Put all the firmware down.
This file should be copied to the/lib/firmware/on the board, or it will be an error.
You can rt2870.bin the downloaded firmware and put it in the newly created firmware directory under the/lib file. Script: No firmware directory in file system/lib, new one.
Mkdir/lib/firmware
Cp/mnt/wifi_lib/rt2870.bin/lib/firmware
This will run the script at power-on startup. Sh, you can ifconfig-a see the wlan0, indicating that the WiFi drive has been transplanted.
Then run the following command on the board, or run it directly in the startup script.
Ifconfig wlan0 up
ifconfig wlan0 192.168.1.13
iwconfig wlan0 Essid tp-link_9d9608
#udhcpc-I wlan0 #下面再说这个命令
My router name is tp-link_9d9608, no password, set 192.168.1.13 is wlan0 IP address, so you can run Telnet 192.168.1.13 On the PC operating system on arm.
This solves the previous way the wired network must be banned when using wireless
Ifconfig eth0 down. This way can be logged at the same time wired and wireless Wifi,ip address is different, my wired and wireless connected to a router, router address 192.168.1.1.
You can also not set the IP address to WiFi, with UDHCPC dynamic random access to IP, this can connect the extranet.
BusyBox is used to make the file system, and there are udhcp tools.
From the BusyBox examples/udhcp/copy good simple.script files to the Development Board/usr/share/udhcpc/(BusyBox inside the default directory file is/usr/share/udhcpc/ Default.script), and rename it to Default.script.
No/share/udhcpc/directory, new one.
Mkdir-p/usr/share/udhcpc/
cp/mnt/wifi_lib/default.script/usr/share/udhcpc/
So run on the board or write the following command in the script, give WiFi a random IP.
Udhcpc-i Wlan0
4: Configure WIFI+HOSTAPD as a hotspot
First of all to the kernel configuration support Softap reference to the next online tutorial on the kernel made configuration changes, but my kernel compiled, can not start, looking for a long time did not find the reason. Because my kernel is to support Softap mode, in the previous blog compiled Softap source can be started, the online tutorial changes too much, I changed the point, and finally succeeded.
[*] Networking Support---> Networking option---> <*> Packet socket <*> Uni
x domain Sockets < > Pf_key sockets [*]
TCP/IP networking [] ip:advanced router [*]
Ip:kernel level autoconfiguration [*] IP:DHCP support [*]
IP:BOOTP support [*] IP:RARP support
< > Ip:tunneling < > Ip:gre demultiplexer [*] Ip:multicast Routi Ng
[*] Networking Support --->
<*> RF switch subsystem support --->//Note To select otherwise, you will get an error using the HOSTAPD command
Configuration error when using the HOSTAPD command if there is no build in RF option
The next step is a tool transplant:
I: here with the above transplant openssl.0.9.8e, here will not continue to introduce, refer to the above compilation.
II: Transplant LIBNL
Download Address: libnl-1.1.tar.gz
# mkdir install
./configure--prefix=/home/zhuzhu/downloads/libnl-1.1/install (Specify Installation path)
# make cc=/home/ zhu/codesourcery/sourcery_codebench_lite_for_xilinx_gnu_linux/bin/arm-xilinx-linux-gnueabi-gcc
Copy the Libnl.so.1 in the Lib folder under install to the Development Board/lib directory.
Add in script:
Ln-s/mnt/wifi_lib/libnl.so.1.1/lib/libnl.so.1
III: Transplant HOSTAPD
Download: hostapd-1.0.tar.gz
After decompression:
# cp defconfig. config
# vim. config
Find this code: remove the annotation.
#CONFIG_DRIVER_NL80211 =y
Also configure other options according to your requirements. Basically, just configuring this line is enough for HOSTAPD to run WPA/WPA2 authentication and encryption.
Modify makefile, add OpenSSL and LIBNL header file and library path respectively, OpenSSL path and the above is not the same, I copied to the following directory.
Cflags + +-i/home/zhu/downloads/libnl-1.1/install/include
cflags + =-i/home/zhu/coding/openssl-0.9.8e/install/ Include
LIBS + +-l/home/zhu/downloads/libnl-1.1/install/lib
ldflags + =-L/HOME/ZHU/DOWNLOADS/LIBNL-1.1/ Install/lib
LIBS + =-l/home/zhu/coding/openssl-0.9.8e/install/lib
Ldflags + =-l/home/zhu/coding/ Openssl-0.9.8e/install/lib
Compile
# Make CC=/HOME/ZHU/CODESOURCERY/SOURCERY_CODEBENCH_LITE_FOR_XILINX_GNU_LINUX/BIN/ARM-XILINX-LINUX-GNUEABI-GCC
# sudo make install
The executable command HOSTAPD and configuration file hostapd.conf will be generated in/usr/local/bin/.
Here do not make install also can, just in this directory to find HOSTAPD files and. conf.
modifying hostapd.conf files
interface=wlan0 driver=nl80211 ssid=chuhang-1 channel=1 hw_mode=g ignore_broadcast_ssid=0 Auth_algs=1 #wpa =3 #wpa_passphrase =11111111 #wpa_key_mgmt =wpa-psk #wpa_pairwise =tkip #rsn_pairwise =ccmp
The above explanations are as follows: (1) SSID: Wireless router launch WiFi name; (2) Hw_mode: Specify 802.11 protocol, including a = IEEE 802.11a, b = IEEE 802.11b, g = IEEE 802.11g; ===== =================================================== Wireless LAN standard IEEE 802.11 protocol *ieee 802.11, 1997, original Standard (2MBIT/S,
Work in 2.4GHz).
*ieee 802.11a,1999 Year, physical layer supplements (54mbit/s, working at 5GHz).
*ieee 802.11b,1999, physical layer supplements (11mbit/s works at 2.4GHz).
*ieee 802.11g,2003 Year, physical layer supplements (54mbit/s, working at 2.4GHz). The most used should be the 802.11n standard, working in the 2.4GHz band, up to 600Mbps (theoretical value) ======================================================== (3) Channel: Set the wireless channel; (4) Interface: Access point device name, note Do not include AP suffix, that is, if the device is called WLAN0AP, fill in Wlan0; (5) Driver: Set wireless drive, I am here nl80211; (6) Auth_ Algs=1 where AUTH_ALGS specifies which authentication algorithm to use, bit-fields is used to make the first representation of open systems authentication (open system authentication, OSA), The second digit indicates shared key authentication (the shared key authentication, SKA). I set the value of Alth_algs here to be 1, which means only OSA; (7) WPA: Specifies the WPA type, which is a bit-field value (bit fields), the first to enable WPA, and the second to enable WPA2. In my configuration, whether set to 1, 2, or 3, you can connect normally (8) WPA_PASSPHRASE:WPA/WPA2 encryption requires a key to be specified, this option is to configure the WPA/WPA2 key. Note that wpa_passphrase requires 8~63 characters. In addition, you can configure WPA_PSK to make the key, but to set a 256-bit 16-digit key is not suitable for our needs; (9) Wpa_paIrwise/rsn_pairwise: If WPA is enabled, you need to specify Wpa_pairwise, or if WPA2 is enabled, you need to specify Rsn_pairwise, or use wpa_pairwise settings.
Start the board, execute
Ln-s/MNT/WIFI_LIB/HOSTAPD/BIN/HOSTAPD
ifconfig wlan0 up
ifconfig wlan0 192.168.0.5
hostapd-b hostapd.conf
#udhcpd/etc/udhcpd.conf #这个下面解释
Execute the hostapd-b hostapd.conf directly on the board or add it to the script; if there is an error in the compilation process, check your LIBNL library and OpenSSL library for a library that you can run on the ARM board if you cross-compile with GCC.
This can be used as a hot spot, with a computer connection to log in completely, but to the PC's IP set to 192.168.0.x, can be.
Using UDHCPD, you don't have to set up your PC's IP address. Similar to the UDHCPC.
Modify the busybox/examples/udhcp/udhcpd.conf and copy it to the Development Board/ETC directory
Because it is the most basic function, so we simply modify the address pool, the default gateway and DNS, the following is my configuration:
# The start and end of the IP lease blocks
start 192.168.0.20
end 192.168.0.254
# The interface that UD HCPD'll use
interface wlan0
opt DNS 192.168.0.1 192.168.0.10
option Subnet 255.255.255.0
opt router 192.168.0.1
#opt wins 192.168.10.10
#option DNS 129.219.13.81 # Appended to above DNS servers for a total of 3
option domain local
option lease 864000< c24/># default:10
option msstaticroutes 10.0.0.0/8 10.127.0.1 # single static route
Option staticroutes 10.0.0.0/8 10.127.0.1, 10.11.12.0/24 10.11.12.1
# arbitrary option in hex form:
option 0x08 01020304 # option 8: "Cookie server IP addr:1.2.3.4"
Run to start the DHCP server
Cp/mnt/wifi_lib/udhcpd.conf/etc
UDHCPD /etc/udhcpd.conf
This allows you to use WiFi as a hotspot to log in directly without setting up IP. Thus using tools such as HOSTAPD+UDHCPD based on the kernel mac80211 Drive framework to achieve the RT3070 wireless network card Softap ...