I've been trying on and off for days to build the module for my USB wireless device.

It is an Edimax EW-7811UN

I've found several resources on building modules for Debian, but none for Arch. Currently I am attempting to cross-compile using the ToolChain found on the Raspberry Pi GitHub. These are the steps I've taken:

  • Downloaded the driver sources from the Edimax website.
  • Downloaded the kernel sources from GitHub.
  • Created a specific make rule (as per the Edimax documentation) in the Edimax MakeFile:

ifeq ($(CONFIG_PLATFORM_PI), y)
  EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
  ARCH := arm
  CROSS_COMPILE := arm-bcm2708-linux-gnueabi-
  KVER  := 3.1.9-30-ARCH+
  KSRC := /pi-sources/lib/modules/3.1.9-30-ARCH+/build 
  MODDESTDIR := /pi-sources/lib/modules/3.1.9-30-ARCH+/kernel/drivers/net/wireless/
  INSTALL_PREFIX :=
endif
  • KSRC is the directory containing the kernel sources.
  • MODDESTDIR is the directory you wish the module to end up.
  • CROSS_COMPILE is my toolchain (which has been added to PATH)

First attempt at make gives this error:

fatal error: linux/smp_lock.h: No such file or directory

I found that this is an outdated header, and symlinking it to smp.h should fix the issue. However, the build still fails with source errors, that look like this:

error: field 'recv_tasklet' has incomplete type

I've done enough compiling to know this looks as if the build doesn't support the latest kernel version, but if this is so then how has it been built for Debian?


Extra information:

  • The full output here.
  • I have the same adapter, though not yet got around to trying it! – Shane Hudson Jun 13 '12 at 17:56
  • Please let me know how you get on with it and add your experience afterward, even if its negative. – Jivings Jun 13 '12 at 18:05
  • @Tomas, more bounty! Make sure Alex doesn't get it this time :) – Jivings Jul 30 '12 at 12:36
up vote 12 down vote
+250

Instructions for cross-compiling

  1. Downloaded the driver sources from the Edimax website.

  2. Clone the kernel sources from GitHub.

  3. cd into your kernel source and cd into include/linux. Run

    ln -s smp.h smp_lock.h`.
    
  4. unzip the Edimax download and tar -xzf the driver package. cd into the driver/rtl... subdirectory.

  5. Edit include/rtw_xmit.h and add #include <linux/interrupt.h> under the other includes.

  6. Edit os_dep/osdep_service.c and add

    #include <linux/semaphore.h>
    #define init_MUTEX(sem)         sema_init(sem, 1)
    

    under the other includes.

  7. Edit the Makefile adding

    ifeq ($(CONFIG_PLATFORM_PI), y)
    EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
    ARCH := arm
    CROSS_COMPILE := arm-bcm2708-linux-gnueabi-
    KVER  := 3.1.9-30-ARCH+
    KSRC := ~/pi-sources
    MODDESTDIR := ~/pi-sources/lib/modules/3.1.9-30-ARCH+/kernel/drivers/net/wireless/
    INSTALL_PREFIX :=
    endif
    

under similar sections.

  1. Assuming arm-bcm2708-linux-gnueabi-{gcc|ld} is in your path, run make CONFIG_PLATFORM_PI=y modules.

The module should now be compiled.

  • Build is successful! But where does the module get built to? So I can copy it onto the Pi. – Jivings Jul 19 '12 at 12:12
  • The root of the driver package I think. – Alex Chamberlain Jul 19 '12 at 12:19
  • 1
    Hm, seems to be there. Weird. What's the point in MODDESTDIR then? – Jivings Jul 19 '12 at 12:20
  • No idea!!!!!!!!! – Alex Chamberlain Jul 19 '12 at 12:20
  • In order to get this to build on the Raspberry Pi I also had to symlink the /lib/modules/3.1.9-30-ARCH+/build directory to the kernel sources. – Jivings Jul 24 '12 at 17:42

Try copying the config.gz from /proc/config.gz on your RPi. Then gunzip it and rename it to .config and make as above.

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

  • 3
    Can you state why this is useful in your answer? – Jivings Jul 19 '12 at 12:34

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.