Friday, 4 September 2009

Broadcom Firmware on Live CD

I use linksys wmp54gs wireless cards on my desktop and server machines. I want to try a linux distribution. I download a Live CD and boot the machine. I get crap screen resolution and no internet connection. There is no obvious reason why this is the case.

It turns out, after much googling, that my wireless cards use a chipset made by broadcom. Linux is supposed to have the drivers for this chipset built in. So what gives?

Well, it turns out that it you need TWO pieces of software to get this card working. You need the driver which, as with more mainstream operating systems, sits between the OS and the hardware. There is indeed an open source version of this which is bundled into the linux OS (or kernel). However, you ALSO need the firmware. This is code which runs on the wireless card itself. There is no open source firmware bundled into the linux kernel.

If one is being charitible, one would say that modern network cards are actually mini computers in their own right, and therefore need their own software loaded onto them. If one was feeling cynical one would say that the manufacturers are a bunch of bastards who value obfuscation of function over ease of use. After all, if you try to reverse engineer a network card missing its firmware you are not going to get very far.

Still if you wanted to get a hold of broadcom firmware, it is not difficult. They give it away. They just do not allow anyone else to give it away. With Windows, for instance, all of this is transparent because the driver CD you got or the driver you downloaded comes with the firmware in it. With linux, however, it is a problem because Broadcom will not allow any linux distribution to put the firmware on the CD. Because they are gits.

The solution is to download the firmware once you have booted the CD. Which is a great idea. Oh, except for that rare situation were you do not have an internet connection because your fucking wireless connection is not working. Welcome to the chicken and egg dilemma. You can't get your internet connection working until you get your internet connection working.

With a Windows PC you would, at this point, slip in the driver CD and load up the necessary drivers/firmware from that. No linux drivers on the CD though. Bugger. The windows alternative to a driver CD would be to download the drivers from broadcom on some other machine and move them by USB (or whatever) to the wireless-less machine.

I should point out at this stage that there is a webpage which tries to explain all this. It is a master piece of how not to get across information to someone who just cannot get a god damned wireless card to work. The headline story - that firmware is independent of the drivers - is halfway down the fucking page. The first sentence of the whole page reads "The b43 drivers (bcm43xx in mainline kernels, b43 and b43legacy in wireless-2.6 and 2.6.24 and later) are drivers for the 802.11 B/G family of wireless chips Broadcom produces." In terms of communication, it just goes downhill from there. I expect more from the number two google search result for "linux wireless broadcom".

What I therefore now present is a way to load the firmware onto a running Live CD.

Step Zero.
You need the firmware files. You can get them one of four ways. You can use a PC which already has a working wireless connection in Linux. See above for the amusing catch-22-ness of this solution. Alternatively you can temporarily use windows drivers to at least get online and download them in Linux, or you could use a virtual machine running on a PC with some other OS connected to the internet, or you can use a wired connection. What you could NOT do is leave a comment here asking for a zip of the extracted firmware files, because I am not allowed to distribute them and could not email them to you in a helpful manner. I will deal with using windows drivers and virtual machines in another post, so lets just assume you have somehow got the firmware files installed on your running PC.

Step One.
Get a USB key. Make a directory on the key called, firmware.
I talk a lot about Live CD images above, but really I normally use unetbootin to put the Live CD on a USB key. There should be room on the key to put the firmware on afterwards, it is not that big. You could also partition the key and put the firmware in a different partition to the Live CD image, which would let you swap around Live CD images without having to redo the first few steps here. Partitioning is a whole other topic though.

Step Two.
Copy the folder /lib/firmware/b43 to the usb key firmware directory.
All the linux firmware is kept in the /lib/firmware directory. I understand that some distributions keep the firmware somewhere else. If you have one of those I would recommend trying to find out where your /lib/firmware directory is.

Step Three.
Boot the Live CD (or USB, you know what I mean).
Mount your USB key. If using a sensible distribution, this is as simple as plugging it in. If not you will have to acquaint yourself with the contents of the /dev/ and /media/ directories and the mount command.

Step Four.
On the assumption that your usb key has been mounted to /media/disk, which mine invariably is, you can then just run the following commands in a terminal window:

sudo mkdir /lib/firmware/b43

This [m]a[k]es a folder (or [dir]ectory) in your local /lib/firmware/ folder ready for the firmware. Because this command affects the system area of linux the [s]uper[u]ser (or root) needs to [do] this command.

Step Five.
sudo cp /media/disk/firmware/*.* /lib/firmware/b43/
This copies the firmware file from your USB key to the local system. Note the [/disk/] part of the command - if your USB key mounts to somewhere else you need to change that.

Step Six.
sudo rmmod b43
This shutsdown the wireless driver. Techically it [r]e[m]oves the broadcom driver [mod]ule 'b43'. For these purposes a module is something which deals with hardware and could be in the kernel, but is kept out. It can be loaded or shutdown at will - think of it as a running program.

Step Seven.
sudo modprobe b43
This runs the wireless driver again. This time it will find the b43 folder in /lib/firmware/ and load the files from it onto the card. Assuming this works, you can then configure your internet connection using your usual Live CD network manager.

No comments:

Post a Comment