OpenWrt Forum Archive

Topic: [SOLVED] Problem when patching wifi kernel driver on BB

The content of this topic has been archived on 18 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello OpenWRT Devs!

Warning: I'm German, so please be patient with my grammar smile

For every path shown here, i assume i'm in the base dir (like ~/openwrt/) for compiling Barrier Breaker by myself.


What i wanted to do:

I wanted to add Support for the Sitecom WLA-2100 Wireless USB stick

ID 0df6:0078

into the rt2800usb Kernel module.


What i've done so far:

I installed the luci feed with

./scripts/feeds update -a
./scripts/feeds install -a -p luci

and used

make menuconfig

to set everything up (and include the rt2800usb Kernel module).

I made a patch

--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -1134,6 +1134,7 @@ static struct usb_device_id rt2800usb_de
     { USB_DEVICE(0x0df6, 0x0051) },
     { USB_DEVICE(0x0df6, 0x005f) },
     { USB_DEVICE(0x0df6, 0x0060) },
+    { USB_DEVICE(0x0df6, 0x0078) },
     /* SMC */
     { USB_DEVICE(0x083a, 0x6618) },
     { USB_DEVICE(0x083a, 0x7511) },

following the wiki and put it into

./target/linux/brcm2708/patches-3.10/0175-Adding_Sitecom_WLA-2100_A.patch

folder.

Then i proceeded to build the firmware with

make dirclean
make -j 5 V=s

and everything went fine, except that the kernel module isn't loading for the WLA-2100

dmesg output:
[  168.147591] usb 1-1.3.1: new high-speed USB device number 5 using dwc_otg
[  168.274184] usb 1-1.3.1: New USB device found, idVendor=0df6, idProduct=0078
[  168.283055] usb 1-1.3.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  168.293696] usb 1-1.3.1: Product: 802.11 n WLAN
[  168.299855] usb 1-1.3.1: Manufacturer: Ralink
[  168.305713] usb 1-1.3.1: SerialNumber: 1.0

although it is in the image and can be forced with

echo "0DF6 0078" > /sys/bus/usb/drivers/rt2800usb/new_id

to load.

dmesg output:
[  355.567685] usb 1-1.3.1: new high-speed USB device number 6 using dwc_otg
[  355.694279] usb 1-1.3.1: New USB device found, idVendor=0df6, idProduct=0078
[  355.702897] usb 1-1.3.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  355.713102] usb 1-1.3.1: Product: 802.11 n WLAN
[  355.719073] usb 1-1.3.1: Manufacturer: Ralink
[  355.724768] usb 1-1.3.1: SerialNumber: 1.0
[  355.827605] usb 1-1.3.1: reset high-speed USB device number 6 using dwc_otg
[  355.947155] ieee80211 phy0: rt2x00_set_rt: Info - RT chipset 5392, rev 0223 detected
[  356.014148] ieee80211 phy0: rt2x00_set_rf: Info - RF chipset 5372 detected

So i used

find . -name rt2800usb.c

which gave me the following output:

./build_dir/toolchain-arm_arm1176jzf-s+vfp_gcc-4.8-linaro_uClibc-0.9.33.2_eabi/linux-3.10.49/drivers/net/wireless/rt2x00/rt2800usb.c
./build_dir/target-arm_arm1176jzf-s+vfp_uClibc-0.9.33.2_eabi/linux-brcm2708/compat-wireless-2014-05-22/drivers/net/wireless/rt2x00/rt2800usb.c
./build_dir/target-arm_arm1176jzf-s+vfp_uClibc-0.9.33.2_eabi/linux-brcm2708/linux-3.10.49/.pc/platform/0175-Adding_Sitecom_WLA-2100_A.patch/drivers/net/wireless/rt2x00/rt2800usb.c
./build_dir/target-arm_arm1176jzf-s+vfp_uClibc-0.9.33.2_eabi/linux-brcm2708/linux-3.10.49/drivers/net/wireless/rt2x00/rt2800usb.c

I looked into every *.c file named above and found that the patch was only applied on

./build_dir/target-arm_arm1176jzf-s+vfp_uClibc-0.9.33.2_eabi/linux-brcm2708/linux-3.10.49/drivers/net/wireless/rt2x00/rt2800usb.c

whereas the other three weren't affected.

So i edited them manually, deleted the

./bin

folder and compiled again with

make V=s -j 5

and in this image everything works as expected,

dmesg output:
[   70.867672] usb 1-1.3.1: new high-speed USB device number 5 using dwc_otg
[   70.994256] usb 1-1.3.1: New USB device found, idVendor=0df6, idProduct=0078
[   71.003114] usb 1-1.3.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   71.013779] usb 1-1.3.1: Product: 802.11 n WLAN
[   71.019934] usb 1-1.3.1: Manufacturer: Ralink
[   71.025804] usb 1-1.3.1: SerialNumber: 1.0
[   71.127592] usb 1-1.3.1: reset high-speed USB device number 5 using dwc_otg
[   71.247139] ieee80211 phy0: rt2x00_set_rt: Info - RT chipset 5392, rev 0223 detected
[   71.314135] ieee80211 phy0: rt2x00_set_rf: Info - RF chipset 5372 detected

but after every

make dirclean

the manual changes are getting deleted.



So my Question is:

What am i missing to do, so that the patch is applied among all 4 *.c files that are generated in the build process?


Hardware:
RaspberryPi Model B
Ubuntu Server for building.


Thanks in advice

Napsi-GER-

Edit: Removed dead dropbox link.

(Last edited by Napsi-GER- on 13 Jan 2018, 16:44)

You just patched the wrong file because you did not know OpenWrt internals. (can happen quite fast ^^)

You only need to patch the right one:

- ...toolchain....  : not the right one
- target ....pc/platform/... wrong (artefact of your patch file)
- target...linux-brcm2708/linuxx-3.10... : wrong (your patched file)
- target...linux-brcm2708/compat-wireless... : right one

OpenWrt does not use in Kernel drivers, but "ported" drivers (with backports project help)
see http://wiki.openwrt.org/doc/howto/wireless.overview

so you should add your patch into the directory of the mac80211 package:

kernel/linux/mac80211/patches

Thank you for providing this last piece of information.

I have now done the following to archive my goal:

Fresh start with

make distclean
scripts/feeds update -a
scripts/feeds install -a -p luci
make menuconfig

Then extracting the mac80211 package with

make package/mac80211/{clean,prepare} V=s QUILT=1

and switching into the directory

 cd ./build_dir/target-arm_arm1176jzf-s+vfp_uClibc-0.9.33.2_eabi/linux-brcm2708/compat-wireless-2014-05-22

and then pushing all patches till

621-rt2x00-ht20_40_fix.patch

with

quilt push 621-rt2x00-ht20_40_fix.patch

Then i created my new patch with

quilt new 622-rt2x00-adding-sitecom-wla-2100.patch

and assigned the file to edit with it

quilt edit drivers/net/wireless/rt2x00/rt2800usb.c

and edited it (see first post).
Reviewing the patch with

quilt diff

updating it with

quilt refresh

and making it persistent with

cd ../../../../
make package/mac80211/update V=s

It can now be found in folder:

./package/kernel/mac80211/patches/622-rt2x00-adding-sitecom-wla-2100.patch

Finally i build the Image with

make dirclean
make V=s -j 5

Testing:

dmesg output:
[   36.037554] usb 1-1.3.1: new high-speed USB device number 5 using dwc_otg
[   36.164132] usb 1-1.3.1: New USB device found, idVendor=0df6, idProduct=0078
[   36.172996] usb 1-1.3.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   36.183667] usb 1-1.3.1: Product: 802.11 n WLAN
[   36.189817] usb 1-1.3.1: Manufacturer: Ralink
[   36.195700] usb 1-1.3.1: SerialNumber: 1.0
[   36.297598] usb 1-1.3.1: reset high-speed USB device number 5 using dwc_otg
[   36.417132] ieee80211 phy0: rt2x00_set_rt: Info - RT chipset 5392, rev 0223 detected
[   36.484149] ieee80211 phy0: rt2x00_set_rf: Info - RF chipset 5372 detected

And it's working on BB! big_smile

The patch

--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -1136,6 +1136,7 @@ static struct usb_device_id rt2800usb_de
     { USB_DEVICE(0x0df6, 0x0051) },
     { USB_DEVICE(0x0df6, 0x005f) },
     { USB_DEVICE(0x0df6, 0x0060) },
+    { USB_DEVICE(0x0df6, 0x0078) },
     /* SMC */
     { USB_DEVICE(0x083a, 0x6618) },
     { USB_DEVICE(0x083a, 0x7511) },

in case someone wants to integrate it into the sources (has to be verified if working with CC).

Napsi-GER-

Edit: Removed dead dropbox link.

(Last edited by Napsi-GER- on 13 Jan 2018, 16:43)

upon looking into it i found that USB ID is already in mainline

but OpenWrt does not set CONFIG_RT2800USB_UNKNOWN
so it  might be added to package/kernel/mac80211/Makefile part so its

config-$(call config_package,rt2800-usb) += RT2800USB
config-y += RT2800USB_RT33XX RT2800USB_RT35XX RT2800USB_RT3573 RT2800USB_RT53XX RT2800USB_RT55XX RT2800USB_UNKNOWN

(no linebreak in 2nd line)

should result in a working stick too probably

(Last edited by zloop on 12 May 2015, 15:59)

Thanks again for your reply!

I've looked into the sources again, but in the section surrounded by the preprocessor define

#ifdef CPTCFG_RT2800USB_UNKNOWN
...
#endif

my ID isn't listed, so enabling it in the makefile wouldn't do the job. Or have i overseen something?

I haven't tried it because i have it working. And i wouldn't want do some further investigation into this, as long as i stay on BB.

But when i switch to CC and there is still no support for it, i will come back to this thread. wink

Napsi-GER-

(Last edited by Napsi-GER- on 18 May 2015, 11:34)

The discussion might have continued from here.