Solved - I now have reliable WiFi on the Bone

I have been trying for over a month to get reliable WiFi working on the original BeagleBone and now on the new BeagleBone Black. I kept seeing weird behavior, such as randomly dropped or stuttering connections, and different symptoms depending upon whether the WiFi dongle was plugged directly into Bone, into an extension cable, or into a powered hub. There’s a lot of online frustration about this, some of which I contributed to. It was really unclear to me if the problem was hardware or software related, or some combination of the two.

Long story short, I believe that most of my problems stemmed from attempting to use dongles based upon the rtl8192cu chipset (I tried several different ones). These are very common, widely available, and appear at first glance to have the best software support on the Bone, at least in the standard Angstrom distribution. Most of the online tutorials about how to get WiFi running on the Bone are using these dongles. I don’t know if or why the people who wrote these are getting reliable WiFi - I sure didn’t.

Robert Nelson suggested that I try using a dongle using an Atheros chipset. I ordered a NetGear WNA1100 but soon discovered that it won’t run in the Angstrom distribution, which by default doesn’t provide the ath9k_htc driver and associated firmware. This was really disappointing to me, since I had already made quite an investment in learning all about Angstrom. I was able to bitbake a version of the distribution that included the driver, but was unable to build or find a version of the firmware that would work in Angstrom. I have since given up and switched to Ubuntu, which includes support for this dongle natively. My WiFi is now rock solid with this adapter.

A plea to the makers: please bundle the ath9k_htc driver and associated firmware with the standard Angstrom distribution.

tl;dr: Install Ubuntu on the Bone (I used the latest raring image), buy this dongle, follow these directions to get reliable WiFi.

Thanks to all who attempted to help me - hopefully this post will help others.

For what it’s worth, here are steps I documented for reliably using an ‘ath9k_htc’ usb wifi dongle with Angstrom (systemd-image):

Building and Installing ‘compat-wireless’ Drivers (on the Beaglebone itself):

  1. Prepare local environment for building drivers. Following instructions here: ‘http://nomel.org/post/30357133735/beaglebone-tutorial-how-to-compile-kernel-module’):

a. opkg install task-native-sdk

b. opkg install kernel-headers

c. opkg install kernel-dev

d. ‘ln -s /usr/src/kernel /lib/modules/3.2.30/build’ (Replace 3.2.30 with appropriate kernel version… Make sure the headers downloaded to ‘/usr/src/linux-3.2….’ match the actual kernel version ‘uname -r’, otherwise the modules built in this way will not work)

e. cd /usr/src/kernel

f. make scripts

  1. Download and build the ‘compat-wireless’ drivers. Following instructions here: (http://wireless.kernel.org/en/users/Download/stable/#compat-wireless_3.6_stable_releases):

a. mkdir ~/compatwireless

b. cd ~/compatwireless

c. wget http://www.orbit-lab.org/kernel/compat-wireless-3-stable/v3.6/compat-wireless-3.6.2-1-snp.tar.bz2

d. tar -xzvf compat-wireless-3.6.2-1-snp.tar.bz2

e. cd compat-wireless-3.6.2-1-snp

f. ./scripts/driver-select ath9k_htc

g. make (this step is redundant if the following line is run…)

h. make install-modules (Automatically copies the modules to the correct place)

i. Run ‘depmod -a’ to update the ‘known module dependencies’ list with the ones just made/copied.

  1. Alternately (much faster/better), cross-compile the wireless drivers on a host machine and transfer them across:

a. [From the host machine e.g. Ubuntu…]:

b. mkdir ~/compatwireless

c. cd ~/compatwireless

d. wget http://www.orbit-lab.org/kernel/compat-wireless-3-stable/v3.6/compat-wireless-3.6.2-1-snp.tar.bz2

e. tar -xzvf compat-wireless-3.6.2-1-snp.tar.bz2

f. cd compat-wireless-3.6.2-1-snp

g. ./scripts/driver-select ath9k_htc

h. Build with cross-compiler (using the kernel source git repo path as KLIB and KLIB_BUILD):

i. make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- KLIB=~/angstrom/setup-scripts/build/tmp-angstrom_v2012_05-eglibc/work/beaglebone-angstrom-linux-gnueabi/linux-ti33x-psp-3.2.23-r14i+gitr720e07b4c1f687b61b147b31c698cb6816d72f01/git KLIB_BUILD=~/angstrom/setup-scripts/build/tmp-angstrom_v2012_05-eglibc/work/beaglebone-angstrom-linux-gnueabi/linux-ti33x-psp-3.2.23-r14i+gitr720e07b4c1f687b61b147b31c698cb6816d72f01/git [Note: Change paths to suit…]

j. Package up the module files and move to the target (Borrowing steps from here: http://wiki.chumby.com/index.php/Compat-wireless_driver_on_chumby#Cross-compile_compat-wireless_driver):

k. find ./ | grep ko$ | xargs tar cvjf wireless-compat_modules.tar.bz2

l. [On the beaglebone]:

m. cd /lib/modules/3.2.23

n. mv updates old-updates (only if there is an old version of the wifi drivers present…)

o. mkdir updates

p. cd updates

q. Copy from host machine:

r. scp bone@10.192.0.95:/home/bone/compatwireless/compat-wireless-3.6.2-1-snp/wireless-compat_modules.tar.bz2 ./

s. tar -xvf wireless-compat_modules.tar.bz2

t. Run ‘depmod -a’ to update the ‘known module dependencies’ list with the ones just made/copied.

  1. Download and copy the two firmware files ‘htc_7010.fw’ and ‘htc_9271.fw’ from http://linuxwireless.org/download/htc_fw/1.3/ to ‘/lib/firmware’:

a. cd /lib

b. mkdir firmware

c. cd firmware

d. wget http://linuxwireless.org/download/htc_fw/1.3/htc_7010.fw

e. wget http://linuxwireless.org/download/htc_fw/1.3/htc_9271.fw

  1. Make sure to check the file ‘/var/lib/connman/settings’ and ensure that line after ‘[WiFi]’ reads ‘Enabled=true’

  2. Reboot.

  3. Plug in the usb-wireless dongle. Check ‘dmesg | tail’ to see that it is recognized and that the firmware files are properly transferred. Check ‘lsmod’ to see that all the ‘ath…’ modules have installed correctly.

  4. Follow Steps here to verify wifi works (in client mode…): (http://support.criticallink.com/redmine/projects/arm9-platforms/wiki/USB_WiFi_Configuration?version=6)

a. opkg install wpa-supplicant

b. opkg install wireless-tools

c. opkg install kernel-module-rfkill (annoyingly, needs to update the kernel image – not required for kernel build versions 3.2.30 onwards)

d. In the following files:

/usr/share/dbus-1/system-services/fi.epitest.hostap.WPASupplicant.service

/usr/share/dbus-1/system-services/fi.w1.wpa_supplicant1.service

Change the “Exec=” line to be “Exec=/usr/sbin/wpa_supplicant -u -s -O /var/run/wpa_supplicant” in both files. (initially it is the same up to ’–u’)

e. wpa_supplicant –B –Dwext –iwlan0 –c/etc/wpa_supplicant.conf (runs wpa_supplicant in thebackground)

f. call ‘wpa_cli’, then call ‘status’ to see how the connection is going.

g. Sometimes it can take a long time to connect – perhaps removing connman service helps.

i. What definite helps is setting ‘ap_scan=…’ to ‘ap_scan=1’ in the ‘wpa_supplicant.conf’ configuration file.

Thanks for your post. It seemed specific to kernel version 3.2, but the fact that you had it running in Angstrom made me try again. I downloaded the htc_9271 firmware from linuxwireless.org and now the dongle is working in kernel version 3.8.11. It wasn’t working for me in earlier kernel versions (rfkill kept preventing the driver from loading), but it’s now working fine in Angstrom. I’m not sure whether the new firmware or the updated kernel is responsible for it working now.

FWIW, I went back and tried dongles using both the rtl8192cu and RALink chipsets. They continue to be unreliable for me, in both Angstrom and Ubuntu.

I’ve had some better luck with the RALink chipsets now. My problem was that the dongle power save was kicking in, making it dodgy to use the BeagleBone as a server. I fixed this by turning off power save as follows:

cat > /etc/udev/rules.d/wifi_power_save.rules <<-EOF
ACTION==“add”, SUBSYSTEM==“net”, KERNEL==“wlan*” RUN+="/usr/sbin/iw dev %k set power_save off"
EOF

This command should turn off the power save features of any type of dongle.

Hi Carl,

I’ve just been revisiting ath9k_htc wifi on the beaglebone, and was wondering what procedure you followed to bitbake the drivers into the angstrom distribution.

Did you just bitbake menuconfig and then set all of the ath9k options to build as modules, then rebuild the entire systemd image? Or did you just rebuild the modules - if so, how is this done and where do they end up?

Regards,
Andrew Glen.

Hi Andrew,

Sorry for the late reply. FWIW, I see that Koen has enabled the ath9k_htc driver by default in one of his latest commits, so at some point soon this will become part of the standard Angstrom distribution. I assume the required firmware will also be included.

In case you don’t have this working yet, here are the notes I took about the process:

To create a customized kernel, I fetched and built everything on a Ubuntu 12 host, running

as a Parallels 8.0 VM on a Mac running Mountain Lion. I’m sure any other machine running

the latest Ubuntu would work as well.

First make sure you have the following requisite packages installed

You may need others, or you may already have some of these.

In any case, the bitbake build scripts listed below will tell you if anything is missing.

Install any missing packages (I used the Ubuntu Software Center), and then rerun the command.

sudo apt-get install gettext chrpath subversion gawk texinfo g++ git diffstat

Start by downloading the latest build scripts into a suitable working directory:

cd ~/Devel/BeagleBone/kernel
git clone git://github.com/Angstrom-distribution/setup-scripts.git

Modify the ./setup-scripts/conf/local.conf file and comment out the following line:

INHERIT += “rm_work”

Configure and update with the following commands:

cd ~/Devel/BeagleBone/kernel/setup-scripts

MACHINE=beaglebone ./oebb.sh update

Run menuconfig to enable the ATH9K_HTC driver:

MACHINE=beaglebone ./oebb.sh bitbake virtual/kernel -c menuconfig

This may take a long time to complete the first time, as it has to build the toolchain first.

In the menu that eventually pops up, select the following items to enable the driver:

Device Drivers
→ Network device support
→ -> Wireless LAN
→ -> → Atheros Wireless Cards
→ -> → -> Atheros HTC based wireless card support (type ‘M’)

Alternatively, edit the following default .config file to enable the ATH9K_HTC driver:

sources/meta-beagleboard/common-bsp/recipes-kernel/linux/linux-mainline-3.8/beaglebone/defconfig

You’ll need to change this line:

CONFIG_ATH9K_HTC is not set

to this:
CONFIG_ATH9K_HTC=m

Build the kernel image with the following commands:

. ~/.oe/environment-angstromv2012.12
bitbake virtual/kernel

Copy the file ath9k_htc.ko into /lib/modules//kernel/drivers/net/wireless/ath/ath9k

I didn’t write down where to find this file in the build directories, but I think it might be somewhere in ./setup-scripts/build/tmp-angstrom_v2012_12-eglibc/work/beaglebone-angstrom-linux-gnueabi/linux-mainline-/image/. I used the linux ‘find’ command to locate it.

You can download the required firmware from linuxwireless.org: http://wireless.kernel.org/download/htc_fw/1.3/htc_9271.fw

Copy this file to /lib/firmware on the BeagleBone

Thanks for that Carl. Much appreciated.

Can anyone Carl, Andrew verify these dongles to work with BBB > http://www.adafruit.com/products/814 and http://www.adafruit.com/products/1012

The ones that we have tested an work are listed on the support Wiki. http://xircuitco.com/support/BeagleBoneBlack.

Gerald

Nishant,
I have the adafruit mini (your 814 link) which is a Realtek rtl8188cus chipset. Generally people have not found them to work very reliably. Mine doesn't work well enough for me to use it. Some have had good luck with vendor drivers, but YMMV.

FYI here's the direct link to circuitco tested adapters:
http://circuitco.com/support/index.php?title=BeagleBoneBlack#WIFI_Adapters

One other thing, you definitely need additional power. Either a barrel jack supply or a powered hub is required.
-Dale

Thats a rather small list . … and is at least one of thsoe an Atheros chipset ?

I this evening ordered a wna 1100 netgear wifi dongle that csrl suggested on the very first link to be working fine on ubuntu and also even on angstrom.

Thanks & Regards,
Nishant

Yes, I have since switched back to Angstrom now that I figured out how to build the ATH9K_HTC driver module and download the appropriate firmware. I have also had good reliability on Angstrom with the Tenda W311M dongle, which uses the standard RALink driver. It is less expensive and has a smaller footprint, although the range isn’t as good as the WNA1100. I never got any of the many Realtek dongles I tried to work acceptably on either the BB or BBB.

Good to know Carl, thanks :slight_smile:

Hey Carl,

Your WNA1100 works well in Angstrom latest image for BBBlack? Following Andrew’s steps?

Hi All,

We have been heavily using the TP-Link TL-WN722N (ath9k_htc) in both client and access-point modes (using wpa_supplicant and hostapd) and found it to be very reliable - and with a good range - although it is extremely important to have an external 5V power supply connected - without it (or with it connected intermittently) you’ll find the device ‘randomly’ browns out as the usb supply is overwhelmed.

Regarding my set of steps to bring up the drivers, it has since become clearer that building the drivers into the kernel as modules is far simpler and obviously less prone to tool-chain dependency problems faced when building it separately.

I would still highly recommend using wpa_supplicant (as opposed to connman or any other network manager) to manage client-side connections - it just seems simpler and more powerful; but whatever works…

I now have reliable Wifi on my BBB (A5A) with an Edimax dongle (rtl8192cu). The problem is not the driver/board (in my case), but it was apparently ages old versions of connman and wpa_supplicant. I’m using the firmware binary downloaded from debian repo and then compiled the latest connman (1.16 iirc) and latest wpa_supplicant (2.0) from sources right on the BBB itself and did a make install.

Presto, reliable wifi connection with sane (~1ms) ping to router.

That’s fantastic – does anyone with more OE experience than me know how to update the recipes for 2012.12 so I can rebuild an image with the newer connman and wpa_supplicant?

When I try to ./compile connman 1.16 I get error “configure: error: D-Bus >= 1.4 is required”. I can’t figure out how to update D-Bus. (I am using Angstrom Production Image 2013.09.04) Any suggestions? Finally, can you describe the type of problems you had before upgrading connman and wpa_supplicant? (I have very slow/intermittent wifi access unless I hold the BBB in my hands a certain way…I am hoping what you suggest will fix this.) THANKS!

Hey Andrew, I’m not understanding this part >> d. ‘ln -s /usr/src/kernel /lib/modules/3.2.30/build’ (Replace 3.2.30 with appropriate kernel version… Make sure the headers downloaded to ‘/usr/src/linux-3.2….’ match the actual kernel version ‘uname -r’, otherwise the modules built in this way will not work)

to the extent that I was able to understand is that i have to run this >> -s /usr/src/kernel /lib/modules/3.2.30/build with 3.8.13 as my kernel is but this statement didn’t ran because the terminal couldn’t fine “-s” and I’m stuck now at this line >> h. make install-modules (Automatically copies the modules to the correct place)