[SOLVED]Building a usb wifi driver


Hoodoo

Member
Joined
Jul 11, 2011
Messages
350
Age
39
Location
Moscow, Russia
THE DRIVER DISCUSSED HERE IS IRRELEVANT FOR ANY PANDORA OS VERSION STARTING FROM ZAXXON HOTFIX 6 RELEASE CANDIDATE! THE DEVICES MENTIONED HERE SHOULD BE SUPPORTED OUT OF THE BOX!


This week I tried to build a usb wifi driver for rtl8192cu.


I followed the wiki guide for firmware compatibility, i.e.


Prepared the OS for building:


- Installed qemu


- Installed Debian Squeeze to virtual machine


- Installed git, build-essential, bzip2, unzip, curl, libmpfr-dev


- symlinked /usr/lib/libmpfr.so to /usr/lib/libmpfr.so.1


- got djwillis toolchain and untared it to /usr/local


Got the kernel:


- git clone git://openpandora.org/pandora-kernel.git


- git checkout --track -b pandora-27-omap1 origin/pandora-27-omap1


Got the patches:


- git://git.openpandora.org/openpandora.oe.git


- lloked into openpandora.oe/recipes/linux/omap3-pandora-kernel_2.6.27-pandora.bb for patches list and applied them (all succeeded)


- copied the config from reciopes to /pandora-kernel/.config


Built the kernel:


- make && make modules && make prepare && make modules_prepare


Edited the makefile:


- redefined $CROSS_COMPILE to arm-angstrom-linux-gnueabi-, $ARCH to arm, $KVER to 2.6.27.46.omap1, $KSRC to path to kernel source


Built the module:


-make


Copied the resulting .ko file to pandora: /lib/modules/2.6.27.46.omap1/kernel/drivers/net/usb/


Edited modules.dep


Tried to modprobe the driver and got a bunch of 'Unknown symbol' errors in dmesg.


What did I do wrong?


------------------------------------------------


Nothing. In hotfix5 it would be a real hairy voodoo to build a working driver, if possible. The kernel in hotfix6 has a compatibility layer backported from mainline and this driver works fine.
 
Last edited by a moderator:
im kinda at where your at. gonna kick this around on sunday with rtl8187 and we'll see what happens.
 
Good luck to you with that stuff. I suspect that drivers might not suit the current kernel.


I'm now trying Debian installation described in the wiki and going to give newer kernels a go, maybe these would work.


Also, flawless GPRS/EDGE over Bluetooth helps a lot - no chance to install packages with speed like that, but it's enough for casual browsing.
 
You need to build against compat-wireless, it's a backport or Linux wireless subsystem from some 2.6.3x kernel that we are using. It's in pandora-wifi.git , specifying this instead of kernel root for rtl8192cu build should produce you compatible modules.


I've also built this for someone before, it might need hf6a though:


http://notaz.gp2x.de/misc/pnd/ko/hf6/
 
Last edited by a moderator:
*notaz*, thanks a lot!


Unfortunately, plain downloading the .ko file and trying to modprobe it produces even more 'Unknown symbols' than the one I've managed to build.


Could you please kindly elaborate your answer a little bit for people who haven't been into Pandora development from the start? What is hf6a* and how do I biuld against compat-wireless**? I modified the driver's makefile to point at ~/pandora-wifi/compat/ and I get 'no rule to make target `modules''


Could you please provide something more like a complete idiot's guide please? Or maybe I could contact you or someone else via xmmp tomorrow/the day after tomorrow for further explanation?


As you can see, I do write down anything I do and really try to understand what's going on, so it might make a nice wiki article - what's doable and how.


Thanks in advance!


______________________


* hf6a is hotfix 6 alpha: http://boards.openpa...__fromsearch__1


** I modified the driver's Makefile to point at ~/pandora-wifi and modified the makefile in ~/pandora-wifi: export KLIB:= /root/kernel-patched, and now I have "no rule to make target modules' and copying ./config to /kernel-patched/build/ does not help


I also tried the module you proposed, it seems to modprobe fine, but the dongle does not work with Pandora (works with both my laptops)


I ran depmod && modprobe 8192cu, it did modprobe fine, but when I stick the dongle in dmesg only says a new device found and recognized, the driver does not kick in.
 
Last edited by a moderator:
HELL YEAH IT WORKS!


I've built a working driver!


So what described in the first post is actually correct, but the kernel in hotfix5 just does not 'understand' the driver. In hotfix6 alpha 4 wireles-compat is added to kernel, so the driver worked perfectly: I just made a directory /lib/modules/2.6.27.46.omap1/kernel/drivers/net/wireless/ and put the file there, then ran depmod && modprobe 8192cu and BAM! "Wireless networks available"


So Belkin Surf micro, rtl8192cu is proven to work with Openpandora (hotfix 6 reqiured)


The dongle: http://www.belkin.co...oduct_Id=525497


The driver's source: http://tuxme.net/dat...L8192CU.tar.bz2 (I think it's basically the official manufacturer's driver stripped of scripts and wpa_supplicant they kindly attached to it)


The driver: http://dl.openhandhe...i?0,0,0,0,1,438


Thanks everyone involved (people who helped me here and in IRC and of course those who made hf6)
 
Last edited by a moderator:
I,ve bought a Belkin N150 wifi usb dongle. a/b/g/n compatible. And it works on the pandora with Hoodoo driver.


Thanks, Now I have a 10mb/s wifi! Internal one was broken...


THANKS SO MUCH
 
Jeff, please post a link to the dongle's description.


It works not because I've compiled the driver written by Realkek, but because Pandora kernel hacking people added compat-wireless, so now much more drivers can be built.


I wonder how do I get a list of devices supported by this module, I guess it should be quite a large part of Realteks.
 
Last edited by a moderator:
Hoodoo,


Since you are already setup could you please build Pandora drivers for the Realtek RTL8191SU chipset?


I think the Linux drivers are here: http://www.realtek.c...=true#RTL8191SU


The Realtek RTL8191SU is common in many cheap eBay and Amazon USB wifi N adapters.


I have one to test, they work well and many support external antennas, which is what I want to try.


Thank you!!!
 
Here you go, please test. Seems like it supports crapload of dongles. Please report whichever dongle works with it or add information to wiki.


Send more of these, I'll build them (you'll have to test on your own though).

8172u.zip
 

Attachments

  • 8172u.zip
    155.9 KB · Views: 432
Last edited by a moderator:
See, the driver downloaded from RTL8191SU link results in 8172u module. And 8921cu works with some random dongle (N150 is definitely not 8192), that's what I'm curious about, maybe 2-3 modules could cover 70% of Realtek dongles.
 
Hoodoo,


I won’t have access to the 8191SU adapter until later this week so I can’t test it yet.


I did find my Realtek 8187 chipset Wireless G adapter (Realtek RTL8187_Wireless, Vendor 0x0bda, Product 0x8187) and I have it with me.


So if you could please do your kernel module magic again I think the drivers are here:





http://linuxwireless...Drivers/rtl8187 or maybe here: http://www.realtek.c...s=true#RTL8187L


Thanks again!!!


EDIT: The second link seems to lead to the Linux driver source code from Realtek.


EDIT2: Found the source code related to the first link here: http://rtl-wifi.svn.sourceforge.net/


EDIT3: Attached the Realtek released driver (rtl8187L_linux_26.1040.0820.2010.release.tar.gz) to this post because their site was inconsistent today:
 

Attachments

  • rtl8187L_linux_26.1040.0820.2010.release.tar.gz
    1.7 MB · Views: 408
Last edited by a moderator:
Well, it'll take a little longer, it gives me some problems I'm trying to solve.


Makefile:

Code:
LINUX_KSRC_MODULE = /root/kernel-patched/drivers/net/wireless #modified

RTL8187L_DIR = $(shell pwd)

KVER  = 2.6.27.46-omap1 #modified

KSRC = /root/kernel-patched #modified

HAL_SUB_DIR = rtl8187

ARCH = arm #added

CROSS_COMPILE = arm-angstrom-linux-gnueabi- #added

all:

ifeq ($(shell uname -r|cut -d. -f1,2), 2.4)

	@make -C $(RTL8187L_DIR)/ieee80211

	@make -C $(RTL8187L_DIR)/rtl8187

else 

#	@make -C $(KSRC) SUBDIRS=$(RTL8187L_DIR)/ieee80211 modules

#	@cp $(RTL8187L_DIR)/ieee80211/Module.symvers $(RTL8187L_DIR)/rtl8187

	@make -C $(KSRC) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) SUBDIRS=$(RTL8187L_DIR)/rtl8187 modules #guess this one is being run, added options here - ARCH and CROSS_COMPILE

endif

ifeq ($(shell uname -r|cut -d. -f1,2), 2.4)

install:

	@make -C ieee80211/ install

	@make -C rtl8187/ install

else

install:

	@grep rtl8187.ko /lib/modules/$(shell uname -r)/modules.dep && rm -fr $(LINUX_KSRC_MODULE)/rtl8187.ko || echo No system rtl8187.ko file found, Now we will install the new driver rtl8187.ko into system

	@grep rtl8187.ko /lib/modules/$(shell uname -r)/modules.dep && rm -fr $(LINUX_KSRC_MODULE)/rtl818x/rtl8187.ko || echo No system rtl8187.ko file found, Now we will install the new driver rtl8187.ko into system

	@cp $(RTL8187L_DIR)/RadioPower.sh /etc/acpi/events/

#	@make -C ieee80211/ install

	@make -C rtl8187/ install

endif

uninstall:

	@make -C ieee80211/ uninstall

	@make -C rtl8187/ uninstall

clean:

	@make -C rtl8187/ clean

	@make -C ieee80211/ clean

	@rm -rf *~

	@rm -rf Module.markers

	@rm -rf modules.order

	@rm -rf tags


Errors:


Code:
cc1: error: unrecognized command line option "-mlittle-endian"

cc1: error: unrecognized command line option "-marm"

cc1: error: unrecognized command line option "-mapcs"

cc1: error: unrecognized command line option "-mno-sched-prolog"

cc1: error: unrecognized command line option "-mabi=aapcs-linux"

cc1: error: unrecognized command line option "-mno-thumb-interwork"

/root/8187/rtl8187L_linux_26.1040.0820.2010.release/rtl8187/r8187_core.c:1: error: bad value (armv7-a) for -march= switch

/root/8187/rtl8187L_linux_26.1040.0820.2010.release/rtl8187/r8187_core.c:1: error: bad value (armv7-a) for -mtune= switch

make[2]: *** [/root/8187/rtl8187L_linux_26.1040.0820.2010.release/rtl8187/r8187_core.o] Error 1

make[1]: *** [_module_/root/8187/rtl8187L_linux_26.1040.0820.2010.release/rtl8187] Error 2

make: *** [all] Error 2
 
Last edited by a moderator:
I did some searching online for those errors and most advice seems to suggest the wrong [native] compiler is being called.


There is a Makefile in the rtl8187L_linux_26.1040.0820.2010.release/rtl8187/ folder that sets “CC = gcc” and this may override your command line declaration if you used one.


I think this should be “CC = arm-angstrom-linux-gnueabi-gcc” or something like that.


I’m only guessing here and that is the only and (in the ieee80211 folder's Makefile) are places where I found the compiler being set.


Here is the contents of the rtl8187L_linux_26.1040.0820.2010.release/rtl8187/Makefile :

Code:
NIC_SELECT = RTL8187L




CC = gcc

KVER  := $(shell uname -r)

KSRC := /lib/modules/$(KVER)/build

PWD = $(shell pwd)

INSTALL_PREFIX :=


ifneq ($(shell uname -r|cut -d. -f1,2), 2.4)

MODDESTDIR := /lib/modules/$(KVER)/kernel/drivers/net/wireless


#EXTRA_CFLAGS += -DCONFIG_IEEE80211_NOWEP=y

#EXTRA_CFLAGS += -DCONFIG_RTL8180_IOMAP

EXTRA_CFLAGS += -I$(TOPDIR)/drivers/net/wireless

EXTRA_CFLAGS += -std=gnu89

EXTRA_CFLAGS += -O2

EXTRA_CFLAGS += -mhard-float -DCONFIG_FORCE_HARD_FLOAT=y

EXTRA_CFLAGS += -DPOLLING_METHOD_FOR_RADIO

EXTRA_CFLAGS += -DCONFIG_PM

EXTRA_CFLAGS += -DCONFIG_BIG_DATA_NOSCAN

EXTRA_CFLAGS += -DLED

#EXTRA_CFLAGS += -DLED_SHIN

EXTRA_CFLAGS += -DRATE_ADAPTIVE

EXTRA_CFLAGS += -DDIG

#EXTRA_CFLAGS += -DSW_ANTE_DIVERSITY


EXTRA_CFLAGS += -DBUILT_IN_IEEE80211


r8187l-objs :=      	\

	r8187_core.o    	\

	r8180_93cx6.o   	\

	r8180_wx.o      	\

	r8180_rtl8225.o 	\

	r8180_rtl8225z2.o   \

	r8187_led.o 		\

	r8180_pm.o      	\

	r8180_dm.o      	\

	../ieee80211/ieee80211_softmac.o	\

	../ieee80211/ieee80211_rx.o 		\

	../ieee80211/ieee80211_tx.o 		\

	../ieee80211/ieee80211_wx.o 		\

	../ieee80211/ieee80211_module.o 	\

	../ieee80211/ieee80211_softmac_wx.o \

	../ieee80211/ieee80211_crypt.o  	\

	../ieee80211/ieee80211_crypt_tkip.o \

	../ieee80211/ieee80211_crypt_ccmp.o \

	../ieee80211/ieee80211_crypt_wep.o


obj-m := r8187l.o




all: modules


modules:

        	$(MAKE) -C $(KSRC) M=$(PWD) CC=$(CC) modules


install: modules

        	find /lib/modules/$(shell uname -r) -name "r8187.ko" -exec ls -l {} \;

        	find /lib/modules/$(shell uname -r) -name "r8187.ko" -exec rm {} \;


        	install -p -m 644 r8187l.ko $(MODDESTDIR)

        	depmod -a


uninstall:

        	$(shell [ -d $(MODDESTDIR) ] && rm -fr $(MODDESTDIR)/r8187l.ko)

        	depmod -a

clean:

        	rm -fr *.mod.c *.mod *.o .*.cmd *.ko *~

        	rm -fr .tmp_versions

        	rm -fr Module.symvers

        	rm -fr modules.order

        	rm -fr Module.markers

        	rm -rf tags



else #2.4kernel

MODDESTDIR := /lib/modules/$(KVER)/kernel/drivers/net/wireless



LD := ld

KSRC := /lib/modules/$(KVER)/build

CONFIG_FILE := $(KSRC)/include/linux/autoconf.h

CFLAGS += -DLINUX -D__KERNEL__ -DMODULE -O2 -pipe -Wall

CFLAGS += -I$(KSRC)/include -I.

CFLAGS += -DMODVERSIONS -DEXPORT_SYMTAB -include $(KSRC)/include/linux/modversions.h

CFLAGS += -DPOLLING_METHOD_FOR_RADIO

CFLAGS += -DCONFIG_BIG_DATA_NOSCAN

CFLAGS += -DLED

#CFLAGS += -DLED_SHIN

CFLAGS += -DRATE_ADAPTIVE

CFLAGS += -DDIG

#CFLAGS += -DSW_ANTE_DIVERSITY


SMP := $(shell $(CC) $(CFLAGS) -E -dM $(CONFIG_FILE) | \

   grep CONFIG_SMP | awk '{print $$3}')

ifneq ($(SMP),1)

   SMP := 0

endif

ifeq ($(SMP),1)

   CFLAGS	+= -D__SMP__

endif

BJS := ${patsubst %.c, %.o, ${wildcard *.c}}


all:r8187l.o

r8187l.o: \

        	r8187_core.o \

        	r8180_93cx6.o \

        	r8180_wx.o \

        	r8180_rtl8225.o \

        	r8180_rtl8225z2.o \

        	r8187_led.o \

        	r8180_dm.o

        	$(LD) -r $^ -o $@

install:r8187l.o

        	install -p -m 644 r8187l.o  $(MODDESTDIR)

        	@depmod -a


uninstall:

        	$(shell [ -d $(MODDESTDIR) ] && rm -fr $(MODDESTDIR)/r8187l.o)

        	@depmod -a


clean:

        	rm -f *.mod.c *.mod *.o .*.cmd *.ko *~

        	rm -rf $(PWD)/tmp

        	rm -rf *~

        	rm -fr Module.symvers

        	rm -fr modules.order

        	rm -fr Module.markers

        	rm -rf tags


endif


rtl8187L_linux_26.1040.0820.2010.release/ieee80211/Makefile also has the same CC declaration.


Thanks for working on this!!!
 
Last edited by a moderator:
Hmm, looks pretty sane. I've looked through these but didn't modify them. I think I should try changing this one and run make right there. Closer to the roots. :)


// I should rename the topic to 'half-assed drivers workshop' :)
 
Last edited by a moderator:
Back
Top