diff options
author | Michael Büsch <mb@bu3sch.de> | 2009-03-17 19:34:45 +0000 |
---|---|---|
committer | Michael Büsch <mb@bu3sch.de> | 2009-03-17 19:34:45 +0000 |
commit | 48a5ed9bb87c64fbc8ae4df9cd5a713cadf1b893 (patch) | |
tree | 322504dccb0b98905ee0c61a4e1b752e196f6be1 /package/mac80211/files | |
parent | 56bf010d4cd3c289ce5237413a823fab4fe47e7a (diff) | |
download | mtk-20170518-48a5ed9bb87c64fbc8ae4df9cd5a713cadf1b893.zip mtk-20170518-48a5ed9bb87c64fbc8ae4df9cd5a713cadf1b893.tar.gz mtk-20170518-48a5ed9bb87c64fbc8ae4df9cd5a713cadf1b893.tar.bz2 |
b43: Add support for removing unnecessary firmware files to reduce the image size.
SVN-Revision: 14929
Diffstat (limited to 'package/mac80211/files')
-rwxr-xr-x | package/mac80211/files/host_bin/b43-fwsquash.py | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/package/mac80211/files/host_bin/b43-fwsquash.py b/package/mac80211/files/host_bin/b43-fwsquash.py new file mode 100755 index 0000000..52484d1 --- /dev/null +++ b/package/mac80211/files/host_bin/b43-fwsquash.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python +# +# b43 firmware file squasher +# Removes unnecessary firmware files +# +# Copyright (c) 2009 Michael Buesch <mb@bu3sch.de> +# +# Licensed under the GNU/GPL version 2 or (at your option) any later version. +# + +import sys +import os + +def usage(): + print "Usage: %s PHYTYPES COREREVS /path/to/extracted/firmware" % sys.argv[0] + print "" + print "PHYTYPES is a comma separated list of:" + print "A => A-PHY" + print "AG => Dual A-PHY G-PHY" + print "G => G-PHY" + print "LP => LP-PHY" + print "N => N-PHY" + print "" + print "COREREVS is a comma separated list of core revision numbers." + +if len(sys.argv) != 4: + usage() + sys.exit(1) + +phytypes = sys.argv[1] +corerevs = sys.argv[2] +fwpath = sys.argv[3] + +phytypes = phytypes.split(',') +try: + corerevs = map(lambda r: int(r), corerevs.split(',')) +except ValueError: + print "ERROR: \"%s\" is not a valid COREREVS string\n" % corerevs + usage() + sys.exit(1) + + +fwfiles = os.listdir(fwpath) +fwfiles = filter(lambda str: str.endswith(".fw"), fwfiles) +if not fwfiles: + print "ERROR: No firmware files found in %s" % fwpath + sys.exit(1) + +required_fwfiles = [] + +def revs_match(revs_a, revs_b): + for rev in revs_a: + if rev in revs_b: + return True + return False + +def phytypes_match(types_a, types_b): + for type in types_a: + type = type.strip().upper() + if type in types_b: + return True + return False + +revmapping = { + "ucode5.fw" : (5,6,7,8,9,10,), + "ucode11.fw" : (11,12,), + "ucode13.fw" : (13,), + "pcm4.fw" : (1,2,3,4,), + "pcm5.fw" : (5,6,7,8,9,10,), +} + +initvalmapping = { + "a0g1initvals5.fw" : ( (5,6,7,8,9,10,), ("AG",), ), + "a0g0initvals5.fw" : ( (5,6,7,8,9,10,), ("A", "AG",), ), + "b0g0initvals5.fw" : ( (5,6,7,8,9,10,), ("G",), ), + "b0g0initvals13.fw" : ( (13,), ("G",), ), + "n0initvals11.fw" : ( (11,12,), ("N",), ), + "a0g1bsinitvals5.fw" : ( (5,6,7,8,9,10,), ("AG",), ), + "a0g0bsinitvals5.fw" : ( (5,6,7,8,9,10,), ("A", "AG"), ), + "b0g0bsinitvals5.fw" : ( (5,6,7,8,9,10,), ("G",), ), + "n0bsinitvals11.fw" : ( (11,12,), ("N",), ), +} + +for f in fwfiles: + if f in revmapping: + if revs_match(corerevs, revmapping[f]): + required_fwfiles += [f] + continue + if f in initvalmapping: + if revs_match(corerevs, initvalmapping[f][0]) and\ + phytypes_match(phytypes, initvalmapping[f][1]): + required_fwfiles += [f] + continue + print "WARNING: Firmware file %s not found in the mapping lists" % f + +for f in fwfiles: + if f not in required_fwfiles: + print "Deleting %s" % f + os.unlink(fwpath + '/' + f) + |