Skip to content

Install OpenWRT version of Atheros CSI tool

YaxiongXie edited this page Sep 25, 2018 · 18 revisions

Hardware requirements

To install OpenWRT version of Atheros CSI tool, you must have a device that runs OpenWRT system. OpenWRT is an open source project for embedded operating system based on Linux, primarily used on embedded devices to route network traffic (Wikipedia).

Most Wi-Fi routers we use in our daily life can be reflashed with OpenWRT system, although its original system is provided by different vendors. To check whether your hardware is compatible with OpenWRT, please check the TableOfHardware.

One more thing you need to make sure about is that the Wi-Fi NIC cards of your hardware are capable of calculating CSI. That means that your Wi-Fi card must be Atheros 802.11n Wi-Fi card. But not of Atheros 802.11n Wi-Fi NIC supports CSI extraction. According to our experience, AR93xx, AR94xx, and AR95xx are all capable of CSI extraction (AR9331 is not included in the list).

We also confirmed that some versions of Atheros 802.11ac Wi-Fi SoC are also compatible with Atheros CSI tool. We have confirmed that QCA9558 works. We want to note here that: 1, those 802.11ac SoCs must work in 802.11n mode to extract CSI; 2, not all of 802.11ac SoC are compatible with our tool. The rational underneath is that only those 802.11ac SoCs that use ath9k driver in 802.11n mode, is compatible with our tool.

Install OpenWRT

Install from binary firmware

To install OpenWRT on your device, you need the system firmware. The easiest way to obtain the firmware is to download from our GitHub. In this Github folder, you will find many firmware with different names. From this name you can tell which kind of hardware it should be installed on. Just find the one for your own device and download it.

More specifically, there are two important types of firmware under one name:

  • xxxx-squashfs-factory.bin --- it is used when you want to upgrade from the origin system to OpenWRT for the first time.
  • xxxx-squashfs-sysupgrade.bin --- it is used when your device has already been flashed with OpenWRT and you want to update the system running on it.

There are several methods to flash the downloaded firmware to your device. If your device runs the system provided by the vendors, I strongly recommend you to use the web browser. First of all, connect your PC with the router LAN port via ethernet cable. If you are not familiar with the ports configuration of Wi-Fi router, please refer to the following figure. After buiding connection with the router, open your web browser and visit IP "192.168.1.1" (this IP could be differnt with routers. Confirm before the visit). Now, you are actually visitng the WebUI provided by the vendor. Find the "Firmware Upgrade" option and use it to upgrade the firmware. Ports configurations of a typical Wi-Fi router

If your devices has already been flashed with OpenWRT, you can use the WebUI provided by OpenWRT called Luci to upgrade the firmware. Other method is not covered by this tutorial. You can find them here.

Install by compiling the source code

We have released all the source code in Github. You can compile our modified OpenWRT system. After the compilation, you will get the firmware for your device. Follow the steps described above, you can get your device capable of extracting CSI.

Prepare

This section introduces how to compile our modified OpenWRT system. Before stating to build, we need to install some necessary packages by:

$ sudo apt-get update
$ sudo apt-get install sudo apt-get install git python sed wget cvs subversion git-core coreutils unzip texi2html  
texinfo docbook-utils gawk python-pysqlite2 diffstat help2man make gcc g++ build-essential g++ desktop-fileutils     
chrpath flex libncurses5 libncurses5-dev zlib1g-dev pkg-config gettext libxml-simple-perl guile-1.8 cmake libssl-dev 
xsltproc fastjar mercurial pngcrush imagemagick tcl binutils bzip2 perl grep diffutils openjdk-7-jdk zlib1g zlib1g-dbg 
zlib1g-dev zlib-bin zlibc zlib-gst ccache distcc gcc-multilib g++-multilib bin86 libtool

Download and update

Then, we can start to build the OpenWRT system. To begin with, you must operate as a normal user: (NOT ROOT). First of all, use git to download the source code:

$ git clone https://github.com/xieyaxiongfly/Atheros_CSI_tool_OpenWRT_src.git

This create a directory "openwrt", which is the OpenWrt build directory. Please note that in order to avoid the error like “cannot find the file” showing up, you’d better git the source code to /home/$(username) directory, and we will take this path as default for all later commands. Enter folder containing the source code:

$ cd ~/Atheros_CSI_tool_OpenWRT_src

Update feeds of OpenWrt by the following commands:

$ ./scripts/feeds update -a
$ ./scripts/feeds install -a

NOTE If you got error "bash: ./scripts/feeds: Permission denied" when running above commands, add exectuable to all .sh file and feeds by:

$ find . -name "*.sh" -exec chmod +x {} \;
$ chmod +x -R scripts

NOTE If you got error:

fatal: No names found, cannot describe anything.

you can ignore it, since it is caused by github and won't affect the functionality of the c code.

Configure

Now, you are ready to configure OpenWrt. You can use the pseudo-graphical configuration to choose which components to include in your system. Type the following command and enter the configuration mode:

$ make menuconfig

The GUI is as shown in following figure

Menuconfig1

NOTE Do remember to compile the sendData and recvCSI by entering the CSI configuration as following figure shows:

Menuconfig1

Then select the recvCSI and sendData as built-in modules as following figure shows:

Menuconfig1

After selecting these two modules, the recvCSI and sendData is compiled and embedded into the system. You can call this two commands by typing:

$ recvCSI log.txt
$ sendData wlan0 xx:xx:xx:xx:xx:xx 10

NOTE If you want to use the injector mode, please select the lorcon as the built-in module. To select lorcon, please enter the Library section as following figure shows:

Menuconfig1

and then find and select loron:

Menuconfig1

NOTE We also want to note here that, in the default configuration, we select the target profile for all drivers (as shown by the following figure), which means that we will build the firmware for all devices (including your device and all other supported devices).

Menuconfig1

You can accelerate the building process by selecting the target profile as your device. For example, I am using TP-Link 4300, then my configuration will be as follows:

Menuconfig1

Now, we only build the firmware for our own device. Exit and our configuration will be saved into .config file.

Compile

Let's build this system by:

$ make

The first build takes few hours. On the multicore machine, you can use the make's –j option to speed up the building procedure. If you want to see what is going on during the building procedure, or you want to see an error detail, you can use the environment variable V:

$ make V=s

When the compilation is over, you will find the system images in the ~/Atheros_CSI_tool_OpenWRT_src/bin/ar71xx directory. You can get more information about building OpenWrt firmware on this site.

The final step is to follow the aforementioned steps to flash our compiled firmware into your device. After the installation, you can check whether our CSI tool is available on your device by:

$ lsmod | grep 'ar9003_csi' 

This kernel module “ar9003_csi” is crucial for CSI collection because it helps create CSI-detectable packets on the transmitter, and obtain CSI data on the receiver. If you get the message like this:

Menuconfig1

Congratulations! Now you have got the CSI-available version of OpenWrt.