Enable 802.11mc FTM on Intel 8260

HappyZ edited this page Aug 7, 2018 · 12 revisions

0x0. Heads up!

Quoted from [1]:

While we advertise support for Wi-Fi Location* and Wi-Fi Aware* on 8260, we can't commmit on accurate results for those features. NAN isn't considered stable yet and may or may not work depending on the firmware version. FTM can work on 8260 only and requires special calibrations so that an off the shelf 8260 won't be able to provide accurate measurements.

Also note, even though 802.11mc supports bi-directional requests, i.e. AP(s) can send FTM request to client(s) and vice versa, this solution only allows client(s) to send requests to AP(s).

To proceed, keep system updated with sudo apt-install upgrade. And this doc assumes Ubuntu 16.04 LTS with Intel 8260 chip on Dell XPS 13.

The friend of mine Mohamed Ibrahim has published their official installation page for enabling FTM: WiFi FTM Linux Tool. And they have published a verification paper on its accuracy. Please go there and have a look!

0x1. iwlwifi Installation

First need to switch to release/LinuxCore30.


Reboot, enter BIOS settings, and disable Secure Boot. Notice that this will reduce security of your system.

### Download firmware for Intel 8260 chip
$ cd /lib/firmware
$ sudo wget https://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/linux-firmware.git/tree/iwlwifi-8000C-31.ucode
### disable Ubuntu 16.04 kernel 4.4+ security check, this will reduce security of your system
$ sudo apt install mokutil
$ sudo mokutil --disable-validation
$ reboot


$ git clone https://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/backport-iwlwifi.git -b release/LinuxCore30
$ cd backport-iwlwifi
$ make defconfig-iwlwifi-public
$ sed -i 's/CPTCFG_IWLMVM_VENDOR_CMDS=y/# CPTCFG_IWLMVM_VENDOR_CMDS is not set/' .config

Before make, we need to change the code so that FTM responder mode is enabled (thanks to Mohamed Ibrahim). Locate nl80211_start_ap function in net/wireless/nl80211.c, and make the following change:

 static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)

+	nl80211_start_ftm_responder(skb, info);
 	return err;

Also move the entire static int nl80211_start_ftm_responder(struct sk_buff *skb, struct genl_info *info) function above nl80211_start_ap.

And then, in drivers/net/wireless/intel/iwlwifi/mvm/constants.h, change #define IWL_MVM_TOF_IS_RESPONDER to 1.

We are now ready to make & install:

$ make -j4
$ sudo make install

If error popped up saying fopen:No such file or directory: bss_file.c:175 and sign-file: certs/signing_key.pem: No such file or directory (for linux kernel 4.4+), it should be fine.. ..when you reboot after installation and see:

$ cat /var/log/syslog | grep iwlwifi
... iwlwifi-stack-public:release/LinuxCore30:...

Notice that this is not a permanent change. If you install packages (and thus restore the kernel), it will revert back to the original one and you have to redo this step.

0x2. HostAPd Installation

Note: do not install via sudo apt install hostapd unless the binary is of version 2.6+.


$ sudo apt install libssl-dev libnl-3-dev libnl-genl-3-dev

Compile & install HostAPd

$ wget https://w1.fi/releases/hostapd-2.6.tar.gz
$ tar xzf hostapd-2.6.tar.gz
$ cd hostapd-2.6/hostapd/
$ cp defconfig .config
$ sed -i 's/#CONFIG_LIBNL32=y/CONFIG_LIBNL32=y/' .config
$ make
$ sudo make install

If you have installed other version of hostapd before, make sure you are using hostapd v2.6.

0x3. iw Re-Compilation


$ sudo apt install libnl-3-dev libnl-genl-3-dev

Compile & Install

Thanks to Johannes Berg to provide the initial patch. I have committed it to the master branch (the develop branch also has iw folder which is the same but with more information).

$ git clone https://github.com/HappyZ/iw_intel8260_localization.git -b master
$ cd iw_intel8260_localization
$ make
$ sudo make install

To validate, run which iw to see where is current path for iw and run iw --version to see if it is iw version 4.14. Further, you can check to see if iw --help | grep FTM gives you something like Send an FTM request.... If so, installation is successful.

0x4. Get Result!

AP side

Simply enable HostAPd.

Edit /etc/init.d/hostapd

sed -i 's/DAEMON_SBIN=/DAEMON_SBIN="\/usr\/local\/bin\/hostapd"\n# DAEMON_SBIN=/' /etc/init.d/hostapd
sed -i 's/DAEMON_CONF=/DAEMON_CONF="\/etc\/hostapd\/hostapd.conf"\n# DAEMON_CONF=/' /etc/init.d/hostapd

Edit /etc/network/if-pre-up.d/hostapd:

sed -i 's/HOSTAPD_BIN=/HOSTAPD_BIN="\/usr\/local\/bin\/hostapd"\n# HOSTAPD_BIN=/' /etc/network/if-pre-up.d/hostapd

Edit /etc/default/hostapd:

sed -i 's/DAEMON_CONF=/DAEMON_CONF="\/etc\/hostapd\/hostapd.conf"\n# DAEMON_CONF=/' /etc/default/hostapd

Edit /etc/network/interfaces:

auto lo
iface lo inet loopback
auto wlp58s0
iface wlp58s0 inet static
  /usr/local/bin/hostapd /etc/hostapd/hostapd.conf

Edit /etc/hostapd/hostapd.conf

bssid=<mac address>

Client side

Note: you do not need to associate/connect to AP to get the measurement.

First create a file config_entry contains the following entry:

<mac_address> bw=20 cf=2462 retries=5 asap

where bw is the bandwidth, cf is the center frequency of AP's channel.

Then request FTM measurement via

sudo iw <wlan_interface> measurement ftm_request config_entry

Result example

You should see something like the following:

Success to put for target 34:f6:4b:5e:69:1f.
phy #0: FTM result! Status: 0 
Target: 34:f6:4b:5e:69:1f, status: 0, rtt: -33429 psec, distance: -501 cm

If you see anything other than status: 0, it means it is not succeeded.


[1] https://wireless.wiki.kernel.org/en/users/drivers/iwlwifi

[2] https://wireless.wiki.kernel.org/en/users/drivers/iwlwifi/core_release

[3] https://bugzilla.kernel.org/show_bug.cgi?id=197187

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.