802.11AC NIC driver compilation on Raspberry PI 2

Source: Internet
Author: User

Recently on the Raspberry Pi 2 toss video, used to do FPV, but found that the 2.4G control will seriously interfere with 2.4G WIFI, in the open control when my desktop + external USB card is frequently dropped. Consider a bit, although the 5.8G frequency band is lower than the 2.4G penetration, but at this stage 5.8G is cleaner, and 5.8G and 2.4G do not have a frequency-doubling relationship, it is not easy to interfere with each other (1.2G of the image will interfere with 2.4G control).

So went to buy a support dual-band 11AC network card, get directly plugged in Pi2, sure enough-lsusb check the next card is also relatively new, with the RTL8811 chip, the official network provides Linux under the driver, and GitHub on the comparison of a bit more new. Look carefully under the driver package found there is no RTL8811 driver, compared to the source makefile on GitHub, it should be used rtl8821a driver.

First experiment on the PC, unzip the driver package, install the script plus execute permissions chmod +x install.sh, and then./install.sh (need to be well equipped with kernel code and compilation environment), at least this driver is available.

To further compile the kernel driver on the Raspberry Pi, the first is to get the Raspberry Pi Linux kernel source code. The Raspberry Pi Linux kernel is customized and the source code is released in Https://github.com/raspberrypi/linux. It is not always possible to find the source version of the original image from GitHub, if the source version and the running image kernel version do not correspond, the compiled kernel module cannot be inserted. In order to reduce unnecessary trouble, it is best to compile a new kernel directly to use, I do directly on the Raspberry Pi kernel compilation, at least 4 hours. In order to save time, often compiled words can be built on the PC cross-compilation environment, here does not expand said.

Prepare the kernel compilation environment and source code, the current image (official Image: 2015-09-24-raspbian-jessie.zip) already contains most of the compilation environment:

sudo apt-get BC #内核编译环境需求: High Precision Computing language git clone https://Github.com/raspberrypi/linux.git # Assuming that the source code in the/home/pi/linuxcd/lib/modulesmkdir 4.1.y #先随便建立一个目录, may need sudo, as appropriate to add, the following no longer prompt
CD 4.1.Y
Ln-s/home/pi/linux Build
Ln-s/home/pi/linux Source

The next step is to get the kernel configuration now running the kernel, which can be automatically compiled based on this ready-made configuration (no need to manually specify the configuration, lifting a heavy workload). Since the latest Raspberry Pi kernel has compiled configs as a module, it needs to be loaded first:

sudo modprobe configs
Cd/home/pi/linux
zcat/proc/config.gz >. config #得到内核配置文件
Make #开始编译内核

After doing make, you need to answer a few questions (because the old kernel configuration does not contain some of the new version of the settings), here I all press M to compile the module, so that you can modprobe load later when needed.

After the start of the compilation will take several hours to wait for the kernel to compile, if using SSH and other network methods to log on to the Raspberry Pi, it is easy to drop the line caused by the compilation stop, preferably directly with the serial port or screen to start make.

On Pi2, if you want to be quick, you can use the MAKE-J4 to compile with 4 cores.

After the kernel is compiled, you need to continue compiling the module, which is a faster step:

 Make Modules sudo  Make Modules_install sudo CP arch/arm/boot/image/boot/kernel-4.1. y.img #将新编译的内核拷贝到/boot

Next you need to configure the Raspberry Pi to boot with the new kernel, edit/boot/config.txt, append a line:

kernel=/boot/kernel-4.1. y.img

After saving the exit, with Sudo reboot restart, after the boot is completed/lib/modules below will be a directory named after the current kernel version, the directory name and Uname-r obtained results are consistent.

Finally, you can start compiling kernel drivers. Because the driver does not provide the Raspberry Pi compilation option, you need to manually modify the makefile, no longer execute the./install.sh script, instead call make manually:

sudo Install  /home/pi #假设驱动包在/home/pi
Unrar x 8811linux.rar
CD 8811linux/driver/rtl8821au_linux_v4.3.14_13455.20150212_btcoex20150128-51 #具体路径根据版本调整
Vim Makefile

Confirm config_rtl8821a = y exists in makefile, then search config_platform_i386_pc to set it to N and add a line Config_platform_arm_rpi = y.

Continue searching for the processing code block for CONFIG_PLATFORM_I386_PC and add the following processing script after it:

+ =-dconfig_little_endianarch:= armcross_compile:=kver  :uname -R) ksrc :=/lib/modules/$ (kver)/buildmoddestdir:=/lib/modules/$ (kver)/kernel/drivers/net/wireless/  endif

Save exit, and now that the preparation is finally complete, you can start compiling the driver:

 Make sudo  Make Install sudo Insmod 8821au.ko

The above is the normal way to compile the Linux kernel module, the same time make can be added-j4 parameters.

There are actually two pits when compiling on the Raspberry Pi. The first is the error when compiling:

-werror=Date-time/macro "__date__" might prevent reproducible builds

To resolve this error, you only need to find extra_cflags in makefile and add a line extra_cflags + =-wno-error=date-time.

Second, my version of the driver refers to the STRNICMP function, but the current Raspberry Pi Linux kernel source (4.1.17) does not define this function, but defines the strncasecmp, the function is the same. The grep driver code finds all strnicmp replaced by STRNCASECMP.

After the Insmod, the network card will light up, you can use DMESG and iwconfig to confirm.

Last modified/etc/network/interfaces add WiFi configuration will be able to surf the Internet:

allow-hotplug wlan0iface wlan0 inet dhcpwpa-ssid <YOUR-ACCESS-POINT-SSID>WPA-PSK < Your-access-point-passkey>

Test the 5.8G network does have a lot less interference, but the wall effect is not. Because the FPV is in the air, there is less barrier, the problem is not very much.

In addition, the network card is a 50mW transmit power, compared to the normal figure came to say that a lot of small, used to do experimental toss is good, the later need to increase the range can be replaced by high-power network card or add two-way WiFi amplifier.

802.11AC NIC driver compilation on Raspberry PI 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.