# Kernel module compilation,broadcom-sta driver

## wormite

I am quite new to Gentoo, but I have used ubuntu for over 3 years, and compiled kernel several times. I installed it over last weekend, but couldn't get the Broadcom wireless card working. Since it was working with some small problems on Ubuntu, I figured there must be something I could do and did some research into it.

If you are here to help with the kernel module compilation, jump to the Conclusion part.

My card:

lspci -k

0c:00.0 Network controller: Broadcom Corporation BCM4322 802.11a/b/g/n Wireless LAN Controller (rev 01)

	Subsystem: Dell Wireless 1510 Wireless-N WLAN Mini-Card

	Kernel modules: wl

System, gentoo,x86_64.

There are 3 ways to get the card working, and since I have been playing with Dell's broadcom chipsets for 3 years, I am quite familiar with them, so I tried all of them.

References:

gentoo wiki:

http://en.gentoo-wiki.com/wiki/Dell_Latitude_E6x00#Broadcom

http://en.gentoo-wiki.com/wiki/Broadcom_43xx

According to first link, current version of wl.ko is broken, the old one 5.10.91.9.3 was the last one working.

Now I want to list what I tried the results:

1. The kernel driver support 

According to Gentoo wiki:

14e4:432b 	 103c:137f 	 Broadcom Corporation BCM4322 802.11a/b/g/n Wireless LAN Controller (rev 01) 	 Not tested 	 Not tested 

I followed the detailed instruction on:

http://linuxwireless.org/en/users/Drivers/b43

As claimed by them, it is not yet supported because there is currently nothing for 802.11n. The result turns out to be unsuccessful.

2. The ndiswrapper with windows driver.

I emerged ndiswrapper :

[ebuild  N    ] net-wireless/ndiswrapper-1.55-r1  USE="usb -debug" 0 kB

loaded various windows drivers:

a) The ndiswrapper claimed working BCM4318 's driver.

Unsuccessful.

b) Dell's driver support, both the newest version and an old one (5.10)

Unsuccessful.

Typical behavior of ndiswrapper is, once installed, and successfully listed:

```
ndiswrapper -l
```

with driver and device present.

```
modprobe ndiswrapper
```

hangs.

3. The wl.ko(net-wireless/broadcom-sta) provided by broadcom.

I have tried the newest broadcom-sta module:

[ebuild IN    ] net-wireless/broadcom-sta-5.60.48.36  0 kB

The module can turn on the wireless led, but unable to do

```
iwlist eth1 scan
```

To be specific, sometimes the scan is successful, while most of the time 

it fails with error reporting invalid argument.

I tried to compile the latest version downloaded from 

http://www.broadcom.com/support/802.11/linux_sta.php

The result is the same.

Conclusion. 

Right now I am convinced the 80211n support is poor in broadcom card. but I still haven't tried the older version of the broadcom-sta driver.

http://www.broadcom.com/docs/linux_sta/Novell/sle10sp2/x86_64/broadcom-wireless-5.10.91.9-0.src.rpm

I could not try it because I failed to compile it against my 2.6.31 kernel, with error reporting the missing net_device functions.

Steps:

a) unpacking it, copy some part from the newer version's Makefile for the module compilation

new Makefile:

```

obj-m              += wl.o

wl-objs            :=

wl-objs            += src/wl/sys/wl_linux.o

wl-objs            += src/wl/sys/wl_iw.o

wl-objs            += src/shared/linux_osl.o

EXTRA_CFLAGS       :=

EXTRA_CFLAGS       += -I$(src)/src/include

EXTRA_CFLAGS       += -I$(src)/src/wl/sys

EXTRA_LDFLAGS      := $(src)/lib/wlc_hybrid.o_shipped

all:

        KBUILD_NOPEDANTIC=1 make -C /lib/modules/`uname -r`/build M=`pwd`

clean:

        KBUILD_NOPEDANTIC=1 make -C /lib/modules/`uname -r`/build M=`pwd` clean

install:

        install -D -m 755 wl.ko /lib/modules/`uname -r`/kernel/drivers/net/wireless/wl.ko

```

Tried to compile, 

```

make

```

Compilation error:

```

/root/wireless/5.10/broadcom-wireless-5.10.91.9/src/wl/sys/wl_linux.c: In function 'wl_if_setup':

/root/wireless/5.10/broadcom-wireless-5.10.91.9/src/wl/sys/wl_linux.c:233: error: 'struct net_device' has no member named 'open'

/root/wireless/5.10/broadcom-wireless-5.10.91.9/src/wl/sys/wl_linux.c:234: error: 'struct net_device' has no member named 'stop'

/root/wireless/5.10/broadcom-wireless-5.10.91.9/src/wl/sys/wl_linux.c:235: error: 'struct net_device' has no member named 'hard_start_xmit'

/root/wireless/5.10/broadcom-wireless-5.10.91.9/src/wl/sys/wl_linux.c:236: error: 'struct net_device' has no member named 'get_stats'

```

I tracked this down and it seems to be the net_device being ill defined somewhere, possibly:

```

broadcom-wireless-5.10.91.9 # vim src/include/linuxver.h

```

I compared this file with the newer version, copied most of the part I deem reasonable, but still couldn't solve the problem, any ideas?

A minor problem is, what's the meaning of :

```

KBUILD_NOPEDANTIC=1 make

```

and its M=`pwd` doing?

----------

## wormite

I found this:

http://www.virtualbox.org/ticket/4264

According to Vbox people, net_device is gone starting from 2.6.31. I think I need to redefine it somewhere.

----------

## wormite

I have successfully patched the 5.10 driver module for 2.6.31 kernel, with modifications regarding wl_iw.c wl_linux.c wl_iw.h wl_linux.h  including/linuxver.h. Most of the fixes are around net_device being changed. Minor ones are for kernel. 

  With the home grown kernel module I can insert it, run it, and iwlist scan works. But the wpa_supplicant still can not lock down on my home router. And iwlist fails at about 10% chance with iwlist scan. At this moment I have tried all that I could, waiting for further update from broadcom. 

  And sticking to Ubuntu for wireless.

  I hope someone else is working on this problem... Otherwise I'm gonna change my wireless card.

----------

## pavel_prochazka

Having the same problem. Has anybody found a solution or a forum (tutorial) concerning this topic? 

Thanks Pavel

----------

## DaggyStyle

having an older broadcom card, I've used both the sta and ndis module till not to long when loading either modules resulted in module crash. although the kernel b43 module never worked for me and the site states it's doesn't supports my card I've gave it a try, now I have wireless working.

maybe it will work for you guys too.

edit: also, try newer kernel.

----------

## wormite

what do you mean by newer kernel?

Please give a kernel version range or example...

----------

## DaggyStyle

 *wormite wrote:*   

> what do you mean by newer kernel?
> 
> Please give a kernel version range or example...

 

2.6.33-34

----------

