-
Notifications
You must be signed in to change notification settings - Fork 54
CompatWirelessBuilding
This page describes how to setup and use an open80211s development environment using compat-drivers. It is aimed at newcomers to Linux kernel development. Application installation instructions are for Ubuntu and you may have to adapt them to your distribution.
Note that compat-wireless is now called compat-drivers and it is part of the 'backport' project. The following instructions for building open80211s using compat-drivers are based on information in these pages:
Note that not all of these will be necessary for everybody, but I've found them all useful.
sudo apt-get install build-essential libssl-dev linux-headers-`uname -r` libncurses5-dev quilt guilt exuberant-ctags libnl-dev
We will be following the instructions for generating a "stable release" using the open80211s git repository as our 'linux-next'. Two scripts are provided for getting the necessary source trees for compat-drivers. The scripts work as provided, but you might want to examine them to better understand what they do. In particular, you might want to modify the 'PREFIX' variable in these scripts so that they place the downloaded trees in your desired location. By default, everything is dropped in your $HOME directory. (The following is a direct quote from Getting Required Code.
wget https://github.com/mcgrof/compat/raw/master/bin/get-compat-trees
wget https://github.com/mcgrof/compat/raw/master/bin/get-compat-kernels
chmod 755 get-compat-trees get-compat-kernels
./get-compat-trees
./get-compat-kernels
The get-compat-trees script clones compat, compat-drivers, linux-next, and linux-stable into your $HOME directory (unless you've changed $PREFIX
.)
Note that the latter of these scripts (get-compat-kernels) is really not necessary if you are only building for the kernel version you have installed. It's use is described in the section To build for a different kernel version than what's installed on the build machine below.
cd $PREFIX # $PREFIX being the same directory used by get-compat-trees
git clone git://github.com/cozybit/open80211s.git
Link it to the linux-stable repo.
cd open80211s
git remote add stable ../linux-stable # Assumes open80211s is in the same folder as linux-stable
git fetch stable
git fetch -t stable
git describe # Should return the kernel commit open80211s is derived from.
For a clean build, the compat and compat-drivers git trees have to be set to the kernel rev branch that matches the most recent branch point of the open80211s tree. To determine which version is needed, check the top of the open80211s/Makefile. It will look something like this:
VERSION = 3
PATCHLEVEL = 6
SUBLEVEL = 0
EXTRAVERSION =
NAME = Terrified Chipmunk
This indicates that current version of open80211s is branched off of the 3.6 kernel. We'll need the '3.6.y' branch of the various backport git trees. (To discover what branch names are available in a repository, use git branch -a
).
cd ../compat
git checkout -b linux-3.6.y origin/linux-3.6.y
cd ../linux-stable
git checkout -b linux-3.6.y origin/linux-3.6.y
cd ../devel/compat-drivers
git checkout -b linux-3.6.y origin/linux-3.6.y
cd ../compat-drivers
export GIT_TREE=../../open80211s # Adjust for actual folder location relative to compat-drivers
export GIT_COMPAT_TREE=../../compat # Adjust for actual folder location relative to compat-drivers
./scripts/admin-update.sh
make [-jN] # -jN is optional and specifies the number of cores to use
This will build all of the drivers by default. If you see errors from the admin-update.sh
script, please see the section 'Correcting Patch Errors' below.
Once the make is complete, you can install the driver(s) of interest or create a tarball that can be moved to the target machines for installation.
To install a driver, the driver-select script is used to select the driver to install and then sudo make install
installs the driver. Run ./scripts/driver-select
without arguments to see the list of drivers and driver groups that may be installed.
cd ../devel/compat-drivers
./scripts/driver-select ath # 'ath' is a driver group
sudo make install
This will install the selected driver(s) into the /lib/modules/
uname -r/updates/drivers/net/wireless
directory.
Currently activated drivers may be unloaded using sudo make wlunload
.
- The new driver may be activated using
sudo modprobe driver-name
(e.g.sudo modprobe ath9k_htc
). - Information on which drivers are currently activated may be found with
lsmod | grep 80211
. - To discover what driver file is actually being used, use
modinfo driver-name
(e.g.modinfo ath9k_htc
). The full path to the driver file being used is at the top of the information returned.
If you need to support more than one driver on a machine, it's a little tricky. The driver-select.sh script provided won't let you do it. Here is a work-around:
1. ./scripts/driver-select restore # To ensure no drivers are selected
2. Edit compat-drivers/Makefile to remove the uninstall target from install:
- install: uninstall install-modules install-scripts
+ install: install-modules install-scripts
3. ./scripts/driver-select driver1
4. sudo make install
5. ./scripts/driver-select restore # Restores the tree to the initial state
6. ./scripts/driver-select driver2
7. sudo make install
8. /lib/modules/`uname -r`/updates/drivers/net/wireless # To make sure both drivers have been installed
It is possible that admin-update.sh fails to apply some patches. In this case, run ./scripts/admin-update.sh refresh
, and use the quilt tool to refresh the compat-wireless patches against open80211s. You have several options:
- If possible, correct the patch by examining the reject file(s) and applying the patch by hand. Once the patch has been applied, simply run
quilt refresh
(as specified in the admin-update.sh error message) and then re-run./scripts/admin-update.sh refresh
. Repeat until clean, thenmake
. - If the hunk that fails applies to a driver that you are not interested in, just delete the hunk from the patch.
- If the entire patch applies to drivers that you are not interested in, delete the entire patch.
Then remember to run ./scripts/driver-select <your_driver_of_interest_here>
to avoid running into build errors for other drivers. To discover what drivers and what driver groups can be selected (or what argument to use to select them) run ./scripts/driver-select
with no arguments. To restore a compat-drivers tree to a neutral state with no driver selected, execute ./scripts/driver-select restore
.
To uninstall drivers that have been installed (reverting to the original, kernel-provided drivers):
compat-drivers$ sudo make wlunload
compat-drivers$ sudo make uninstall
compat-drivers$ ls /lib/modules/`uname -r`/updates/drivers/net # To verify that they've been cleaned up
Reboot
It should be possible to build for a different version of the kernel than what you have installed on the build machine. To do this, you'll need to run the git-compat-kernels
script mentioned in the section Download the compat-drivers code (above.) If run as user, this creates a folder in the KSRC_PREFIX
folder (defaults to $HOME, defined in the script) named compat-ksrc
. If run as 'root', the additional kernel headers and modules are put in /usr/src
and /usr/lib/modules
.
You can then build against one of the supported kernel versions by defining the KLIB
Makefile variable, as shown here:
compat-drivers$ make KLIB=/home/pstoaks/sandbox/wl/compat-ksrc/lib/modules/3.5.7-030507-generic -j3
Luis backports regularly compat-drivers master on top of linux-next (Aprox 1 month period). This seems a good option to have the closest to wireless-testing without having to invest a lot effort on backporting our android-linux patches.
We will use a linux-next tag from the latest date compat-drivers supports. This will be considered our android development code base. If any of the patches we need are not there yet, we'll need to back port them on top of the linux-next snapshot. Back porting process should be limited or non-existant.