Tuesday, December 22, 2015

Setting a GuruPlug Server Plus up as a WiFi client

Recently I wanted to again stream audio to my GuruPlug Server Plus, only to discover this house has no good way to get a network cable close enough to my stereo to make it work. I figured this wouldn't be a problem, after all, the GuruPlug Server Plus has WiFi. However, the guide to setting up the GuruPlug as a WiFi client is gone, as is the Wisdom of the Ancients of those who got it to work before me. What follows is a guide on getting WiFi client mode working on a GuruPlug Server Plus running Debian Wheezy with a 3.2.68-1 kernel.




Before continuing, it's important to note that while I've found client mode to be stable (with no dropouts to report), I certainly haven't found it performant: I've never seen higher than 15 Mbps down, less than half what I see from other wireless devices on the same network. Any heavy network activity shows 'wlan_main_service' consuming a significant amount of CPU time. I suspect this is related to the software cryptography library our hacked driver will wind up using, but I haven't taken the time to prove it. If marginal network performance (unfortunately not good enough for the task that started this whole mess) is alright with you, lets press on.

I'm assuming we're doing all the compilation right on the GuruPlug as most people probably won't have a cross compiling toolchain setup. As such, you will need the following packages installed on the GuruPlug:

  • 'build-essential' to get GCC and the other necessary tools installed
  • 'firmware-libertas' for the firmware loader binaries as well as the firmware for the wireless module
  • 'linux-headers-kirkwood' to get the kernel headers for the currently installed kernel

Once these things are installed, download the Marvell wireless drivers I've hacked for more recent kernels. The source is available here, or if you're running a 3.2.68-1 kernel, you can download a tarball directly here. My Debian 3.2.68 branch is based off the original sources from here.

With the source downloaded (and extracted as necessary), change to the source directory and perform a 'make', specifying the location of our kernel headers, and nulling out the 'CROSS_COMPILE' option since the Makefile is hardcoded assuming cross compilation, which we are not doing:

# make KERNELDIR=/usr/src/linux-headers-3.2.0-4-kirkwood CROSS_COMPILE=

Once the driver is built, we need to set up loading the firmware for the wireless module. Instead of the binaries provided in the original Marvell tarball, we'll use the 'sd8688_helper.bin' and 'sd8688.bin' provided in the 'firmware-libertas' package installed earlier. The driver assumes these files are in '/lib/firmware/mrvl' (and that the firmware loader is named 'helper_sd.bin') and while the logs may look like it is trying to use them in other locations, I have only managed to get them to work in that exact location. So create '/lib/firmware/mrvl' and copy the firmware loader and the firmware itself:

$ cp /lib/firmware/libertas/sd8688.bin /lib/firmware/mrvl/
$ cp /lib/firmware/libertas/sd8688_helper.bin /lib/firmware/mrvl/helper_sd.bin

With these files in place, we can now install the kernel modules we compiled. Create a '/lib/modules/3.2.0-4-kirkwood/kernel/drivers/net/wireless/mrvl/' folder, and copy the 'mcypt.ko' and 'sd8xxx.ko' files from source directory we did the compile in earlier.

Now, set up the kernel modules so we can activate wireless on boot:

$ depmod -a

Once that is complete, you can ensure the drivers run and properly load the firmware by typing:

$ modprobe mcypt
$ modprobe sd8xxx

Assuming everything is setup correctly, you should see something like the following in dmesg:

mcypt: module license 'Marvell Proprietary' taints kernel.
Disabling lock debugging due to kernel taint
wlan_sdio mmc0:0001:1: firmware: agent loaded mrvl/helper_sd.bin into memory
wlan_sdio mmc0:0001:1: firmware: agent loaded mrvl/sd8688.bin into memory
WLAN FW is active

Now that we've confirmed the driver starts correctly and the firmware is loaded, we can setup the driver to start at boot. First, make sure the other libertas drivers are blacklisted so they don't interfere, if it doesn't already exist, create '/etc/modprobe.d/guruplug-wireless-blacklist.conf', and then ensure it contains the lines:

blacklist libertas_sdio
blacklist libertas
blacklist btmrvl_sdio
blacklist btmrvl

Now, ensure our new wireless driver is loaded at boot, in '/etc/modules' add the following lines:

mcypt
sd8xxx

Finally, reboot and ensure the 'WLAN FW is active' message appears in dmesg after boot is complete. Now, simply setup wireless as described in the Debian wiki.

No comments:

Post a Comment