Re: b43-fwcutter patch for new firmware versions (508.1107 and 508.102)

2009-09-14 Thread Larry Finger
Daniel Lenski wrote:
 On Thu, Sep 3, 2009 at 5:25 PM, Daniel Lenski dlen...@gmail.com wrote:
 I have not found any other source of these, unfortunately.  I am happy
 to send the extracted firmware to developers off-list if desired.
 Linksys's less-than-helpful GPL source code page gives no indication of
 the age or date of the various files, so it's hard for me to tell which
 might be newer without downloading many Gb and extracting many
 firmwares.  I have half a mind to write a Python script...
 
 Hi all,
 
 Since starting this thread, I've search around more to find b43
 firmware.  I wrote a script to automatically download, unpack, and
 scour each and every one of the Linksys GPL packages
 (http://www.linksysbycisco.com/US/en/supportgplcode) for firmware.
 
 I found some interesting things in the process, including several new
 firmware versions.  Perhaps most interestingly, I found  Broadcom WL
 drivers built for a 2.6.x kernel.  If you grab the file
 WAG54GX2_A_v1009_UK_GPL.tgz from Linksys, there's a file
 src.GPL/driver/2.6.8.1/extra/wl.ko containing firmware.  Very
 intriguing.
 
 Also, I wrote a pure-Python version of b43-fwcutter (attached) to
 facilitate this automated firmware extraction, based on mklist.py.
 Just point it at a binary containing firmware, and it will (a) find
 the firmware in the manner of mklist.py, and (b) extract it in the
 manner of b43-fwcutter.c.  It produces identical firmware files as the
 C version of b43-fwcutter, and may be useful if experimenting with
 different firmware versions.
 
 In the process of writing the Python code, I think I found an
 endian-related bug in b43-fwcutter.c.  It mangles the byte order of
 firmware instructions and as a result the analyse_ucode() routine
 doesn't find the firmware version information on little-endian hosts.
 I can submit a patch for that as well, if interested.  But the bug is
 fixed in my Python implementation, which you can try out.

I tried it on the file above and got the following:

fin...@larrylap:~/WAG54GX2 ~/sprom/b43_fwcutter.py
src.GPL/driver/2.6.8.1/extra/wl.ko
Firmware md5sum is 4f1218df93c23b4e27c83cb208031a1d...
Extracting a0g0bsinitvals2 of length 0x10 from offset 0x52A4C...
Traceback (most recent call last):
  File /home/finger/sprom/b43_fwcutter.py, line 267, in module
extract_firmware(fd, extract, options.endian, outfn)
  File /home/finger/sprom/b43_fwcutter.py, line 197, in extract_firmware
buf, n = build_ivs(buf, endian)
  File /home/finger/sprom/b43_fwcutter.py, line 169, in build_ivs
assert biv.size in (2,4)
AssertionError


___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


Re: b43-fwcutter patch for new firmware versions (508.1107 and 508.102)

2009-09-14 Thread Daniel Lenski
On Mon, 2009-09-14 at 22:01 -0500, Larry Finger wrote:
 I tried it on the file above and got the following:
 
 fin...@larrylap:~/WAG54GX2 ~/sprom/b43_fwcutter.py
 src.GPL/driver/2.6.8.1/extra/wl.ko
 Firmware md5sum is 4f1218df93c23b4e27c83cb208031a1d...
 Extracting a0g0bsinitvals2 of length 0x10 from offset 0x52A4C...
 Traceback (most recent call last):
   File /home/finger/sprom/b43_fwcutter.py, line 267, in module
 extract_firmware(fd, extract, options.endian, outfn)
   File /home/finger/sprom/b43_fwcutter.py, line 197, in extract_firmware
 buf, n = build_ivs(buf, endian)
   File /home/finger/sprom/b43_fwcutter.py, line 169, in build_ivs
 assert biv.size in (2,4)
 AssertionError
 

Oh, sorry... run it with the -b option to indicate that the binary is
big-endian.

You can see the command-line options with --help.  Also, I've attached
my script to downloads and inspect /all/ the firmware from the Linksys
site.  (Warning: ugly, hackish code to handle ugly, ridiculously
organized archives.)

Dan
#!/usr/bin/python
#
# (C) 2009 by Dan Lenski
# 
# Uses b43_finder.py to seek out all the firmware from Linksys's GPL
# code site.
#
#   Redistribution and use in source and binary forms, with or without
#   modification, are permitted provided that the following conditions
#   are met:
#
# 1. Redistributions of source code must retain the above copyright
#notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above
#copyright notice, this list of conditions and the following
#disclaimer in the documentation and/or other materials provided
#with the distribution.
#
#   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
#   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
#   OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
#   DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
#   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
#   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
#   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
#   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
#   OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
#   EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


import sys, os, re, tempfile, urllib, hashlib
import tarfile, zipfile
import b43_fwcutter

outdir = sys.argv[1]

def reporthook(blocks, blocksize, totalsize):
sofar = blocks*blocksize
if sofar1.01e9: amount=%.2f GB%(sofar/1e9)
elif sofar1.01e6: amount=%.2f MB%(sofar/1e6)
elif sofar1.01e3: amount=%.2f kB%(sofar/1e3)
else: amount=%.2f B%sofar
if totalsize: percent = 100.0*sofar/totalsize
else: percent = 100
print %2d%% - Downloaded %s  \r % (percent, amount),
if percent=100: print

def search_archive(fn, name):
# open the archive
try:
if name.endswith('.zip'):
print Opening zipfile...
archive = zipfile.ZipFile(fn)
getnames = archive.namelist
getfile = archive.open
elif any(x in name for x in ('.tar','.tgz','.gz','.tbz','.bz')):
print Opening tarball...
archive = tarfile.open(fn)
getnames = archive.getnames
getfile = archive.extractfile
else:
print Don't know what to do with archive named '%s'... % name
print Skipping...
return

# get contents
print Getting contents...
names = getnames()
except:
print Couldn't open/list archive named '%s'... % name
print Skipping...
return

# find nested archives and potential firmware-containing binaries
print Finding files potentially containing firmware...
nested = [ n for n in names if any(x in n.lower() for x in ('.zip','.tar','.tgz','.gz','.tbz','.bz')) ]
potential = [ n for n in names if re.match('wl(?:\w*)\.k?o', os.path.basename(n)) ]

# stupid archive-inside-archives... RRRGH!
if not potential:
for fn in nested:
tmp = /tmp/+hashlib.md5(fn).hexdigest()
if not os.access(tmp, os.F_OK):
print Extracting nested archive %s... % fn
try:
open(tmp,w).write( getfile(fn).read() )
except:
print Couldn't extract nested archive!!!
continue
print Checking nested archive %s... % fn
search_archive( tmp, fn ) # RECURSE!

# extract potential firmware-containing binaries
for fn in potential:
print Extracting %s... % fn
tmp = tempfile.NamedTemporaryFile()
contents = getfile(fn).read()
md5sum = hashlib.md5(contents).hexdigest()
tmp.write( contents )

print Guessing endian...
endian = ''

Re: b43-fwcutter patch for new firmware versions (508.1107 and 508.102)

2009-09-04 Thread Michael Buesch
On Thursday 03 September 2009 23:37:31 Larry Finger wrote:
 Daniel Lenski wrote:
  Larry,
  I agree on the ridiculously poor packaging... did I mention they're 1gb+
  extracted?
 
 I didn't look at what is contained within that package, but we
 certainly don't need it.
 
  I have not found any other source of these, unfortunately.  I am happy
  to send the extracted firmware to developers off-list if desired.
  Linksys's less-than-helpful GPL source code page gives no indication of
  the age or date of the various files, so it's hard for me to tell which
  might be newer without downloading many Gb and extracting many
  firmwares.  I have half a mind to write a Python script...
 
 Not necessary to send the extracted software. If and when I want to
 see the new firmware, I'm perfectly happy to download that big file;
 however, it does not make sense for some user who is using the
 openSUSE script to wait through a large download just to install firmware.
  
  I notice in your extraction that there are now ucode files for
  revisions 16, 17, 19, 20, and 21.
  
  Yes, indeed.  So are these the source of the FW12/13/14/... numbering?
 
 No. Michael assigns a new number whenever he releases a new version.
 All the new files are supposed to be listed with that number. At least
 I think that is the way it works. Version 12 is the last one released.

Ehm, no.
The FW.. identifier is a _unique_ identifier for a set of firmware files.
So the identifier is the same for binary equal firmware files. So if you add
a firmware _that_ _is_ _not_ _already_ _there_ you monotonically increment the
last ID and assign the firmware that ID.
But if another firmware is already there which has the same version _and_
number of files _and_ filenames _and_ these files are binary equal, assign
the new firmware the ID of the existing equal firmware.

The idea is that the driver prints a string to dmesg telling what the best 
supported
firmware is. For example if the driver says:
  Broadcom 43xx driver loaded [ Features: PL, Firmware-ID: FW13 ]
that means the user should go and get FW13.

-- 
Greetings, Michael.
___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


Re: b43-fwcutter patch for new firmware versions (508.1107 and 508.102)

2009-09-03 Thread Daniel Lenski
On Thu, 2009-09-03 at 16:49 -0400, Daniel Lenski wrote:
 Both of these firmwares work on my BCM4311 laptop card in managed and
 monitor modes.  When loaded, they identify themselves as newer firmware
 revisions than anything that b43-fwcutter currently knows about:

On that note, is there a way to identify the ucode-version of b43 
firmware without reloading the b43 driver?

A quick glance at the drivers/net/wireless/b43/main.c suggests that the 
driver actually loads the firmware, then queries the device for its 
version number... but maybe there's some kind of heuristic?

Dan

___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


Re: b43-fwcutter patch for new firmware versions (508.1107 and 508.102)

2009-09-03 Thread Daniel Lenski
On Thu, 2009-09-03 at 16:13 -0500, Larry Finger wrote:
 I certainly would like to have access to the later firmware; however
 downloads of 338 and 340 MB seem a little silly just to get a few
 hundred KB of firmware. Have you found any other sources with 508.XX
 firmware?

Larry,
I agree on the ridiculously poor packaging... did I mention they're 1gb+
extracted?

I have not found any other source of these, unfortunately.  I am happy
to send the extracted firmware to developers off-list if desired.
Linksys's less-than-helpful GPL source code page gives no indication of
the age or date of the various files, so it's hard for me to tell which
might be newer without downloading many Gb and extracting many
firmwares.  I have half a mind to write a Python script...

 I notice in your extraction that there are now ucode files for
 revisions 16, 17, 19, 20, and 21.

Yes, indeed.  So are these the source of the FW12/13/14/... numbering?

Dan

___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


Re: b43-fwcutter patch for new firmware versions (508.1107 and 508.102)

2009-09-03 Thread Larry Finger
Sending to the list:

Daniel Lenski wrote:
 
 On that note, is there a way to identify the ucode-version of b43 
 firmware without reloading the b43 driver?

The dmesg output has it.

 A quick glance at the drivers/net/wireless/b43/main.c suggests that the 
 driver actually loads the firmware, then queries the device for its 
 version number... but maybe there's some kind of heuristic?

The ucode file that is loaded is dictated by the revision number of
the 802.11 core. The output from 'dmesg | egrep ssb|b43' on my
system shows the following:

ssb: Core 0 found: ChipCommon (cc 0x800, rev 0x16, vendor 0x4243)
ssb: Core 1 found: IEEE 802.11 (cc 0x812, rev 0x0F, vendor 0x4243)
ssb: Core 2 found: PCMCIA (cc 0x80D, rev 0x0A, vendor 0x4243)
ssb: Core 3 found: PCI-E (cc 0x820, rev 0x09, vendor 0x4243)
ssb: Found rev 1 PMU (capabilities 0x02A62F01)
ssb: SPROM revision 8 detected.
ssb: Sonics Silicon Backplane found on PCI device :04:00.0
b43-phy0: Broadcom 4312 WLAN found (core revision 15)
b43-phy0 debug: Found PHY: Analog 6, Type 5, Revision 1
b43-phy0 debug: Found Radio: Manuf 0x17F, Version 0x2062, Revision 2
b43 ssb0:0: firmware: requesting b43/ucode15.fw
b43 ssb0:0: firmware: requesting b43/lp0initvals15.fw
b43 ssb0:0: firmware: requesting b43/lp0bsinitvals15.fw
b43-phy0: Loading firmware version 478.104 (2008-07-01 00:50:23)

Note that 0x0F in ssb core 1 = ucode15. The version is stored within
that file. A number of different versions are likely to work with a
given card. In fact, there may not be any difference in the ucode5
file between firmware version 410.XXX and 508.XXX. One would have to
look at the binary differences to tell if anything other that the
version number had changed.

Larry

___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


Re: b43-fwcutter patch for new firmware versions (508.1107 and 508.102)

2009-09-03 Thread Larry Finger
Daniel Lenski wrote:
 Larry,
 I agree on the ridiculously poor packaging... did I mention they're 1gb+
 extracted?

I didn't look at what is contained within that package, but we
certainly don't need it.

 I have not found any other source of these, unfortunately.  I am happy
 to send the extracted firmware to developers off-list if desired.
 Linksys's less-than-helpful GPL source code page gives no indication of
 the age or date of the various files, so it's hard for me to tell which
 might be newer without downloading many Gb and extracting many
 firmwares.  I have half a mind to write a Python script...

Not necessary to send the extracted software. If and when I want to
see the new firmware, I'm perfectly happy to download that big file;
however, it does not make sense for some user who is using the
openSUSE script to wait through a large download just to install firmware.
 
 I notice in your extraction that there are now ucode files for
 revisions 16, 17, 19, 20, and 21.
 
 Yes, indeed.  So are these the source of the FW12/13/14/... numbering?

No. Michael assigns a new number whenever he releases a new version.
All the new files are supposed to be listed with that number. At least
I think that is the way it works. Version 12 is the last one released.

Larry
___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


Re: b43-fwcutter patch for new firmware versions (508.1107 and 508.102)

2009-09-03 Thread Daniel Lenski
On Thu, 2009-09-03 at 16:37 -0500, Larry Finger wrote:
 Daniel Lenski wrote:
  Larry,
  I agree on the ridiculously poor packaging... did I mention they're 1gb+
  extracted?
 
 I didn't look at what is contained within that package, but we
 certainly don't need it.

It appears to be the complete toolchain used to build the firmware,
complete with a bunch of random binaries floating around.

  I have not found any other source of these, unfortunately.  I am happy
  to send the extracted firmware to developers off-list if desired.
  Linksys's less-than-helpful GPL source code page gives no indication of
  the age or date of the various files, so it's hard for me to tell which
  might be newer without downloading many Gb and extracting many
  firmwares.  I have half a mind to write a Python script...
 
 Not necessary to send the extracted software. If and when I want to
 see the new firmware, I'm perfectly happy to download that big file;
 however, it does not make sense for some user who is using the
 openSUSE script to wait through a large download just to install firmware.

Good point.  I'm not really familiar with the legal intricacies of the
licensing issues involved.  The LICENSE files strewn throughout the
tarball *seem* to indicate that it'd be permissible to cut out the
relevant binaries and distribute them, but I'm in way over my head
here...

  I notice in your extraction that there are now ucode files for
  revisions 16, 17, 19, 20, and 21.
  
  Yes, indeed.  So are these the source of the FW12/13/14/... numbering?
 
 No. Michael assigns a new number whenever he releases a new version.
 All the new files are supposed to be listed with that number. At least
 I think that is the way it works. Version 12 is the last one released.

Hmm... I think we might be talking about two different things.  I'm
wondering about the source of the .id = FWxx tags in fwcutter_list.h.

Dan

___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


Re: b43-fwcutter patch for new firmware versions (508.1107 and 508.102)

2009-09-03 Thread Gábor Stefanik
On Fri, Sep 4, 2009 at 12:02 AM, Daniel Lenskidlen...@gmail.com wrote:
 On Thu, 2009-09-03 at 16:37 -0500, Larry Finger wrote:
 Daniel Lenski wrote:
  Larry,
  I agree on the ridiculously poor packaging... did I mention they're 1gb+
  extracted?

 I didn't look at what is contained within that package, but we
 certainly don't need it.

 It appears to be the complete toolchain used to build the firmware,
 complete with a bunch of random binaries floating around.

  I have not found any other source of these, unfortunately.  I am happy
  to send the extracted firmware to developers off-list if desired.
  Linksys's less-than-helpful GPL source code page gives no indication of
  the age or date of the various files, so it's hard for me to tell which
  might be newer without downloading many Gb and extracting many
  firmwares.  I have half a mind to write a Python script...

 Not necessary to send the extracted software. If and when I want to
 see the new firmware, I'm perfectly happy to download that big file;
 however, it does not make sense for some user who is using the
 openSUSE script to wait through a large download just to install firmware.

 Good point.  I'm not really familiar with the legal intricacies of the
 licensing issues involved.  The LICENSE files strewn throughout the
 tarball *seem* to indicate that it'd be permissible to cut out the
 relevant binaries and distribute them, but I'm in way over my head
 here...

  I notice in your extraction that there are now ucode files for
  revisions 16, 17, 19, 20, and 21.
 
  Yes, indeed.  So are these the source of the FW12/13/14/... numbering?

 No. Michael assigns a new number whenever he releases a new version.
 All the new files are supposed to be listed with that number. At least
 I think that is the way it works. Version 12 is the last one released.

 Hmm... I think we might be talking about two different things.  I'm
 wondering about the source of the .id = FWxx tags in fwcutter_list.h.

They have no source - everytime a new version is added to fwcutter,
it's FWxx ID is incremented. E.g. if the most recent version is FW15,
then adding a new entry should be done as FW16.

-- 
Vista: [V]iruses, [I]ntruders, [S]pyware, [T]rojans and [A]dware. :-)
___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev