Beaglebone Wifi notes

Michael Haberler edited this page May 20, 2014 · 15 revisions

make the Beaglebone work with Realtek USB WiFi sticks

I have three Wifi USB sticks, and got them all to work; I just tried one in Access Point mode:

Realtek Wifi USB sticks

The stock kernel drivers are useless, so we need to build our own drivers.

The prerequisite is a kernel package which supports out-of-tree kernel module builds; the kernel on Charles’s latest test image supports this already.

If you get errors like so:

machinekit@beaglebone:~/rtl8188eu$ make
make ARCH=arm CROSS_COMPILE= -C /lib/modules/3.8.13xenomai-bone49/build M=/home/machinekit/rtl8188eu   modules
make: *** /lib/modules/3.8.13xenomai-bone49/build: No such file or directory.  Stop.
make: *** [modules] Error 2

you might have to install the matching kernel headers, in this case:

sudo apt-get install linux-headers-3.8.13xenomai-bone49

The TL-WN725N needs a 8188eu.ko module, whereas the other two need a 8192cu.ko module.

To build and install the 8188eu.ko module, I found this to work:

 linuxcnc@arm:/src$ git clone
 linuxcnc@arm:/src$ cd rtl8188eu/
 linuxcnc@arm:/src/rtl8188eu$ make
 make ARCH=arm CROSS_COMPILE= -C /lib/modules/3.8.13xenomai-bone43/build M=/src/rtl8188eu  modules
 make[1]: Entering directory `/usr/src/linux-headers-3.8.13xenomai-bone43'
  CC [M]  /src/rtl8188eu/core/rtw_ap.o
  ... lots of output ...
  LD [M]  /src/rtl8188eu/8188eu.ko
 make[1]: Leaving directory `/usr/src/linux-headers-3.8.13xenomai-bone43'
 linuxcnc@arm:/src/rtl8188eu$ ls -l 8188eu.ko
 -rw-r--r-- 1 linuxcnc linuxcnc 857799 Apr  1 05:36 8188eu.ko
 linuxcnc@arm:/src/rtl8188eu$ sudo make install
 install -p -D -m 644 8188eu.ko  /lib/modules/3.8.13xenomai-bone43/kernel/drivers/net/wireless/8188eu.ko
/sbin/depmod -a 3.8.13xenomai-bone43
 mkdir -p /lib/firmware/rtlwifi
 cp -n rtl8188eufw.bin /lib/firmware/rtlwifi/.

For the 8192cu.ko module, I followed instructions from: and adapted the Makefile for a native build, so use my fork instead:

 linuxcnc@arm:/src$ git clone git://
 linuxcnc@arm:/src$ cd rtl8192cu_beaglebone/
 linuxcnc@arm:/src/rtl8192cu_beaglebone$ make
 make ARCH=arm CROSS_COMPILE= -C /lib/modules/3.8.13xenomai-bone43/build M=/src/rtl8192cu_beaglebone  modules
  ... lots of output ...
  LD [M]  /src/rtl8192cu_beaglebone/8192cu.ko
 make[1]: Leaving directory `/usr/src/linux-headers-3.8.13xenomai-bone43'
 linuxcnc@arm:/src/rtl8192cu_beaglebone$ ls -l 8192cu.ko
 -rw-r--r-- 1 linuxcnc linuxcnc 554550 Apr  1 05:48 8192cu.ko
 linuxcnc@arm:/src/rtl8192cu_beaglebone$ sudo make install
 install -p -m 644 8192cu.ko  /lib/modules/3.8.13xenomai-bone43/kernel/drivers/net/wireless/
/sbin/depmod -a 3.8.13xenomai-bone43

Next, blacklist the native drivers:

$ cat /etc/modprobe.d/blacklist.conf
# Blacklist native RealTek 8188CUs drivers
blacklist rtl8192cu
blacklist rtl8192c_common
blacklist rtlwifi

Reboot with wifi stick plugged in, depending on the wifi stick either driver should be now visible (this is with the TL-WN725N inserted):

linuxcnc@arm:~$ lsmod
Module                  Size  Used by
cpufreq_userspace       2002  0
g_multi                47408  0
libcomposite           13888  1 g_multi
nfsd                  187593  2
8188eu                663614  0   <------------------
evdev                   6814  1
linuxcnc@arm:~$ lsusb
Bus 001 Device 002: ID 0bda:8179 Realtek Semiconductor Corp.  <------------------
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

To enable the BB to connect via wifi to an existing access point, go from here:

/etc/network/interfaces :
# WiFi Example
auto wlan0
iface wlan0 inet dhcp
    wpa-ssid "essid"
    wpa-psk  "password"
run 'ifdown wlan0', then 'ifup wlan0'. With some luck the BB connects and gets an IP address for wlan0.

make the BB work with Realtek USB Wifi sticks as Access Point

We’ll configure interface wlan0 to 'NAT through eth0'. This means if the beaglebone has Internet connectivity through eth0, so will have the WiFi clients. The config files below will configure your AP to use:

SSID machinekit
password beaglebone
encryption WPA2 PSK

The setup requires 'hostapd', however the hostapd binary from debian dont work and segfaults. But to get the config files, install the hostapd package nevertheless:

$ sudo apt-get install hostapd

That leaves a binary /usr/sbin/hostapd which is broken. Remove it:

$ sudo rm -f /usr/sbin/hostapd

Now we build a working hostapd. Fortunately there is one in the repo which we just built the driver from, so:

On the BB, do this:

linuxcnc@arm:/src$ cd rtl8188eu/hostapd-0.8/hostapd
linuxcnc@arm:rtl8188eu/hostapd-0.8/hostapd$ cp defconfig .config
linuxcnc@arm:rtl8188eu/hostapd-0.8/hostapd$ make
 CC  config_file.c
 ... lots of output ...
 LD  hostapd_cli
linuxcnc@arm:/src/rtl8188eu/hostapd-0.8/hostapd$ sudo make install
mkdir -p /usr/local/bin
  for i in hostapd hostapd_cli; do cp -f $i /usr/local/bin/$i; done

This will install our new hostapd in /usr/local/bin/hostapd.

Adapt /etc/init.d/hostapd to refer to the proper path - change DAEMON_SBIN to read:


next, enable hostapd on startup, so edit /etc/default/hostapd to read:

linuxcnc@arm:~/src$ cat /etc/default/hostapd


create a /etc/hostapd-bone.conf like so:

# Wifi device
# netlink driver not present/needed
# AP-Name
# frequency
# up to 54Mbit, also 802.11 and 802.11b
# auth mode "Open System Authentication"
# accept only WPA2
# Pre-Shared-Key (PSK) , cleartext
# <my-super-secret-password, 8chars min>

Now we need DHCP service on wlan0, so we edit /etc/udhcpd.conf to read:

# see
interface  wlan0
max_leases 100
opt dns
opt router
opt subnet
opt domain	local
opt lease	864000		# 10 days of seconds

We use an 'exotic' 172.x subnet to avoid collisions with first-level NAT in front of eth0. This makes it more likely Internet connectivity works with Wifi clients if eth0 already has an Internet connection using NAT.

We need two more shell scripts to configure the NAT:

/etc/init-wlan-ap is for starting the NAT and reads:

# Enable NAT
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
iptables --table nat --append POSTROUTING --out-interface $2 -j MASQUERADE
iptables --append FORWARD --in-interface $1 -j ACCEPT
sysctl -w net.ipv4.ip_forward=1
service udhcpd restart

The other file /etc/stop-wlan-ap is for stopping the NAT and reads:

iptables --flush
iptables --delete-chain
service udhcpd stop

make these files executable:

chmod +x /etc/init-wlan-ap /etc/stop-wlan-ap

Finally we need to enable wlan0 in /etc/network/interfaces, so add:

auto wlan0
iface wlan0 inet static
up /etc/init-wlan-ap wlan0 eth0 up
up service hostapd restart
down /etc/stop-wlan-ap
down service hostapd stop

that’s all! just 237 or so easy steps! Reboot and you should be in business - the AP should now be visible and a client connected should get an IP address in the 172.29.0.x range.

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.