mdsh
Posts: 4
Joined: Sun Jan 13, 2013 10:02 am

Compile kernel modules

Sun Jan 27, 2013 10:18 pm

I've got a couple of 256MB models running Raspbian.

Just for the heck-of-it I've been trying to build the kernel module for a TP-Link TL-WDN3200. It's recognized as a RT5572.

[67745.924045] usb 1-1.3.2: new high-speed USB device number 7 using dwc_otg
[67746.040555] usb 1-1.3.2: New USB device found, idVendor=148f, idProduct=5572
[67746.040584] usb 1-1.3.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[67746.040600] usb 1-1.3.2: Product: 802.11 n WLAN
[67746.040614] usb 1-1.3.2: Manufacturer: Ralink
[67746.040626] usb 1-1.3.2: SerialNumber: 1.0

There are several web pages describing how to download the RPi kernel, prepare it for modules building, download the driver source, build it, etc - including this one:

http://www.raspberrypi.org/phpBB3/viewt ... le#p269368

Every which way I do it I always end up with insmod not liking the module, seen clearly from the dmesg log line:

[71049.485779] rt5572sta: disagrees about version of symbol module_layout

I'm after advice on how I can debug the "disagrees about version of symbol module_layout" thing. How I can see what it is, how I can find out what it should be.

Thanks in advance :-)

--
Mark
--
Mark Himsley

elatllat
Posts: 1337
Joined: Sat Dec 17, 2011 5:05 pm

Re: Compile kernel modules

Thu Jan 31, 2013 7:01 am

"This indicates you have compiled the module against a different version of the kernel than is running."


http://elinux.org/Talk:RPi_Kernel_Compi ... le_example
SBC with 32GB RAM: https://hardkernel.com

FAQ : https://raspberrypi.stackexchange.com

Unanswered: https://www.raspberrypi.org/forums/search.php?search_id=unanswered

mdsh
Posts: 4
Joined: Sun Jan 13, 2013 10:02 am

Re: Compile kernel modules

Sat Feb 02, 2013 6:56 pm

But obviously I don't want to spend many hours compiling a whole new kernel and set of modules.
I want to compile a new module that is compatible with the stock Raspbian kernel.
--
Mark Himsley

User avatar
Redrobes
Posts: 80
Joined: Mon Dec 26, 2011 9:19 pm
Location: S.W. UK

Re: Compile kernel modules

Sat Feb 02, 2013 11:54 pm

My experience is that you do have to have a) a set of kernel sources which you can download and b) a Module.symvars file which is not part of the download. I read that some people have created it and uploaded one but all the links I tried failed. To get one of these files I did build the kernel but not install it. It made the file and then I was able to make the kernel module.

To get the sources many people recommend getting the git install but when I tried that I could get the depth 1 files but then it failed on the checkout of the kernel version that I wanted.

I am using raspian which for me was 3.2.27+ (Use uname -r to find out what you have running). Then I went and downloaded the sources via a tar file instead of git. I tried to download the raspi tools dir and set it up as a cross compile from ubuntu but ran into build errors that way so I used the raspi itself to compile the kernel sources of the version it was already running and it completed in about 10hrs - left on overnight.

So after that I could compile and modprobe my driver. So thats what I did but other people have said they had enormous problems compiling the kernel on the raspi. So I dunno. Its not a very clear path to take either way.

TonyInOz
Posts: 8
Joined: Tue Apr 30, 2013 10:24 am
Location: Adelaide, Australia

Re: Compile kernel modules

Tue Aug 27, 2013 11:10 am

Hi Mark,

I too have been trying to compile a Module for a TP-Link TL-WDN3200 based on the RT5572 chipset. Did you ever succeed on compiling a module? I've been trying a number of different methods and have hit a dead end.

While it would be expedient to download a compiled module for the RT5572, I'd like to learn how to compile for the Raspbian.

I'm interested to hear how you got on.

Regards
Tony
Adelaide, Australia

Anthologist
Posts: 4
Joined: Mon Feb 03, 2014 3:38 pm

Re: Compile kernel modules

Mon Feb 03, 2014 3:50 pm

Hi

I was able to finally get this working myself over the weekend.

I used Raspbian build from NOOBS (though I'm pretty sure now you don't need NOOBS for the base) along with the TP-LINK TL-WDN3200.

After install of Raspian, you need to install the kernel from raspian.org. Additional background here: http://www.eevblog.com/forum/reviews/ho ... h-headers/

Note the snippet at the post is outdated. You'll need to use the current kernel version and you'll correct entries to in /boot/config.txt if you look for kernel version in /boot.

Once you boot into the raspian.org kernel, you can go ahead and compile the driver from here: http://www.ctheroux.com/2012/09/ralink- ... ntu-12-04/

The iface will show up as wlan0 and not ra0 as stated.

Good luck!

TonyInOz
Posts: 8
Joined: Tue Apr 30, 2013 10:24 am
Location: Adelaide, Australia

Re: Compile kernel modules

Mon Feb 03, 2014 5:36 pm

Hi Anthologist,

Thanks for the posting, I'll give it a try next weekend

Regards, Tony

Anthologist
Posts: 4
Joined: Mon Feb 03, 2014 3:38 pm

Re: Compile kernel modules

Tue Feb 04, 2014 2:08 am

I'll try to sum up my step by step:
  • Install Raspian via NOOBS
  • Setup your locale, timezone, etc.
  • Enable SSH
  • Reboot
  • apt-get update
  • apt-get install linux-image-rpi-rpfv
  • Append to /boot/config.txt the version of the kernel installed. Hint: check /boot. As of this posting, you're going to append the below:

    Code: Select all

    echo "kernel=vmlinuz-3.10-3-rpi" >> /boot/config.txt 
    echo "initramfs initrd.img-3.10-3-rpi" >> /boot/config.txt 
  • Reboot
  • apt-get install linux-headers-rpi-rpfv
  • wget http://www.ctheroux.com/publicfiles/DPO ... ar.bz2.bz2
  • Extract the tarball to your choice of directory
  • cd DPO_RT5572_LinuxSTA_2.6.0.1_20120629
  • make
  • make install
  • ifconfig (you ought to see wlan0)
  • Add the below or something like the below (depends on your AP setup) to /etc/wpa_supplicant/wpa_supplicant.conf

    Code: Select all

    network={
        ssid="YOUR SSID"
        proto=RSN
        key_mgmt=WPA-PSK
        pairwise=CCMP TKIP
        group=CCMP TKIP
        psk="YOUR PSK"
    }
  • ifdown wlan0
  • ifup wlan0
And with that, you should be rockin. Don't look for the status light to be lit on the WDN3200. Mine didn't, but it definitely was connected to my AP.

Some additional notes and background:
I had the WDN3200 connected to the Pi via a powered hub (along with a usb keyboard) and did the OS install, kernel update and driver compile connected the entire time.

While the above has it setup as a wifi client, I now have the WDN3200 directly connected to the Pi (no powered hub) along with a 64GB USB Flash drive. Then I set the Pi up with HostAPD, DNSMasq and MiniDLNA so it functions as an access point and a DLNA server.

I went with the WDN3200 because it's capable of using the 5Ghz spectrum. I needed this because my Nexus 7 2013 has problems using both Bluetooth and WIFI over the 2.4Ghz spectrum.

It took me a long time to get everything completely working, cobbled together with information from various places on the great Internet and it works great now.

Hope this info helps others!
Last edited by Anthologist on Thu Feb 06, 2014 2:26 pm, edited 1 time in total.

TonyInOz
Posts: 8
Joined: Tue Apr 30, 2013 10:24 am
Location: Adelaide, Australia

Re: Compile kernel modules

Wed Feb 05, 2014 7:21 pm

Hi Anthologist,

Success!! I was able to get it working first time without any problems. Thanks for the clear and concise instructions.

FYI, I started with Raspbian Wheezy dated 7th Jan 2014.

Anthologist
Posts: 4
Joined: Mon Feb 03, 2014 3:38 pm

Re: Compile kernel modules

Thu Feb 06, 2014 2:24 pm

That's great! Congrats!

20vwld
Posts: 1
Joined: Tue Apr 15, 2014 12:56 pm

Re: Compile kernel modules

Tue Apr 15, 2014 1:39 pm

Hi Anthologist!

Thank' for your tutorial, works great for me!

You wrote, that you use it as an access point now.
I would also like to use it as an access point, i use HostApd and .isc-dhcp-server but i can't get it running!

it seems that hostAPD has a problem with the rt2800usb driver.
do you have any suggestions for me?

Anthologist
Posts: 4
Joined: Mon Feb 03, 2014 3:38 pm

Re: Compile kernel modules

Thu Apr 17, 2014 10:58 pm

Hey there,

Use nl80211 as your driver.

I don't think the ISC dhcp server will work. I recall giving it a try myself and gave up to use dnsmasq instead. I could be wrong... my memory isn't what it used to be.

Here's a snippet from my /etc/network/interfaces:

Code: Select all

allow-hotplug wlan0
auto wlan0
iface wlan0 inet static
address 192.168.1.1
netmask 255.255.255.0
Here's my full hostapd.conf:

Code: Select all

country_code=US
interface=wlan0
driver=nl80211
ssid=CHANGE_TO_YOUR_PREFERRED_SSID
auth_algs=3

wme_enabled=1
ieee80211n=1
channel=44
hw_mode=a
ht_capab=[HT40-][HT40+][SHORT-GI-40]

wpa=3
wpa_passphrase=CHANGE_TO_YOUR_PREFERRED_PASSPHRASE
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
rsn_pairwise=CCMP

macaddr_acl=0
ignore_broadcast_ssid=0

ctrl_interface=/var/run/hostapd
ctrl_interface_group=0

logger_syslog=-1
logger_syslog_level=1
Good luck!

yetanotherlogin
Posts: 1
Joined: Mon Nov 02, 2015 12:26 pm

Re: Compile kernel modules

Mon Nov 02, 2015 12:42 pm

Anthologist,

Did you use rt2800usb when using hostapd? Or rt5572sta? I built rt5572sta and installed, but when trying to run hostapd, I end up getting errors that the device doesn't exist. The default is ra0 and I am wondering if that is the issue or if I might be doing something else incorrectly.

8bitskink
Posts: 1
Joined: Sat Dec 05, 2015 8:00 am

Re: Compile kernel modules

Sat Dec 05, 2015 8:14 am

Hi,

Thanks for the great work on outlining the steps. I found that I could not compile, getting an error along the lines of "error: incompatible types when assigning to type ‘int’ from type ‘kgid_t’". Turns out there have been changes to kernel that mean this source no longer compiles.

After some digging, I found another thread discussing a similar issue. http://www.arnelborja.com/compiling-rt2 ... in-fedora/

I have no idea how to apply a patch file, but I found I only had to change two lines in /os/Linux/rt_linux.h. Open up the file and search for the following segment

Code: Select all

 typedef struct _OS_FS_INFO_
 {
	int				fsuid;
	int				fsgid;
 	mm_segment_t	fs;
 } OS_FS_INFO;
 
and change it to read

Code: Select all

typedef struct _OS_FS_INFO_
 {
	kuid_t				fsuid;
	kgid_t				fsgid;
 	mm_segment_t	fs;
 } OS_FS_INFO;
I could then compile the module and bring up my WLAN interface. :D

Return to “General discussion”