Realtek r8712u or 8712udriver for 802.11n wireless adapter

I am trying to get an ASUS USB-N10 wireless adapter to work with the
beaglebone. I have now spent a week attempting to get a working
driver for it.

Looking at various posts on various forums, it seems that the r8712u
driver needs a firmware file rtl8712u.bin that is missing from the
Angstrom distribution. I was able to locate the firmware and it
sometimes sort of works, but never fully. By "sometimes sort of" I
mean that sometimes it will load the firmware and I can bring the
wlan0 device up and connect to the access point with wpa_supplicant,
but dhcp fails. Other times there is an error when it tries to load
the firmware:

2011-12-07T07:41:38.525312+00:00 beaglebone kernel: [ 3046.570315] usb
1-1: new high speed USB device number 2 using musb-hdrc
2011-12-07T07:41:38.665437+00:00 beaglebone kernel: [ 3046.712549] usb
1-1: New USB device found, idVendor=0b05, idProduct=1786
2011-12-07T07:41:38.665538+00:00 beaglebone kernel: [ 3046.712571] usb
1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
2011-12-07T07:41:38.665559+00:00 beaglebone kernel: [ 3046.712585] usb
1-1: Product: ASUS EZ N Network Adapter
2011-12-07T07:41:38.665578+00:00 beaglebone kernel: [ 3046.712596] usb
1-1: Manufacturer: Manufacturer Realtek
2011-12-07T07:41:38.665596+00:00 beaglebone kernel: [ 3046.712607] usb
1-1: SerialNumber: 00e04c000001
2011-12-07T07:41:38.706550+00:00 beaglebone kernel: [ 3046.751775]
r8712u: module is from the staging directory, the quality is unknown,
you have been warned.
2011-12-07T07:41:38.706661+00:00 beaglebone kernel: [ 3046.760939]
r8712u: DriverVersion: v7_0.20100831
2011-12-07T07:41:38.706687+00:00 beaglebone kernel: [ 3046.761031]
r8712u: register rtl8712_netdev_ops to netdev_ops
2011-12-07T07:41:38.706704+00:00 beaglebone kernel: [ 3046.761048]
r8712u: USB_SPEED_HIGH with 4 endpoints
2011-12-07T07:41:38.715346+00:00 beaglebone kernel: [ 3046.764644]
r8712u: Boot from EFUSE: Autoload OK
2011-12-07T07:41:44+00:00 beaglebone connmand[104]: connmand[104]:
wlan0 {create} index 4 type 1 <ETHER>
2011-12-07T07:41:44+00:00 beaglebone connmand[104]: wlan0 {create}
index 4 type 1 <ETHER>
2011-12-07T07:41:44.345374+00:00 beaglebone kernel: [ 3052.395837]
r8712u: CustomerID = 0x0010
2011-12-07T07:41:44.345413+00:00 beaglebone kernel: [ 3052.395858]
r8712u: MAC Address from efuse = 00:e0:4c:87:00:00
2011-12-07T07:41:44.345432+00:00 beaglebone kernel: [ 3052.396786]
usbcore: registered new interface driver r8712u
2011-12-07T07:41:44+00:00 beaglebone connmand[104]: connmand[104]:
wlan0 {update} flags 4098 <DOWN>
2011-12-07T07:41:44+00:00 beaglebone connmand[104]: wlan0 {update}
flags 4098 <DOWN>
2011-12-07T07:41:44+00:00 beaglebone connmand[104]: connmand[104]:
wlan0 {newlink} index 4 address 00:E0:4C:87:00:00 mtu 1500
2011-12-07T07:41:44+00:00 beaglebone connmand[104]: wlan0 {newlink}
index 4 address 00:E0:4C:87:00:00 mtu 1500
2011-12-07T07:41:44+00:00 beaglebone connmand[104]: connmand[104]:
wlan0 {newlink} index 4 operstate 2 <DOWN>
2011-12-07T07:41:44+00:00 beaglebone connmand[104]: wlan0 {newlink}
index 4 operstate 2 <DOWN>
2011-12-07T07:41:44+00:00 beaglebone connmand[104]: connmand[104]:
wlan0 runs an unsupported 802.11 driver
2011-12-07T07:41:44+00:00 beaglebone connmand[104]: wlan0 runs an
unsupported 802.11 driver
2011-12-07T07:41:44+00:00 beaglebone connmand[104]: connmand[104]:
Create interface wlan0 [ wifi ]
2011-12-07T07:41:44+00:00 beaglebone connmand[104]: Create interface
wlan0 [ wifi ]
2011-12-07T07:41:44.685370+00:00 beaglebone kernel: [ 3052.735579]
r8712u: Loading firmware from "rtlwifi/rtl8712u.bin"
2011-12-07T07:41:49+00:00 beaglebone connmand[104]: ** (connmand:104):
CRITICAL **: error org.freedesktop.DBus.Error.NoReply

Since the behavior is unpredictable and having seen the warnings about
the unsupported driver, I started trying to compile a different
driver, the 8712u. This is the driver that is provided on the Realtek
website, and is included with Fedora 14 where it works just fine with
that particular adapter. This post
http://yetanotherhackersblog.wordpress.com/2010/11/20/streaming-uvc-webcam-video-over-802-11n-with-a-beagleboard/
describes how someone got it working on the beagleboard. I have been
spectacularly unsuccessful in compiling it either using a build
environment on another machine or compiling it directly on the
beaglebone.

I installed the Angstrom development environment on a Fedora machine,
but I'm getting errors running bitbake that I can't seem to get past.
I have tried both the steps listed in the blog post above and on the
Angstrom website and I have been slogging through various errors. I
have been able to get past them, but I seem to make it a few tasks
farther before it blows up again. The last one I saw was:

NOTE: Running task 114 of 5257 (ID: 964, /home/joe/projects/secam/
beaglebone/angstrom-setup-scripts/sources/openembedded/recipes/libtool/
libtool-native_2.2.6b.bb, do_distribute_sources)
NOTE: package autoconf-native-2.65-r14.1: task do_install: Started
ERROR: Logfile of failure stored in: /home/joe/projects/secam/
beaglebone/angstrom-setup-scripts/build/tmp-angstrom_2008_1/work/
x86_64-linux/autoconf-native-2.65-r14.1/temp/log.do_install.29449
Log data follows:| + do_install

+ autotools_do_install
+ oe_runmake DESTDIR=/home/joe/projects/secam/beaglebone/angstrom-

setup-scripts/build/tmp-angstrom_2008_1/work/x86_64-linux/autoconf-
native-2.65-r14.1/image install

+ oenote make DESTDIR=/home/joe/projects/secam/beaglebone/angstrom-

setup-scripts/build/tmp-angstrom_2008_1/work/x86_64-linux/autoconf-
native-2.65-r14.1/image install

+ echo NOTE: 'make DESTDIR=/home/joe/projects/secam/beaglebone/

angstrom-setup-scripts/build/tmp-angstrom_2008_1/work/x86_64-linux/
autoconf-native-2.65-r14.1/image install'

NOTE: make DESTDIR=/home/joe/projects/secam/beaglebone/angstrom-

setup-scripts/build/tmp-angstrom_2008_1/work/x86_64-linux/autoconf-
native-2.65-r14.1/image install

+ make DESTDIR=/home/joe/projects/secam/beaglebone/angstrom-setup-

scripts/build/tmp-angstrom_2008_1/work/x86_64-linux/autoconf-
native-2.65-r14.1/image install

make: *** No rule to make target `install'. Stop.
+ die 'oe_runmake failed'
+ oefatal 'oe_runmake failed'
+ echo FATAL: 'oe_runmake failed'
FATAL: oe_runmake fail

Since I have only made it to task 114 of 5257, I figure there must be
a better way.

I don't particularly want to have to get cross compiling working
anyway as I have been successfully compiling on the board directly for
various other applications using make. The problem with compiling the
driver there is that it needs the kernel source, and although I
downloaded the source from the github repository, is is missing the
kernel configuration file for Angstrom.

# make CROSS_Compile= KSRC=/usr/src/kernels/3.1.0+/ KVER=3.1.0+
ARCH=arm
make ARCH=arm CROSS_COMPILE= -C /usr/src/kernels/3.1.0+/ M=/home/root/
rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/driver/
rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401 modules
make[1]: Entering directory `/usr/src/kernels/3.1.0+'
  ERROR: Kernel configuration is invalid.
         include/generated/autoconf.h or include/config/auto.conf are
missing.
         Run 'make oldconfig && make prepare' on kernel src to fix it.

If I make oldconfig I have to input all the zillions of kernel
parameters that were chosen for the Angstrom build. These would be in
the .config file, but I haven't been able to locate it so far.

I know there are other adapters that work, but they are too big
physically for what I am building. It seems that the same chipset is
used by the other manufacturers in their tiny wireless adapters as
well.

My options seem to be:

1. Get the r8712u driver working reliably - not sure if this is
possible
2. Cross-compile the 8712u driver on Fedora - need to figure out why
bitbake is broken
3. Compile the 8712u driver on the beaglebone - need the .config file
for the kernel

I appreciate any help or suggestions.

Update:

I was finally able to build the kernel under Fedora. I deleted
everything and followed the steps on the Angstrom site, rather than
the other one I referenced above. Maybe whatever I got from
gitorious.org was defective.

Having built the kernel, I tried to cross-compile the driver. After
running into a bunch of problems (I haven't done this before) I copied
the kernel source to the beaglebone and compiled the driver there. I
should mention that although the file name of the driver is 8712u.ko,
the name that shows up in lsmod is r8712u, so I guess it's just a
different version of the one that came with Angstrom.

So now at least the behavior is consistent, although it still doesn't
work. I see blinking lights, but it won't connect to the network.
Running wpa_supplicant in debug mode produces this:

# /usr/sbin/wpa_supplicant -P /var/run/wpa_supplicant.wlan0.pid -i
wlan0 -c /etc/wpa_supplicant.conf -D wext -dK
Initializing interface 'wlan0' conf '/etc/wpa_supplicant.conf' driver
'wext' ctrl_interface 'N/A' bridge 'N/A'
Configuration file '/etc/wpa_supplicant.conf' -> '/etc/
wpa_supplicant.conf'
Reading configuration file '/etc/wpa_supplicant.conf'
ctrl_interface='/var/run/wpa_supplicant'
Priority group 0
   id=0 ssid='xxxxx'
SIOCGIWRANGE: WE(compiled)=22 WE(source)=16 enc_capa=0xf
  capabilities: key_mgmt 0xf enc 0xf flags 0x0
ioctl[SIOCSIWAP]: Operation not permitted
WEXT: Failed to set bogus BSSID/SSID to disconnect
netlink: Operstate: linkmode=1, operstate=5
Own MAC address: 00:26:18:a1:9f:84
wpa_driver_wext_set_key: alg=0 key_idx=0 set_tx=0 seq_len=0 key_len=0
wpa_driver_wext_set_key: alg=0 key_idx=1 set_tx=0 seq_len=0 key_len=0
wpa_driver_wext_set_key: alg=0 key_idx=2 set_tx=0 seq_len=0 key_len=0
wpa_driver_wext_set_key: alg=0 key_idx=3 set_tx=0 seq_len=0 key_len=0
wpa_driver_wext_set_countermeasures
RSN: flushing PMKID list in the driver
Setting scan request: 0 sec 100000 usec
EAPOL: SUPP_PAE entering state DISCONNECTED
EAPOL: Supplicant port status: Unauthorized
EAPOL: KEY_RX entering state NO_KEY_RECEIVE
EAPOL: SUPP_BE entering state INITIALIZE
EAP: EAP entering state DISABLED
EAPOL: Supplicant port status: Unauthorized
EAPOL: Supplicant port status: Unauthorized
Added interface wlan0
RTM_NEWLINK: operstate=0 ifi_flags=0x1043 ([UP][RUNNING])
RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added
Wireless event: cmd=0x8b06 len=8
RTM_NEWLINK: operstate=0 ifi_flags=0x1003 ([UP])
RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added
State: DISCONNECTED -> SCANNING
Starting AP scan for wildcard SSID
Scan requested (ret=0) - scan timeout 5 seconds
EAPOL: disable timer tick
EAPOL: Supplicant port status: Unauthorized
Scan timeout - try to get results
Received 0 bytes of scan results (0 BSSes)
BSS: Start scan result update 1
New scan results available
Selecting BSS from priority group 0
Try to find WPA-enabled AP
Try to find non-WPA AP
No suitable network found

I don't know what ioctl[SIOCSIWAP] is supposed to do, but it seems to
be failing. There was a warning message during the compile of the
driver in the ioctl module:

/home/root/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/driver/
rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/ioctl/
rtl871x_ioctl_linux.c: In function 'r8711_wx_get_scan':
/home/root/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/driver/
rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/ioctl/
rtl871x_ioctl_linux.c:1865:1: warning: the frame size of 1056 bytes is
larger than 1024 bytes