You are not logged in.

#1 2016-07-24 12:46:24

Fulvio
Member
From: Italy
Registered: 2016-07-24
Posts: 12

Building driver for Wi-Fi Broadcom 4320 (rev 03) card

Hello World! I am a newbie.

I am throughly following the instructions contained in this file: https://www.broadcom.com/docs/linux_sta … 23.248.txt, my PC is a 32 bit one, as you have likely already understood; but when I arrive at the point: "BUILD INSTRUCTIONS > 2. Build the driver as a Linux loadable kernel module (LKM):" when I execute the command "make" I obtain the following error messages:

KBUILD_NOPEDANTIC=1 make -C /lib/modules/`uname -r`/build M=`pwd`
make[1]: Entering directory '/user/lib/modules/4.6.4-1-ARCH/build'
make[1]: *** No targets specified and no makefile found. Stop.
make[1]: Leaving directory '/user/lib/modules/4.6.4-1-ARCH/build'
make: *** [Makefile:159: all] Error 2

What should I do to succed in building that driver? On that PC I can build the Linux kernel without receiving any error message. Please answer me even to just say that it is a too much difficult issue to solve. Thanks a lot.

Last edited by Fulvio (2016-07-24 14:16:55)

Offline

#2 2016-07-24 12:50:32

Awebb
Member
Registered: 2010-05-06
Posts: 6,285

Re: Building driver for Wi-Fi Broadcom 4320 (rev 03) card

You could look up how it is being solved in other broadcom packages on the AUR, for example: https://aur.archlinux.org/packages/broadcom-wl/

I'd generally refrain from building such things manually and write a PKGBUILD. Read the respective wiki article and then read the PKGBUILDs of some broadcom AUR packages.

Offline

#3 2016-07-24 12:57:16

Gusar
Member
Registered: 2009-08-25
Posts: 3,605

Re: Building driver for Wi-Fi Broadcom 4320 (rev 03) card

Assuming that by Broadcom 4320 you mean the BCM4306/3 with the pci-id 14e4:4320, you don't need to build any driver for that thing. Just install b43-firmware from AUR and the b43 driver will work.

Last edited by Gusar (2016-07-24 12:57:53)

Offline

#4 2016-07-24 13:48:04

Fulvio
Member
From: Italy
Registered: 2016-07-24
Posts: 12

Re: Building driver for Wi-Fi Broadcom 4320 (rev 03) card

Thanks Awebb. I downloaded the broadcom-wl file, I executed tar xzf on it and then I launched the "makepkg -i" command, but the building has aborted and these are the last messages that I got before the aborting:

==> Starting build()...
make: Entering directory '/usr/lib/modules/4.6.4-1-ARCH/build'
CFG80211 API is prefered for this kernel version
Using CFG80211 API
  LD      /home/all/Documents/Deposito/Broadcom_wl/broadcom-wl/src/built-in.o
  CC [M]  /home/all/Documents/Deposito/Broadcom_wl/broadcom-wl/src/src/shared/linux_osl.o
/home/all/Documents/Deposito/Broadcom_wl/broadcom-wl/src/src/shared/linux_osl.c: In function 'osl_getcycles':
/home/all/Documents/Deposito/Broadcom_wl/broadcom-wl/src/src/shared/linux_osl.c:935:2: error: implicit declaration of function 'rdtscl' [-Werror=implicit-function-declaration]
  rdtscl(cycles);
  ^~~~~~
/home/all/Documents/Deposito/Broadcom_wl/broadcom-wl/src/src/shared/linux_osl.c:935:2: warning: 'cycles' is used uninitialized in this function [-Wuninitialize]  rdtscl(cycles);
  ^~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[1]: *** [scripts/Makefile.build:292: /home/all/Documents/Deposito/Broadcom_wl/broadcom-wl/src/src/shared/linux_osl.o] Error 1
make: *** [Makefile:1429: _module_/home/all/Documents/Deposito/Broadcom_wl/broadcom-wl/src] Error 2
make: Leaving directory '/usr/lib/modules/4.6.4-1-ARCH/build'
==> ERROR: A failure occurred in build().
    Aborting...

How could I solve this issue?

Thanks Gusar, that is my PC Wi-Fi card; but when I try to install the b43-firmware using the command "sudo pacman -S b43-firmware" I get the "error: target not found: b43-firmware".

Last edited by Fulvio (2016-07-24 14:17:26)

Offline

#5 2016-07-24 14:46:24

Pyntux
Member
From: Serbia
Registered: 2008-12-21
Posts: 391

Re: Building driver for Wi-Fi Broadcom 4320 (rev 03) card

That is because that package is in AUR...


I do not speak English, but I understand...

Offline

#6 2016-07-24 14:56:03

loqs
Member
Registered: 2014-03-06
Posts: 17,318

Re: Building driver for Wi-Fi Broadcom 4320 (rev 03) card

$ git clone https://aur.archlinux.org/broadcom-wl.git
Cloning into 'broadcom-wl'...
remote: Counting objects: 38, done.
remote: Compressing objects: 100% (34/34), done.
remote: Total 38 (delta 12), reused 21 (delta 3)
Unpacking objects: 100% (38/38), done.
Checking connectivity... done.
$ cd broadcom-wl/
$ makepkg
==> Making package: broadcom-wl 6.30.223.271-3 (Sun 24 Jul 15:52:45 BST 2016)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Found modprobe.d
  -> Found license.patch
  -> Found wl_linux.c.patch
  -> Found linux47.patch
  -> Downloading hybrid-v35_64-nodebug-pcoem-6_30_223_271.tar.gz...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 2859k  100 2859k    0     0   865k      0  0:00:03  0:00:03 --:--:--  865k
==> Validating source files with sha256sums...
    modprobe.d ... Passed
    license.patch ... Passed
    wl_linux.c.patch ... Passed
    linux47.patch ... Passed
==> Validating source_x86_64 files with sha256sums...
    hybrid-v35_64-nodebug-pcoem-6_30_223_271.tar.gz ... Passed
==> Extracting sources...
  -> Extracting hybrid-v35_64-nodebug-pcoem-6_30_223_271.tar.gz with bsdtar
==> Starting prepare()...
patching file src/wl/sys/wl_linux.c
Hunk #1 succeeded at 207 (offset 2 lines).
patching file src/wl/sys/wl_linux.c
patching file src/wl/sys/wl_cfg80211_hybrid.c
==> Starting build()...
make: Entering directory '/usr/lib/modules/4.6.4-1-ARCH/build'
CFG80211 API is prefered for this kernel version
Using CFG80211 API
  LD      /tmp/broadcom-wl/src/built-in.o
  CC [M]  /tmp/broadcom-wl/src/src/wl/sys/wl_linux.o
  CC [M]  /tmp/broadcom-wl/src/src/shared/linux_osl.o
  CC [M]  /tmp/broadcom-wl/src/src/wl/sys/wl_iw.o
  CC [M]  /tmp/broadcom-wl/src/src/wl/sys/wl_cfg80211_hybrid.o
/tmp/broadcom-wl/src/src/wl/sys/wl_linux.c: In function ‘wl_pci_probe’:
/tmp/broadcom-wl/src/src/wl/sys/wl_linux.c:773:2: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
  if ((val & 0x0000ff00) != 0)
  ^~
/tmp/broadcom-wl/src/src/wl/sys/wl_linux.c:775:3: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
   bar1_size = pci_resource_len(pdev, 2);
   ^~~~~~~~~
/tmp/broadcom-wl/src/src/wl/sys/wl_cfg80211_hybrid.c: In function ‘wl_ch_to_chanspec’:
/tmp/broadcom-wl/src/src/wl/sys/wl_cfg80211_hybrid.c:2253:18: warning: comparison between ‘enum ieee80211_band’ and ‘enum nl80211_band’ [-Wenum-compare]
   if (chan->band == NL80211_BAND_2GHZ) {
                  ^~
/tmp/broadcom-wl/src/src/wl/sys/wl_cfg80211_hybrid.c:2256:23: warning: comparison between ‘enum ieee80211_band’ and ‘enum nl80211_band’ [-Wenum-compare]
   else if (chan->band == NL80211_BAND_5GHZ) {
                       ^~
  LD [M]  /tmp/broadcom-wl/src/wl.o
  Building modules, stage 2.
CFG80211 API is prefered for this kernel version
Using CFG80211 API
  MODPOST 1 modules
  CC      /tmp/broadcom-wl/src/wl.mod.o
  LD [M]  /tmp/broadcom-wl/src/wl.ko
make: Leaving directory '/usr/lib/modules/4.6.4-1-ARCH/build'
==> Entering fakeroot environment...
==> Starting package()...
==> Tidying install...
  -> Removing libtool files...
  -> Purging unwanted files...
  -> Removing static library files...
  -> Stripping unneeded symbols from binaries and libraries...
  -> Compressing man and info pages...
==> Checking for packaging issue...
==> Creating package "broadcom-wl"...
  -> Generating .PKGINFO file...
  -> Generating .BUILDINFO file...
  -> Adding install file...
  -> Generating .MTREE file...
  -> Compressing package...
==> Leaving fakeroot environment.
==> Finished making: broadcom-wl 6.30.223.271-3 (Sun 24 Jul 15:52:51 BST 2016)

Edit:
Also checked the snapshot from aur

$ wget https://aur.archlinux.org/cgit/aur.git/snapshot/broadcom-wl.tar.gz
--2016-07-24 16:27:55--  https://aur.archlinux.org/cgit/aur.git/snapshot/broadcom-wl.tar.gz
Resolving aur.archlinux.org (aur.archlinux.org)... 5.9.250.164, 2a01:4f8:160:3033::2
Connecting to aur.archlinux.org (aur.archlinux.org)|5.9.250.164|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/x-gzip]
Saving to: ‘broadcom-wl.tar.gz’

broadcom-wl.tar.gz      [ <=>                ]   3.36K  --.-KB/s    in 0s      

2016-07-24 16:27:56 (371 MB/s) - ‘broadcom-wl.tar.gz’ saved [3445]

$ tar -xf broadcom-wl.tar.gz 
$ cd broadcom-wl/
$ makepkg
==> Making package: broadcom-wl 6.30.223.271-3 (Sun 24 Jul 16:28:44 BST 2016)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Found modprobe.d
  -> Found license.patch
  -> Found wl_linux.c.patch
  -> Found linux47.patch
  -> Downloading hybrid-v35_64-nodebug-pcoem-6_30_223_271.tar.gz...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 2859k  100 2859k    0     0   263k      0  0:00:10  0:00:10 --:--:--  295k
==> Validating source files with sha256sums...
    modprobe.d ... Passed
    license.patch ... Passed
    wl_linux.c.patch ... Passed
    linux47.patch ... Passed
==> Validating source_x86_64 files with sha256sums...
    hybrid-v35_64-nodebug-pcoem-6_30_223_271.tar.gz ... Passed
==> Extracting sources...
  -> Extracting hybrid-v35_64-nodebug-pcoem-6_30_223_271.tar.gz with bsdtar
==> Starting prepare()...
patching file src/wl/sys/wl_linux.c
Hunk #1 succeeded at 207 (offset 2 lines).
patching file src/wl/sys/wl_linux.c
patching file src/wl/sys/wl_cfg80211_hybrid.c
==> Starting build()...
make: Entering directory '/usr/lib/modules/4.6.4-1-ARCH/build'
CFG80211 API is prefered for this kernel version
Using CFG80211 API
  LD      /tmp/broadcom-wl/src/built-in.o
  CC [M]  /tmp/broadcom-wl/src/src/wl/sys/wl_linux.o
  CC [M]  /tmp/broadcom-wl/src/src/shared/linux_osl.o
  CC [M]  /tmp/broadcom-wl/src/src/wl/sys/wl_iw.o
  CC [M]  /tmp/broadcom-wl/src/src/wl/sys/wl_cfg80211_hybrid.o
/tmp/broadcom-wl/src/src/wl/sys/wl_linux.c: In function ‘wl_pci_probe’:
/tmp/broadcom-wl/src/src/wl/sys/wl_linux.c:773:2: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
  if ((val & 0x0000ff00) != 0)
  ^~
/tmp/broadcom-wl/src/src/wl/sys/wl_linux.c:775:3: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
   bar1_size = pci_resource_len(pdev, 2);
   ^~~~~~~~~
/tmp/broadcom-wl/src/src/wl/sys/wl_cfg80211_hybrid.c: In function ‘wl_ch_to_chanspec’:
/tmp/broadcom-wl/src/src/wl/sys/wl_cfg80211_hybrid.c:2253:18: warning: comparison between ‘enum ieee80211_band’ and ‘enum nl80211_band’ [-Wenum-compare]
   if (chan->band == NL80211_BAND_2GHZ) {
                  ^~
/tmp/broadcom-wl/src/src/wl/sys/wl_cfg80211_hybrid.c:2256:23: warning: comparison between ‘enum ieee80211_band’ and ‘enum nl80211_band’ [-Wenum-compare]
   else if (chan->band == NL80211_BAND_5GHZ) {
                       ^~
  LD [M]  /tmp/broadcom-wl/src/wl.o
  Building modules, stage 2.
CFG80211 API is prefered for this kernel version
Using CFG80211 API
  MODPOST 1 modules
  CC      /tmp/broadcom-wl/src/wl.mod.o
  LD [M]  /tmp/broadcom-wl/src/wl.ko
make: Leaving directory '/usr/lib/modules/4.6.4-1-ARCH/build'
==> Entering fakeroot environment...
==> Starting package()...
==> Tidying install...
  -> Removing libtool files...
  -> Purging unwanted files...
  -> Removing static library files...
  -> Stripping unneeded symbols from binaries and libraries...
  -> Compressing man and info pages...
==> Checking for packaging issue...
==> Creating package "broadcom-wl"...
  -> Generating .PKGINFO file...
  -> Generating .BUILDINFO file...
  -> Adding install file...
  -> Generating .MTREE file...
  -> Compressing package...
==> Leaving fakeroot environment.
==> Finished making: broadcom-wl 6.30.223.271-3 (Sun 24 Jul 16:28:58 BST 2016)

Last edited by loqs (2016-07-24 15:31:45)

Offline

#7 2016-07-24 15:42:15

Fulvio
Member
From: Italy
Registered: 2016-07-24
Posts: 12

Re: Building driver for Wi-Fi Broadcom 4320 (rev 03) card

Thanks loqs; but that worked for you because you build the 64 bit driver. Following your indications I got the same error that I got before.

So it appears to me that there is a problem with the declaration of the function rdtscl(cycles) at the row 935 of the file ./src/src/shared/linux_osl.c that needs to be corrected. I am looking if I can correct that.

Last edited by Fulvio (2016-07-24 15:43:00)

Offline

#8 2016-07-24 15:58:18

loqs
Member
Registered: 2014-03-06
Posts: 17,318

Re: Building driver for Wi-Fi Broadcom 4320 (rev 03) card

Fulvio wrote:

So it appears to me that there is a problem with the declaration of the function rdtscl(cycles) at the row 935 of the file ./src/src/shared/linux_osl.c that needs to be corrected. I am looking if I can correct that.

Sorry missed that you are on i386.  This seems to be a fix for the same issue.
http://disq.us/p/17n512q

#if defined(__i386__) 
#if defined rdtscl 
    rdtscl(cycles); 
#else 
    cycles = rdtsc(); 
#endif 
#else 
    cycles = 0; 
#endif

If that works you might want to raise the issue with the aur package maintainer.
Edit:
https://git.kernel.org/cgit/linux/kerne … 820453293a
This appears to be the removal commit from the 4.3 merge window.

Last edited by loqs (2016-07-24 17:25:13)

Offline

#9 2016-07-24 20:56:58

Fulvio
Member
From: Italy
Registered: 2016-07-24
Posts: 12

Re: Building driver for Wi-Fi Broadcom 4320 (rev 03) card

So it seems that I need an Arch Linux version with a kernel earlier then 4.3; but unfortunately it appears that is no longer available. So the only solution for me is to switch to another Linux distribution. Thank you.

Offline

#10 2016-07-24 21:23:07

loqs
Member
Registered: 2014-03-06
Posts: 17,318

Re: Building driver for Wi-Fi Broadcom 4320 (rev 03) card

Fulvio wrote:

So it seems that I need an Arch Linux version with a kernel earlier then 4.3; but unfortunately it appears that is no longer available. So the only solution for me is to switch to another Linux distribution. Thank you.

No but you will have to patch the driver so that it does not use rdtscl.  One possible patch I referenced before another would be something like the following ( untested )

#if defined(__i386__) 
#if defined rdtscl 
    rdtscl(cycles); 
#else 
    cycles = (u32)native_read_tsc();
#endif 
#else 
    cycles = 0; 
#endif

Or follow Gusar's advice in post #3 and use b43-firmware from aur.

Offline

#11 2016-07-24 21:40:19

Fulvio
Member
From: Italy
Registered: 2016-07-24
Posts: 12

Re: Building driver for Wi-Fi Broadcom 4320 (rev 03) card

Thank you a lot, but the solution proposed with that code is not a good solution, it just allows you to build the driver, but then you are sure that there is a bug in your driver. The b43-firmware is no longer available. Anyway, to find a light Linux distribution with the kernel prior than 4.3 is revealing hard.

Last edited by Fulvio (2016-07-24 21:42:52)

Offline

#12 2016-07-25 07:44:22

loqs
Member
Registered: 2014-03-06
Posts: 17,318

Re: Building driver for Wi-Fi Broadcom 4320 (rev 03) card

Fulvio wrote:

Thank you a lot, but the solution proposed with that code is not a good solution, it just allows you to build the driver, but then you are sure that there is a bug in your driver.

How is there a bug remaining in the driver?
That is the code that was in the kernel that was removed in the 4.3 cycle

#define rdtscl(low)						\
	((low) = (u32)native_read_tsc())

A macro named rdtscl that calls native_read_tsc and casts the result to u32.
How is replacing the use of the removed macro with the exact code it implemented a bug?
How is replacing the use of the macro with any code that provides the same functionality a bug?

Fulvio wrote:

The b43-firmware is no longer available.

https://aur.archlinux.org/packages/b43-firmware
Edit:
commit to broadcom-wl-ck including a fix for the issue
https://aur.archlinux.org/cgit/aur.git/ … 803ba9a797

Last edited by loqs (2016-07-25 13:34:19)

Offline

#13 2016-07-25 12:36:08

Gusar
Member
Registered: 2009-08-25
Posts: 3,605

Re: Building driver for Wi-Fi Broadcom 4320 (rev 03) card

Fulvio wrote:

The b43-firmware is no longer available.

It is. Learn to use AUR.

Offline

#14 2016-07-28 15:55:38

Fulvio
Member
From: Italy
Registered: 2016-07-24
Posts: 12

Re: Building driver for Wi-Fi Broadcom 4320 (rev 03) card

loqs wrote:
Fulvio wrote:

Thank you a lot, but the solution proposed with that code is not a good solution, it just allows you to build the driver, but then you are sure that there is a bug in your driver.

How is there a bug remaining in the driver?
That is the code that was in the kernel that was removed in the 4.3 cycle

#define rdtscl(low)						\
	((low) = (u32)native_read_tsc())

A macro named rdtscl that calls native_read_tsc and casts the result to u32.
How is replacing the use of the removed macro with the exact code it implemented a bug?
How is replacing the use of the macro with any code that provides the same functionality a bug?

Fulvio wrote:

The b43-firmware is no longer available.

https://aur.archlinux.org/packages/b43-firmware
Edit:
commit to broadcom-wl-ck including a fix for the issue
https://aur.archlinux.org/cgit/aur.git/ … 803ba9a797

Thank you very much loqs; but I tried to install the broadcom-wl-ck package and I got the error:

cat: /usr/lib/modules/extramodules-4.3-ck/version: not existing file or directory

and also the error:

==> Missing dependencies:
  -> linux-ck-headers>=4.3
  -> linux-ck-headers<4.4
==> Impossible to solve all the dependencies.

I translated these messages in English from my own language, because I get the error messages in my own language, so the actual messages in English could be different.

Before I installed the b43-firmware package, and my Wi-Fi card worked with it, but it appears to me that it connects at a speed no higher than 11 Mbit/s while it is 54 Mbit/s capable, and moreover the card enters in stadby mode after few seconds, perhaps 5 or 10 seconds, but this issue could be caused by the error message:

MP-BIOS bug 8254 timer not connected to io-apic

that I get when Linux starts.

It also does not make sense checking if >=4.3 or <4.4, I think it should be >=4.3 or <4.3, or better checking only if >=4.3.

Last edited by Fulvio (2016-07-28 16:07:20)

Offline

#15 2016-07-28 17:09:43

loqs
Member
Registered: 2014-03-06
Posts: 17,318

Re: Building driver for Wi-Fi Broadcom 4320 (rev 03) card

Fulvio wrote:

That link was to show you that the broadcom-wl-ck package which is for the linuc-ck kernel applied a variant of the patch I was suggesting.

Thank you very much loqs; but I tried to install the broadcom-wl-ck package and I got the error:

cat: /usr/lib/modules/extramodules-4.3-ck/version: not existing file or directory

and also the error:

==> Missing dependencies:
  -> linux-ck-headers>=4.3
  -> linux-ck-headers<4.4
==> Impossible to solve all the dependencies.

It also does not make sense checking if >=4.3 or <4.4, I think it should be >=4.3 or <4.3, or better checking only if >=4.3.

If you had linux-ck-headers version 4.3 installed that would satisfy both the above dependancies (note this is not a suggestion you should switch to the ck kernel).
Checking for only >= 4.3 would allow 4.4,4.5,4.6,4.7 etc even if that package is targetted at just 4.3
The first fix I suggested you try in post #8 was

#if defined(__i386__) 
#if defined rdtscl 
    rdtscl(cycles); 
#else 
    cycles = (u32)native_read_tsc();
#endif 
#else 
    cycles = 0; 
#endif

This could be used either by editing the file src/shared/linux_osl.c or by Creating a Patch

--- a/src/shared/linux_osl.c	2016-07-28 17:23:25.816052639 +0100
+++ b/src/shared/linux_osl.c	2016-07-28 18:04:56.044389761 +0100
@@ -932,8 +932,12 @@
 	uint cycles;
 
 #if defined(__i386__)
+#if defined rdtscl 
 	rdtscl(cycles);
 #else
+    cycles = rdtsc(); 
+#endif 
+#else 
 	cycles = 0;
 #endif 
 	return cycles;

A similar patch could be generated for the fix in post #10.  The link in post #12 to the commit for broadcom-wl-ck would take a bit more work to convert to a patch.
Applying_patches covers how you then use the patch.

The fix can I believe be simplified to

#if defined(__i386__) 
    cycles = (u32)rdtsc();  
#else 
    cycles = 0; 
#endif 

Which gives the following patch

--- a/src/shared/linux_osl.c	2016-07-28 17:23:25.816052639 +0100
+++ b/src/shared/linux_osl.c	2016-07-28 17:47:48.803485538 +0100
@@ -932,7 +932,7 @@
 	uint cycles;
 
 #if defined(__i386__)
-	rdtscl(cycles);
+    cycles = (u32)rdtsc();  
 #else
 	cycles = 0;
 #endif

Edit:
Fix spelling in not ub

Last edited by loqs (2016-07-28 17:10:58)

Offline

Board footer

Powered by FluxBB