[package] add support for DS2482 1-Wire I2C bus master
[openwrt.git] / package / mac80211 / files / host_bin / b43-fwsquash.py
1 #!/usr/bin/env python
2 #
3 # b43 firmware file squasher
4 # Removes unnecessary firmware files
5 #
6 # Copyright (c) 2009 Michael Buesch <mb@bu3sch.de>
7 #
8 # Licensed under the GNU/GPL version 2 or (at your option) any later version.
9 #
10
11 import sys
12 import os
13
14 def usage():
15 print("Usage: %s PHYTYPES COREREVS /path/to/extracted/firmware" % sys.argv[0])
16 print("")
17 print("PHYTYPES is a comma separated list of:")
18 print("A => A-PHY")
19 print("AG => Dual A-PHY G-PHY")
20 print("G => G-PHY")
21 print("LP => LP-PHY")
22 print("N => N-PHY")
23 print("")
24 print("COREREVS is a comma separated list of core revision numbers.")
25
26 if len(sys.argv) != 4:
27 usage()
28 sys.exit(1)
29
30 phytypes = sys.argv[1]
31 corerevs = sys.argv[2]
32 fwpath = sys.argv[3]
33
34 phytypes = phytypes.split(',')
35 try:
36 corerevs = map(lambda r: int(r), corerevs.split(','))
37 except ValueError:
38 print("ERROR: \"%s\" is not a valid COREREVS string\n" % corerevs)
39 usage()
40 sys.exit(1)
41
42
43 fwfiles = os.listdir(fwpath)
44 fwfiles = filter(lambda str: str.endswith(".fw"), fwfiles)
45 if not fwfiles:
46 print("ERROR: No firmware files found in %s" % fwpath)
47 sys.exit(1)
48
49 required_fwfiles = []
50
51 def revs_match(revs_a, revs_b):
52 for rev in revs_a:
53 if rev in revs_b:
54 return True
55 return False
56
57 def phytypes_match(types_a, types_b):
58 for type in types_a:
59 type = type.strip().upper()
60 if type in types_b:
61 return True
62 return False
63
64 revmapping = {
65 "ucode2.fw" : (2,3,),
66 "ucode4.fw" : (4,),
67 "ucode5.fw" : (5,6,7,8,9,10,),
68 "ucode11.fw" : (11,12,),
69 "ucode13.fw" : (13,),
70 "ucode14.fw" : (14,),
71 "ucode15.fw" : (15,),
72 "ucode16_mimo.fw" : (16,),
73 "pcm4.fw" : (1,2,3,4,),
74 "pcm5.fw" : (5,6,7,8,9,10,),
75 }
76
77 initvalmapping = {
78 "a0g1initvals5.fw" : ( (5,6,7,8,9,10,), ("AG",), ),
79 "a0g0initvals5.fw" : ( (5,6,7,8,9,10,), ("A", "AG",), ),
80 "b0g0initvals2.fw" : ( (2,4,), ("G",), ),
81 "b0g0initvals5.fw" : ( (5,6,7,8,9,10,), ("G",), ),
82 "b0g0initvals13.fw" : ( (13,), ("G",), ),
83 "n0initvals11.fw" : ( (11,12,), ("N",), ),
84 "n0initvals16.fw" : ( (16,), ("N",), ),
85 "lp0initvals13.fw" : ( (13,), ("LP",), ),
86 "lp0initvals14.fw" : ( (14,), ("LP",), ),
87 "lp0initvals15.fw" : ( (15,), ("LP",), ),
88 "a0g1bsinitvals5.fw" : ( (5,6,7,8,9,10,), ("AG",), ),
89 "a0g0bsinitvals5.fw" : ( (5,6,7,8,9,10,), ("A", "AG"), ),
90 "b0g0bsinitvals5.fw" : ( (5,6,7,8,9,10,), ("G",), ),
91 "n0bsinitvals11.fw" : ( (11,12,), ("N",), ),
92 "n0bsinitvals16.fw" : ( (16,), ("N",), ),
93 "lp0bsinitvals13.fw" : ( (13,), ("LP",), ),
94 "lp0bsinitvals14.fw" : ( (14,), ("LP",), ),
95 "lp0bsinitvals15.fw" : ( (15,), ("LP",), ),
96 }
97
98 for f in fwfiles:
99 if f in revmapping:
100 if revs_match(corerevs, revmapping[f]):
101 required_fwfiles += [f]
102 continue
103 if f in initvalmapping:
104 if revs_match(corerevs, initvalmapping[f][0]) and\
105 phytypes_match(phytypes, initvalmapping[f][1]):
106 required_fwfiles += [f]
107 continue
108 print("WARNING: Firmware file %s not found in the mapping lists" % f)
109
110 for f in fwfiles:
111 if f not in required_fwfiles:
112 print("Deleting %s" % f)
113 os.unlink(fwpath + '/' + f)
114
This page took 0.055587 seconds and 5 git commands to generate.