diff options
Diffstat (limited to 'package')
-rw-r--r-- | package/mac80211/Config.in | 44 | ||||
-rw-r--r-- | package/mac80211/Makefile | 4 | ||||
-rwxr-xr-x | package/mac80211/files/host_bin/b43-fwsquash.py | 100 |
3 files changed, 148 insertions, 0 deletions
diff --git a/package/mac80211/Config.in b/package/mac80211/Config.in index f3eb5ec3cf..0eda184019 100644 --- a/package/mac80211/Config.in +++ b/package/mac80211/Config.in @@ -17,3 +17,47 @@ config B43_OPENFIRMWARE bool "Open FirmWare for WiFi networks" endchoice + +config B43_FW_SQUASH + bool "Remove unnecessary firmware files" + depends on PACKAGE_kmod-b43 && !B43_OPENFIRMWARE + help + This options allows you to remove unnecessary b43 firmware files + from the final rootfs image. This can reduce the rootfs size by + up to 200k. + + Do _NOT_ use this option, if you don't know the core revision + and/or PHY type of your wireless chip. + + If unsure, say N. + +config B43_FW_SQUASH_COREREVS + string "Core revisions to include" + depends on PACKAGE_kmod-b43 + depends on B43_FW_SQUASH + default "5,6,7,8,9,10" + help + This is a comma seperated list of core revision numbers. + Example (keep files for rev5 only): + 5 + Example (keep files for rev5 and rev11): + 5,11 + +config B43_FW_SQUASH_PHYTYPES + string "PHY types to include" + depends on PACKAGE_kmod-b43 + depends on B43_FW_SQUASH + default "G,LP,N" + help + This is a comma seperated list of PHY types: + A => A-PHY + AG => Dual A-PHY G-PHY + G => G-PHY + LP => LP-PHY + N => N-PHY + + Example (keep files for G-PHY only): + G + Example (keep files for G-PHY and N-PHY): + G,N + diff --git a/package/mac80211/Makefile b/package/mac80211/Makefile index 8fadab88bd..b3b73fb32d 100644 --- a/package/mac80211/Makefile +++ b/package/mac80211/Makefile @@ -483,6 +483,7 @@ ifneq ($(CONFIG_B43_OPENFIRMWARE),) $(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_B43_FWCUTTER_SUBDIR)/assembler/b43-asm $(STAGING_DIR_HOST)/bin/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_B43_FWCUTTER_SUBDIR)/assembler/b43-asm.bin $(STAGING_DIR_HOST)/bin/ endif + $(INSTALL_BIN) ./files/host_bin/b43-fwsquash.py $(STAGING_DIR_HOST)/bin/ endef define KernelPackage/b43/install @@ -503,6 +504,9 @@ ifneq ($(CONFIG_B43_OPENFIRMWARE),) else b43-fwcutter --unsupported -w $(1)/lib/firmware/ $(PKG_BUILD_DIR)/$(PKG_B43_FWV4_OBJECT) endif +ifneq ($(CONFIG_B43_FW_SQUASH),) + b43-fwsquash.py "$(CONFIG_B43_FW_SQUASH_PHYTYPES)" "$(CONFIG_B43_FW_SQUASH_COREREVS)" "$(1)/lib/firmware/b43" +endif endef define KernelPackage/b43legacy/install 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 0000000000..52484d1b19 --- /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) + |