PogoPlayer – WiFi

Getting USB WiFi working was the next hurdle. I bought the Airlink Fully compatible Wireless N 150 Ultra Mini-USB Adapter (AWLL5099), which has the Realtek 8188CUS chipset. I would not recommend this WiFi dongle for others. The drivers were hard to setup and had a memory leak (more on that later). I ended up downloading and installing the driver from the RealTek website. Follow the installation instructions in the zip file. One disconcerting thing I noted on the download page is that the supported kernel versions were “Linux Kernel 2.6.18~2.6.38 and Kernel 3.0.8” (it might have worked on the VAMP image after-all); as noted above I’m running a 3.2.0 kernel.

Some friends have since recommended Atheros chipsets as being more Linux-friendly. I hope you have better luck than I did, but I’m not complaining too loudly since the one I have does work in the end.

At first I could not connect to my WPA2-encrypted hotspot. I installed WPASupplicant and found the following configurations to work:

/etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
ap_scan=1

network={
  ssid="YOUR-WiFi-SSID"
  key_mgmt=WPA-PSK
  psk=HEX-ENCODED-PASSPHRASE
  priority=5
}

/etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet dhcp

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
address 192.168.1.13
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

As you can see I have configured a static IP address, which is fine for this application. For some reason DHCP would not work. My preference was to have my router’s DHCP server assign the IP address rather than to have it hard-coded in the PogoPlug, but obviously it didn’t work out that way.

I’m not sure if this next thing is a Linux configuration issue or an issue with my specific WiFi adaptor, but it does not seem to work when the wired NIC is connected and then disconnected. I did not take the time to debug this completely since I am primarily interested in using this device with WiFi only. I was happy and moved on once I realized that I could connect to SSH over WiFi if I booted the device with the wired NIC disconnected. It is important to wait long enough for WiFi and SSH to come up. I can ping the PogoPlug about a minute after applying power, but cannot connect to SSH for more than two minutes. This is not a big deal since it hardly ever needs to be rebooted, although a faster boot would be nice.

The final WiFi issue was not solved until much later when I had everything else up and running. I noticed that the PogoPlug would steadily run out of RAM over the course of a few days. At first I had no idea what it was. The usual suspects were not guilty: top showed no processes consuming huge amounts of memory, there were no tmpfs file systems growing without bound, but there was constantly less and less free memory. After about three or four days the OS would run out of RAM and freeze up. The only remedy at that point was to pull the power and reboot. I started digging into /proc/meminfo and slabtop since the symptoms were pointing at a kernel memory leak. I observed that “SUnreclaim” in /proc/meminfo was steadily increasing. As I understand it, this is unreclaimable memory consumed by the kernel. slabtop showed many objects named “size-512” consuming lots of memory after a day or two. I had also noticed a lot of messages like this in dmesg:

[190125.169528] delay: estimated 134, actual 1
[190127.151059] rtw_set_ps_mode(): Enter 802.11 power save mode...
[190127.157037] delay: estimated 90, actual 310
[190127.157073] rtl8192c_set_FwPwrMode_cmd(): Mode = 1, SmartPS = 2
[190127.163118] delay: estimated 90, actual 1
[190127.168515] delay: estimated 134, actual 1
[190129.151055] rtw_set_ps_mode(): Busy Traffic , Leave 802.11 power save..
[190129.157815] delay: estimated 46, actual 310
[190129.158029] rtl8192c_set_FwPwrMode_cmd(): Mode = 0, SmartPS = 0
[190129.167397] delay: estimated 222, actual 1
[190131.150923] rtw_set_ps_mode(): Enter 802.11 power save mode...

Knowing that the WiFi driver did not explicitly support my kernel version, on a whim I decided to see if I could disable the power save mode. Maybe that was causing the memory leak? It was certainly generating a lot of dmesg churn, and it was happening constantly regardless of whether the machine was in use or sitting idle, which matched the pattern of decreasing free memory. A quick Google turned up RTL8192cu WiFi disable power save on forum.doozan.com again (that site has been a lifeline for this project). So I added a file:

/etc/modprobe.d/8192cu.conf

options 8192cu rtw_power_mgnt=0

Reboot. A lot less dmesg output and no more memory leak. Excellent!

Other posts in this series:

  1. Introduction
  2. Debian Wheezy on the PogoPlug
  3. WiFi
  4. ALSA, UCA-202, squeezelite
  5. Source switch and volume controller app for mobile device (or any web browser)
  6. PogoPlayer – Known Issues and Annoyances

Leave a Reply