# [SOLVED] Cannot get broadcom-sta to compile

## mconnolly

Hello,

I am attempting to get the broadcom-sta driver to compile so that I may use the built-in wireless on my laptop as opposed to using USB tethering on my phone (which is currently the only solution that is working for me).

Here are the various outputs that portage recommends for support (please let me know if I should provide more information!)

```
➜  ~  emerge --info '=net-wireless/broadcom-sta-6.30.223.248-r1::gentoo'

Portage 2.2.14 (python 2.7.8-final-0, default/linux/amd64/13.0/desktop/gnome/systemd, gcc-4.9.2, glibc-2.19-r1, 3.17.2-gentoo x86_64)

=================================================================

                         System Settings

=================================================================

System uname: Linux-3.17.2-gentoo-x86_64-Intel-R-_Core-TM-_i7-4960HQ_CPU_@_2.60GHz-with-gentoo-2.2

KiB Mem:    16354396 total,  10289948 free

KiB Swap:          0 total,         0 free

Timestamp of tree: Sat, 01 Nov 2014 14:00:01 +0000

ld GNU ld (Gentoo 2.24 p1.4) 2.24

app-shells/bash:          4.3_p30

dev-lang/perl:            5.20.1-r2

dev-lang/python:          2.7.8, 3.3.5-r1, 3.4.1

dev-util/cmake:           3.0.2

dev-util/pkgconfig:       0.28-r2

sys-apps/baselayout:      2.2

sys-apps/openrc:          0.13.2

sys-apps/sandbox:         2.6-r1

sys-devel/autoconf:       2.13, 2.69

sys-devel/automake:       1.11.6, 1.14.1

sys-devel/binutils:       2.24-r3

sys-devel/gcc:            4.9.2

sys-devel/gcc-config:     1.8

sys-devel/libtool:        2.4.3-r1

sys-devel/make:           4.1-r1

sys-kernel/linux-headers: 3.17-r1 (virtual/os-headers)

sys-libs/glibc:           2.19-r1

Repositories: gentoo gnome

ACCEPT_KEYWORDS="amd64 ~amd64"

ACCEPT_LICENSE="* -@EULA Broadcom"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-march=native -mtune=native -fomit-frame-pointer -O2 -pipe"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"

CXXFLAGS="-march=native -mtune=native -fomit-frame-pointer -O2 -pipe"

DISTDIR="/usr/portage/distfiles"

FCFLAGS="-O2 -pipe"

FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"

FFLAGS="-O2 -pipe"

GENTOO_MIRRORS="http://distfiles.gentoo.org"

LANG="en_US.UTF-8"

LDFLAGS="-Wl,-O1 -Wl,--as-needed"

MAKEOPTS="-j8"

PKGDIR="/usr/portage/packages"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="/var/lib/layman/gnome"

USE="X a52 aac acl acpi alsa amd64 berkdb bindist bluetooth branding bzip2 cairo cdda cdr cli colord cracklib crypt cups cxx dbus dri dts dvd dvdr eds emboss encode evo exif experimental fam firefox flac fortran gdbm gif glamor gnome gnome-keyring gnome-online-accounts gpm gstreamer gtk iconv infinality introspection ipv6 jpeg lcms ldap libnotify libsecret mad mmx mng modules mp3 mp4 mpeg multilib nautilus ncurses nls nptl ogg opengl openmp pam pango pcre pdf png policykit ppds pulseaudio qt3support readline sdl session socialweb spell sse sse2 ssl startup-notification svg symlink systemd tcpd tiff truetype udev udisks unicode upower usb vim-syntax vorbis wxwidgets x264 xcb xml xv xvid zlib zsh-completion" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en en_US" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_3" RUBY_TARGETS="ruby19 ruby20" USERLAND="GNU" VIDEO_CARDS="nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, SYNC, USE_PYTHON

```

```
➜  ~  emerge -pqv '=net-wireless/broadcom-sta-6.30.223.248-r1::gentoo'

[ebuild  N    ] net-wireless/broadcom-sta-6.30.223.248-r1 

 * IMPORTANT: 9 news items need reading for repository 'gentoo'.

 * Use eselect news to read news items.

```

```
➜  ~  sudo cat /var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/temp/build.log

 * Package:    net-wireless/broadcom-sta-6.30.223.248-r1

 * Repository: gentoo

 * Maintainer: tomboy64@sina.cn proxy-maint@gentoo.org

 * USE:        abi_x86_64 amd64 elibc_glibc kernel_linux userland_GNU

 * FEATURES:   preserve-libs sandbox userpriv usersandbox

 * Determining the location of the kernel source code

 * Found kernel source directory:

 *     /usr/src/linux

 * Found kernel object directory:

 *     /lib/modules/3.17.2-gentoo/build

 * Found sources for kernel version:

 *     3.17.2-gentoo

 * Checking for suitable kernel configuration options...                                                                                                                                                                                                                               [ ok ]

>>> Unpacking source...

>>> Unpacking hybrid-v35_64-nodebug-pcoem-6_30_223_248.tar.gz to /var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work

>>> Unpacking README-broadcom-sta-6.30.223.248.txt to /var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work

unpack README-broadcom-sta-6.30.223.248.txt: file format not recognized. Ignoring.

>>> Source unpacked in /var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work

>>> Preparing source in /var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work ...

 * Applying broadcom-sta-6.30.223.141-license.patch ...                                                                                                                                                                                                                                [ ok ]

 * Applying broadcom-sta-6.30.223.141-makefile.patch ...                                                                                                                                                                                                                               [ ok ]

 * Applying broadcom-sta-6.30.223.141-eth-to-wlan.patch ...                                                                                                                                                                                                                            [ ok ]

 * Applying broadcom-sta-6.30.223.141-gcc.patch ...                                                                                                                                                                                                                                    [ ok ]

 * Applying broadcom-sta-6.30.223.141-linux-3.15.patch ...                                                                                                                                                                                                                             [ ok ]

>>> Source prepared.

>>> Configuring source in /var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work ...

>>> Source configured.

>>> Compiling source in /var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work ...

ln: failed to create symbolic link ‘Module.symvers’: File exists

 * Preparing wl module

make -j8 HOSTCC=x86_64-pc-linux-gnu-gcc CROSS_COMPILE=x86_64-pc-linux-gnu- 'LDFLAGS=-m elf_x86_64' -C /usr/src/linux M=/var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work wl.ko 

make: Entering directory '/usr/src/linux-3.17.2-gentoo'

CFG80211 API is prefered for this kernel version

Using CFG80211 API

  CC [M]  /var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work/src/wl/sys/wl_cfg80211_hybrid.o

  CC [M]  /var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work/src/shared/linux_osl.o

  CC [M]  /var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work/src/wl/sys/wl_linux.o

  CC [M]  /var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work/src/wl/sys/wl_iw.o

/var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work/src/wl/sys/wl_linux.c: In function ‘wl_alloc_linux_if’:

/var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work/src/wl/sys/wl_linux.c:1311:64: error: macro "alloc_netdev" requires 4 arguments, but only 3 given

  dev = alloc_netdev(sizeof(priv_link_t), intf_name, ether_setup);

                                                                ^

/var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work/src/wl/sys/wl_linux.c:1311:8: error: ‘alloc_netdev’ undeclared (first use in this function)

  dev = alloc_netdev(sizeof(priv_link_t), intf_name, ether_setup);

        ^

/var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work/src/wl/sys/wl_linux.c:1311:8: note: each undeclared identifier is reported only once for each function it appears in

/var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work/src/wl/sys/wl_linux.c: In function ‘wl_dump_ver’:

/var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work/src/wl/sys/wl_linux.c:2050:3: error: macro "__DATE__" might prevent reproducible builds [-Werror=date-time]

   __DATE__, __TIME__, EPI_VERSION_STR);

   ^

/var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work/src/wl/sys/wl_linux.c:2050:13: error: macro "__TIME__" might prevent reproducible builds [-Werror=date-time]

   __DATE__, __TIME__, EPI_VERSION_STR);

             ^

/var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work/src/wl/sys/wl_cfg80211_hybrid.c: In function ‘wl_cfg80211_get_key’:

/var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work/src/wl/sys/wl_cfg80211_hybrid.c:1390:9: warning: passing argument 1 of ‘memcpy’ discards ‘const’ qualifier from pointer target type

  memcpy(params.key, key.data, params.key_len);

         ^

In file included from ./arch/x86/include/asm/string.h:4:0,

                 from include/linux/string.h:17,

                 from include/linux/dynamic_debug.h:111,

                 from include/linux/printk.h:260,

                 from include/linux/kernel.h:13,

                 from ./arch/x86/include/asm/percpu.h:44,

                 from ./arch/x86/include/asm/preempt.h:5,

                 from include/linux/preempt.h:18,

                 from include/linux/spinlock.h:50,

                 from include/linux/seqlock.h:35,

                 from include/linux/time.h:5,

                 from include/linux/stat.h:18,

                 from include/linux/module.h:10,

                 from /var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work/src/include/linuxver.h:40,

                 from /var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work/src/wl/sys/wl_cfg80211_hybrid.c:26:

./arch/x86/include/asm/string_64.h:32:14: note: expected ‘void *’ but argument is of type ‘const u8 *’

 extern void *memcpy(void *to, const void *from, size_t len);

              ^

/var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work/src/wl/sys/wl_cfg80211_hybrid.c: At top level:

/var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work/src/wl/sys/wl_cfg80211_hybrid.c:1778:2: warning: initialization from incompatible pointer type

  .get_station = wl_cfg80211_get_station,

  ^

/var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work/src/wl/sys/wl_cfg80211_hybrid.c:1778:2: warning: (near initialization for ‘wl_cfg80211_ops.get_station’)

cc1: some warnings being treated as errors

scripts/Makefile.build:257: recipe for target '/var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work/src/wl/sys/wl_linux.o' failed

make[1]: *** [/var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work/src/wl/sys/wl_linux.o] Error 1

make[1]: *** Waiting for unfinished jobs....

Makefile:1540: recipe for target 'wl.ko' failed

make: *** [wl.ko] Error 2

make: Leaving directory '/usr/src/linux-3.17.2-gentoo'

 * ERROR: net-wireless/broadcom-sta-6.30.223.248-r1::gentoo failed (compile phase):

 *   emake failed

 * 

 * If you need support, post the output of `emerge --info '=net-wireless/broadcom-sta-6.30.223.248-r1::gentoo'`,

 * the complete build log and the output of `emerge -pqv '=net-wireless/broadcom-sta-6.30.223.248-r1::gentoo'`.

 * The complete build log is located at '/var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/temp/build.log'.

 * The ebuild environment file is located at '/var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/temp/environment'.

 * Working directory: '/var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work'

 * S: '/var/tmp/portage/net-wireless/broadcom-sta-6.30.223.248-r1/work'

```

I am currently using Linux 3.17.2, and as far as I know it seems to be correctly configured with SSB and B43 disabled in the kernel. In addition, I have tried to install a few other versions of the broadcom-sta driver, as well as using it on Linux 3.16.7 (which has worked in the past).

Thanks for any help that you can provide!Last edited by mconnolly on Sun Nov 02, 2014 8:07 pm; edited 1 time in total

----------

## mconnolly

I was able to fix this by browsing through Debian's mailing list.

There, a user suggested a patch (which I modified slightly to work properly for portage's patch system).

Simply paste the following into the filename /etc/portage/patches/net-wireless/broadcom-sta/wl_linux.patch and emerge as normal.

```

--- src/wl/sys/wl_linux.c   2014-09-24 10:45:55.000000000 -0500

+++ src/wl/sys/wl_linux.c   2014-09-24 10:49:08.000000000 -0500

@@ -1309,7 +1309,12 @@

    dev->priv = priv_link;

 #else

 

-   dev = alloc_netdev(sizeof(priv_link_t), intf_name, ether_setup);

+   #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0))

+      dev = alloc_netdev(sizeof(priv_link_t), intf_name, ether_setup);

+   #else

+      dev = alloc_netdev(sizeof(priv_link_t), intf_name, NET_NAME_UNKNOWN, ether_setup);

+   #endif

+

    if (!dev) {

       WL_ERROR(("wl%d: %s: alloc_netdev failed\n",

          (wl->pub)?wl->pub->unit:wlif->subunit, __FUNCTION__));

```

Note that I am using Linux version 3.17.2 and have tested this for broadcom-sta version 6.30.223.248-r1. I am also using amd64 as my architecture, so if you are on something else, your mileage may vary.

For more info, see this link which also has an i386 version (which you will have to change the paths on for it to work): https://www.mail-archive.com/debian-bugs-dist%40lists.debian.org/msg1260504.html

----------

## Dachnaz

Nice post!! Thanks so much for finding this patch and making it usable with portage. With gentoo-sources-3.17.2 amd64, I had the same problem, and tried your patch, but it was not able to be applied. I had to tweak the line numbers of the patch just so, and here's what worked for me:

```
--- src/wl/sys/wl_linux.c       2014-11-05 20:51:43.024639499 -0800

+++ src/wl/sys/wl_linux.c       2014-11-05 21:24:45.281415658 -0800

@@ -1308,7 +1308,13 @@

        dev->priv = priv_link;

 #else

 

+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0))

        dev = alloc_netdev(sizeof(priv_link_t), intf_name, ether_setup);

+#else

+

+       dev = alloc_netdev(sizeof(priv_link_t), intf_name, NET_NAME_UNKNOWN, ether_setup);

+#endif

+

        if (!dev) {

                WL_ERROR(("wl%d: %s: alloc_netdev failed\n",

                        (wl->pub)?wl->pub->unit:wlif->subunit, __FUNCTION__));
```

----------

