# rtl8187 fails building (kernel 2.6.18) - analysis,workaround

## wu-s

Hi gentoo forum,

this is an analysis of https://forums.gentoo.org/viewtopic-t-492479-highlight-rtl8187.html. I had the same problem with the unresolved symbols and finally managed to get a transitional solution. I don´t know if it is an amd64 issue.

Cause of the unresolved symbols:

The module r8187.ko is build in the directory beta-8187/ and needs some symbols of the module ieee80211, which is build in the directory iee80211/. Neither the code in beta-8187/ uses the function "request_module(...)" or the Makefile in beta-8187/ is considering that situation. Apparently the kbuild-system in kernel 2.6.18 does not like that.

Is anyone familiar with Makefiles for kernel modules? Should we link in the functions from the objects in ieee80211/ or use "request_module(..)" in beta-8187/? Where are the kernel-hackers out there? How should that be done correctly?

Hack to get the driver compiled:

Copy all the code and headers from beta-8187/ and ieee80211/ into a single directory and use that Makefile:

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

EXTRA_CFLAGS += -std=gnu89

EXTRA_CFLAGS += -O2

EXTRA_CFLAGS += -mhard-float -DCONFIG_FORCE_HARD_FLOAT=y

ieee80211-rtl-objs := ieee80211_softmac.o ieee80211_rx.o ieee80211_tx.o ieee80211_wx.o ieee80211_module.o ieee80211_softmac_wx.o

ieee80211_crypt-rtl-objs := ieee80211_crypt.o

ieee80211_crypt_tkip-rtl-objs := ieee80211_crypt_tkip.o

ieee80211_crypt_ccmp-rtl-objs := ieee80211_crypt_ccmp.o

ieee80211_crypt_wep-rtl-objs := ieee80211_crypt_wep.o

r8187-objs := r8187_core.o r8180_93cx6.o r8180_wx.o r8180_rtl8225.o r8180_rtl8225z2.o

obj-m +=r8187.o

obj-m +=ieee80211-rtl.o

obj-m +=ieee80211_crypt-rtl.o

obj-m +=ieee80211_crypt_wep-rtl.o

obj-m +=ieee80211_crypt_tkip-rtl.o

obj-m +=ieee80211_crypt_ccmp-rtl.o

KVER  := $(shell uname -r)

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

INSTALL_PREFIX :=

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

all: modules

clean:

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

        rm -rf $(PWD)/tmp

modules:

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

install: modules

        mkdir -p $(MODDESTDIR)

        install -p -m 644 r8187.ko ieee80211-rtl.ko ieee80211_crypt-rtl.ko ieee80211_crypt_wep-rtl.ko ieee80211_crypt_tkip-rtl.ko ieee80211_crypt_ccmp-rtl.ko $(MODDESTDIR)
```

A final modification to resolve dependency correctly:

Another three lines need a modifiaction to resolve the dependency to our modified ieee80211-stack. Make sure the following lines look like this:

```
ieee80211_softmac.c:2426:               request_module("ieee80211_crypt_wep-rtl");

ieee80211_wx.c:331:                     request_module("ieee80211_crypt_wep-rtl");

ieee80211_wx.c:343:                            "load module ieee80211_crypt_wep-rtl\n",
```

Would be nice if we can get r8187 working out of the box. The driver is used for the wifi-module on Asus P5B-Deluxe WiFi-Edition, e.g.

Cheers,

SvenLast edited by wu-s on Tue Oct 17, 2006 11:31 pm; edited 1 time in total

----------

## wu-s

Ok, this is working somehow. But I would be very pleased it someone can confirm.

Unpack:

```
# ebuild /usr/portage/net-wireless/rtl8187/rtl8187-1.10.ebuild unpack

 * rtl8187-1.10.zip MD5 ;-) ...                                                                      [ ok ]

 * rtl8187-1.10.zip size ;-) ...                                                                     [ ok ]

 * checking ebuild checksums ;-) ...                                                                 [ ok ]

 * checking auxfile checksums ;-) ...                                                                [ ok ]

 * checking miscfile checksums ;-) ...                                                               [ ok ]

 * checking rtl8187-1.10.zip ;-) ...                                                                 [ ok ]

 * Determining the location of the kernel source code

 * Found kernel source directory:

 *     /usr/src/linux

 * Found sources for kernel version:

 *     2.6.18-suspend2

>>> Unpacking source...

>>> Unpacking rtl8187-1.10.zip to /var/tmp/portage/rtl8187-1.10/work

 * Applying module-param-and-isoc.patch ...                                                          [ ok ]

>>> Source unpacked.
```

Use the following Makefile in /var/tmp/portage/rtl8187-1.10/work/rtl8187_linuxdrv_V1.1:

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

EXTRA_CFLAGS += -O2

KVER  := $(shell uname -r)

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

INSTALL_PREFIX :=

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

obj-m   :=  beta-8187/ ieee80211/

all: modules

clean:

        cd $(PWD)/beta-8187

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

        cd $(PWD)/ieee80211/

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

        rm -rf $(PWD)/tmp

modules:

        $(MAKE) -C $(KSRC) SUBDIRS=$(PWD) modules

install:

        mkdir -p $(MODDESTDIR)

        install -p -m 644 beta-8187/r8187.ko \

                ieee80211/ieee80211-rtl.ko ieee80211/ieee80211_crypt-rtl.ko \

                ieee80211/ieee80211_crypt_wep-rtl.ko ieee80211/ieee80211_crypt_tkip-rtl.ko \

                ieee80211/ieee80211_crypt_ccmp-rtl.ko $(MODDESTDIR)

```

Makefile for /var/tmp/portage/rtl8187-1.10/work/rtl8187_linuxdrv_V1.1/beta-8187:

```
EXTRA_CFLAGS += -std=gnu89

EXTRA_CFLAGS += -mhard-float -DCONFIG_FORCE_HARD_FLOAT=y

r8187-objs := r8187_core.o r8180_93cx6.o r8180_wx.o r8180_rtl8225.o r8180_rtl8225z2.o

obj-m := r8187.o

all: modules

modules:

        $(MAKE) -C $(KSRC) SUBDIRS=$(PWD) M=$(PWD) modules
```

Makefile for /var/tmp/portage/rtl8187-1.10/work/rtl8187_linuxdrv_V1.1/ieee80211:

```
ieee80211-rtl-objs := ieee80211_softmac.o ieee80211_rx.o ieee80211_tx.o ieee80211_wx.o ieee80211_module.o ieee80211_softmac_wx.o

ieee80211_crypt-rtl-objs := ieee80211_crypt.o

ieee80211_crypt_tkip-rtl-objs := ieee80211_crypt_tkip.o

ieee80211_crypt_ccmp-rtl-objs := ieee80211_crypt_ccmp.o

ieee80211_crypt_wep-rtl-objs := ieee80211_crypt_wep.o

obj-m +=ieee80211-rtl.o

obj-m +=ieee80211_crypt-rtl.o

obj-m +=ieee80211_crypt_wep-rtl.o

obj-m +=ieee80211_crypt_tkip-rtl.o

obj-m +=ieee80211_crypt_ccmp-rtl.o

all: modules

modules:

        $(MAKE) -C $(KSRC) SUBDIRS=$(PWD) M=$(PWD) modules
```

As already said, it seems to be working, but is it a correct way to do it? How can we integrate it to the .ebuild? As an additional patch? Can we inform the ebuild-maintainer?

Don´t forget to patch ieee80211/ieee80211_softmac.c and ieee80211/ieee80211_wx.c as described in the last post.

Cheers,

Sven

----------

## wu-s

The Makefiles posted seem to be not right 100%, but working. Check http://kernelnewbies.org/FAQ/LinuxKernelModuleCompile for the minor corrections. I think you got the idea.

----------

## wu-s

OK, here the service to do copy-and-paste:

Use the following Makefile in /var/tmp/portage/rtl8187-1.10/work/rtl8187_linuxdrv_V1.1:

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

EXTRA_CFLAGS += -O2

KVER  := $(shell uname -r)

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

INSTALL_PREFIX :=

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

#ifneq ($(KERNELRELEASE),)

obj-m   :=  beta-8187/ ieee80211/

#else

all: modules

clean:

        $(MAKE) -C $(KSRC) M=$(PWD) clean

modules:

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

install:

        mkdir -p $(MODDESTDIR)

        install -p -m 644 beta-8187/r8187.ko \

                ieee80211/ieee80211-rtl.ko \

                ieee80211/ieee80211_crypt-rtl.ko \

                ieee80211/ieee80211_crypt_wep-rtl.ko \

                ieee80211/ieee80211_crypt_tkip-rtl.ko \

                ieee80211/ieee80211_crypt_ccmp-rtl.ko $(MODDESTDIR)

#endif

```

Makefile for /var/tmp/portage/rtl8187-1.10/work/rtl8187_linuxdrv_V1.1/beta-8187:

```
EXTRA_CFLAGS += -std=gnu89

EXTRA_CFLAGS += -mhard-float -DCONFIG_FORCE_HARD_FLOAT=y

r8187-objs := r8187_core.o r8180_93cx6.o r8180_wx.o r8180_rtl8225.o r8180_rtl8225z2.o

obj-m := r8187.o

all: modules

modules:

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

clean:

        $(MAKE) -C $(KSRC) M=$(PWD) clean

```

Makefile for /var/tmp/portage/rtl8187-1.10/work/rtl8187_linuxdrv_V1.1/ieee80211:

```
ieee80211-rtl-objs := ieee80211_softmac.o ieee80211_rx.o ieee80211_tx.o ieee80211_wx.o ieee80211_module.o ieee80211_softmac_wx.o

ieee80211_crypt-rtl-objs := ieee80211_crypt.o

ieee80211_crypt_tkip-rtl-objs := ieee80211_crypt_tkip.o

ieee80211_crypt_ccmp-rtl-objs := ieee80211_crypt_ccmp.o

ieee80211_crypt_wep-rtl-objs := ieee80211_crypt_wep.o

obj-m +=ieee80211-rtl.o

obj-m +=ieee80211_crypt-rtl.o

obj-m +=ieee80211_crypt_wep-rtl.o

obj-m +=ieee80211_crypt_tkip-rtl.o

obj-m +=ieee80211_crypt_ccmp-rtl.o

all: modules

modules:

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

clean:

        $(MAKE) -C $(KSRC) M=$(PWD) clean

```

"make" and "make install" in /var/tmp/portage/rtl8187-1.10/work/rtl8187_linuxdrv_V1.1 don't forget to run "depmod -ae".

i linked this thread with https://bugs.gentoo.org/show_bug.cgi?id=143103.

cheers,

sven

----------

## l_bratch

Thanks for the info, this works fine for me.

kernel: 2.6.18-gentoo-r2

lsusb of card: 0bda:8187 Realtek Semiconductor Corp.

I thought it wasn't working again, but it turns out I had to set the bitrate manually (unlike with other drivers I've used):

iwconfig wlan0 rate 11M

It was setting itself to 54Mb/s, but my AP only supports 11Mb/s.

Edit:

Forgot to mention that's an x86_64 kernel.

----------

