RT2870 compile error under (K)Ubuntu Maverick (10.10)

Yesterday the next version of Ubuntu was released. It comes with kernel 2.6.35 which can make problems if you want to compile the RT2870 driver provided by Ralink. The reason for me to compile the driver rather than using the one shipped with the kernel is that the latter reduces my WLAN speed from 130 MBit/s to 54 MBit/s. If you start compiling the Ralink driver you will soon get the following error message:

CC [M]  2010_0709_RT2870_Linux_STA_v2.4.0.1/os/linux/../../common/cmm_mac_usb.o 2010_0709_RT2870_Linux_STA_v2.4.0.1/os/linux/../../common/cmm_mac_usb.c: In function ‘RTMPAllocUsbBulkBufStruct’: 2010_0709_RT2870_Linux_STA_v2.4.0.1/os/linux/../../common/cmm_mac_usb.c:52: error: implicit declaration of function ‘usb_buffer_alloc’ 2010_0709_RT2870_Linux_STA_v2.4.0.1/os/linux/../../common/cmm_mac_usb.c:52: warning: assignment makes pointer from integer without a cast 2010_0709_RT2870_Linux_STA_v2.4.0.1/os/linux/../../common/cmm_mac_usb.c: In function ‘RTMPFreeUsbBulkBufStruct’: 2010_0709_RT2870_Linux_STA_v2.4.0.1/os/linux/../../common/cmm_mac_usb.c:78: error: implicit declaration of function ‘usb_buffer_free’ 2010_0709_RT2870_Linux_STA_v2.4.0.1/os/linux/../../common/cmm_mac_usb.c: In function ‘RTMPFreeTxRxRingMemory’: make[2]: *** [2010_0709_RT2870_Linux_STA_v2.4.0.1/os/linux/../../common/cmm_mac_usb.o] Error 1 make[1]: *** [_module_2010_0709_RT2870_Linux_STA_v2.4.0.1/os/linux] Error 2 make[1]: Leaving directory '/usr/src/linux-headers-2.6.35-22-generic' make: *** [LINUX] Error 2

The cause for these errors is that the driver makes use of the functions usb_buffer_alloc() and usb_buffer_free() which got renamed in kernel 2.6.35. This is stated in the Changelog:

    USB: rename usb_buffer_alloc() and usb_buffer_free() users

    For more clearance what the functions actually do,

      usb_buffer_alloc() is renamed to usb_alloc_coherent()
      usb_buffer_free()  is renamed to usb_free_coherent()

So to get rid of the error messages all you have to do is to rename the function in include/os/rt_linux.h. To make it easier you can download a patch here. Just run the following command in the driver directory:

patch -ul -p0 -i path/to/patch

Or use the one-liner:

wget -qO- http://www.linuxcrew.de/wp-content/uploads/2010/10/rt2870sta_usb_kernel2635.patch | patch -ul -p0

After patching you can compile the driver without errors again.

Kategorien: 

Comments

yeah! very great. thks a lots!

One note, the 'rt_linux.h' file is available as 'include/os/rt_linux.h'. The article above left out the 'os' subdirectory.

Thanks for this hint! The path is now correct.

Thanks, this fixed my compile issues.

Did you ever increase your speed back to 130? I recompiled the drivers and I'm still only getting 54. I verified that my adapter is a 150 (It and two others work fine on Windows (arggg)) but I can't get above 54 on Ubuntu 10.10

I'm using the 120 (DWA 140) and I have no problems getting speeds up to 300 MBit/s. I don't have a 125 (DWA 150) for testing, but the 54 MBit "limit" indicates that the Ubuntu module is still loaded. Make sure your freshly compiled module gets loaded.

great!!!

Thank you, thank you, thank you! Lifesaver, you are!

It looks like my install copied the compiled driver but how can I tell which driver is actually being used? I blacklisted rt2800usb, rt2x00lib, rt2x00usb. Are there any more I should add to the list?

Sorry to be a pest but I found out that although my rt2870sta.ko file is copied to the /lib/modules/.../kernel/drivers/net/wireless dir and the firmware is in /etc/firmware, the driver being used is /lib/modules/.../kernel/drivers/staging/rt2870/rt2870sta.ko. Do you know why or how to make it use the correct driver? I did a "modinfo" on the driver and that's how I found the path.

Everything is copied to the right place, so there shouldn't be a problem. Try to insert the module manually: insmod /lib/modules/`uname -r`/kernel/drivers/net/wireless/rt2870sta.ko
This should tell you if there's something wrong about your module.

Thanks for your help. I did get an error, -1 invalid module format, but I've since compiled and installed a new kernel... I'll recompile this driver and try again. I'll just have to keep plugging at it since apparently it is do-able!

Thanks so much

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.