2 # DVB firmware extractor
4 # (c) 2004 Andrew de Quincey
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 use File::Temp qw/ tempdir /;
24 @components = ( "sp8870", "sp887x", "tda10045", "tda10046", "av7110", "dec2000t",
25 "dec2540t", "dec3000s", "vp7041", "dibusb", "nxt2002", "nxt2004",
26 "or51211", "or51132_qam", "or51132_vsb", "bluebird");
29 syntax() if (scalar(@ARGV) != 1);
33 for ($i=0; $i < scalar(@components); $i++) {
34 if ($cid eq $components[$i]) {
35 $outfile = eval($cid);
38 Firmware $outfile extracted successfully.
39 Now copy it to either /usr/lib/hotplug/firmware or /lib/firmware
40 (depending on configuration of firmware hotplug).
46 # If we get here, it wasn't found
47 print STDERR "Unknown component \"$cid\"\n";
53 # ---------------------------------------------------------------
54 # Firmware-specific extraction subroutines
57 my $sourcefile = "tt_Premium_217g.zip";
58 my $url = "http://www.technotrend.de/new/217g/$sourcefile";
59 my $hash = "53970ec17a538945a6d8cb608a7b3899";
60 my $outfile = "dvb-fe-sp8870.fw";
61 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
65 wgetfile($sourcefile, $url);
66 unzip($sourcefile, $tmpdir);
67 verify("$tmpdir/software/OEM/HE/App/boot/SC_MAIN.MC", $hash);
68 copy("$tmpdir/software/OEM/HE/App/boot/SC_MAIN.MC", $outfile);
74 my $sourcefile = "Dvbt1.3.57.6.zip";
75 my $url = "http://www.avermedia.com/software/$sourcefile";
76 my $cabfile = "DVBT Net Ver1.3.57.6/disk1/data1.cab";
77 my $hash = "237938d53a7f834c05c42b894ca68ac3";
78 my $outfile = "dvb-fe-sp887x.fw";
79 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
84 wgetfile($sourcefile, $url);
85 unzip($sourcefile, $tmpdir);
86 unshield("$tmpdir/$cabfile", $tmpdir);
87 verify("$tmpdir/ZEnglish/sc_main.mc", $hash);
88 copy("$tmpdir/ZEnglish/sc_main.mc", $outfile);
94 my $sourcefile = "tt_budget_217g.zip";
95 my $url = "http://www.technotrend.de/new/217g/$sourcefile";
96 my $hash = "2105fd5bf37842fbcdfa4bfd58f3594a";
97 my $outfile = "dvb-fe-tda10045.fw";
98 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
102 wgetfile($sourcefile, $url);
103 unzip($sourcefile, $tmpdir);
104 extract("$tmpdir/software/OEM/PCI/App/ttlcdacc.dll", 0x37ef9, 30555, "$tmpdir/fwtmp");
105 verify("$tmpdir/fwtmp", $hash);
106 copy("$tmpdir/fwtmp", $outfile);
112 my $sourcefile = "tt_budget_217g.zip";
113 my $url = "http://www.technotrend.de/new/217g/$sourcefile";
114 my $hash = "6a7e1e2f2644b162ff0502367553c72d";
115 my $outfile = "dvb-fe-tda10046.fw";
116 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
120 wgetfile($sourcefile, $url);
121 unzip($sourcefile, $tmpdir);
122 extract("$tmpdir/software/OEM/PCI/App/ttlcdacc.dll", 0x3f731, 24478, "$tmpdir/fwtmp");
123 verify("$tmpdir/fwtmp", $hash);
124 copy("$tmpdir/fwtmp", $outfile);
130 my $sourcefile = "dvb-ttpci-01.fw-261d";
131 my $url = "http://www.linuxtv.org/downloads/firmware/$sourcefile";
132 my $hash = "603431b6259715a8e88f376a53b64e2f";
133 my $outfile = "dvb-ttpci-01.fw";
137 wgetfile($sourcefile, $url);
138 verify($sourcefile, $hash);
139 copy($sourcefile, $outfile);
145 my $sourcefile = "dec217g.exe";
146 my $url = "http://hauppauge.lightpath.net/de/$sourcefile";
147 my $hash = "bd86f458cee4a8f0a8ce2d20c66215a9";
148 my $outfile = "dvb-ttusb-dec-2000t.fw";
149 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
153 wgetfile($sourcefile, $url);
154 unzip($sourcefile, $tmpdir);
155 verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_T.bin", $hash);
156 copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_T.bin", $outfile);
162 my $sourcefile = "dec217g.exe";
163 my $url = "http://hauppauge.lightpath.net/de/$sourcefile";
164 my $hash = "53e58f4f5b5c2930beee74a7681fed92";
165 my $outfile = "dvb-ttusb-dec-2540t.fw";
166 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
170 wgetfile($sourcefile, $url);
171 unzip($sourcefile, $tmpdir);
172 verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_X.bin", $hash);
173 copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_X.bin", $outfile);
179 my $sourcefile = "dec217g.exe";
180 my $url = "http://hauppauge.lightpath.net/de/$sourcefile";
181 my $hash = "b013ececea83f4d6d8d2a29ac7c1b448";
182 my $outfile = "dvb-ttusb-dec-3000s.fw";
183 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
187 wgetfile($sourcefile, $url);
188 unzip($sourcefile, $tmpdir);
189 verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_S.bin", $hash);
190 copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_S.bin", $outfile);
196 my $sourcefile = "2.422.zip";
197 my $url = "http://www.twinhan.com/files/driver/USB-Ter/$sourcefile";
198 my $hash = "e88c9372d1f66609a3e7b072c53fbcfe";
199 my $outfile = "dvb-vp7041-2.422.fw";
200 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
204 wgetfile($sourcefile, $url);
205 unzip($sourcefile, $tmpdir);
206 extract("$tmpdir/VisionDTV/Drivers/Win2K&XP/UDTTload.sys", 12503, 3036, "$tmpdir/fwtmp1");
207 extract("$tmpdir/VisionDTV/Drivers/Win2K&XP/UDTTload.sys", 2207, 10274, "$tmpdir/fwtmp2");
209 my $CMD = "\000\001\000\222\177\000";
210 my $PAD = "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000";
212 open $FW, ">$tmpdir/fwtmp3";
213 print $FW "$CMD\001$PAD";
214 print $FW "$CMD\001$PAD";
215 appendfile($FW, "$tmpdir/fwtmp1");
216 print $FW "$CMD\000$PAD";
217 print $FW "$CMD\001$PAD";
218 appendfile($FW, "$tmpdir/fwtmp2");
219 print $FW "$CMD\001$PAD";
220 print $FW "$CMD\000$PAD";
223 verify("$tmpdir/fwtmp3", $hash);
224 copy("$tmpdir/fwtmp3", $outfile);
230 my $url = "http://www.linuxtv.org/downloads/firmware/dvb-dibusb-5.0.0.11.fw";
231 my $outfile = "dvb-dibusb-5.0.0.11.fw";
232 my $hash = "fa490295a527360ca16dcdf3224ca243";
236 wgetfile($outfile, $url);
237 verify($outfile,$hash);
243 my $sourcefile = "Broadband4PC_4_2_11.zip";
244 my $url = "http://www.bbti.us/download/windows/$sourcefile";
245 my $hash = "c6d2ea47a8f456d887ada0cfb718ff2a";
246 my $outfile = "dvb-fe-nxt2002.fw";
247 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
251 wgetfile($sourcefile, $url);
252 unzip($sourcefile, $tmpdir);
253 verify("$tmpdir/SkyNETU.sys", $hash);
254 extract("$tmpdir/SkyNETU.sys", 375832, 5908, $outfile);
260 my $sourcefile = "AVerTVHD_MCE_A180_Drv_v1.2.2.16.zip";
261 my $url = "http://www.aver.com/support/Drivers/$sourcefile";
262 my $hash = "111cb885b1e009188346d72acfed024c";
263 my $outfile = "dvb-fe-nxt2004.fw";
264 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
268 wgetfile($sourcefile, $url);
269 unzip($sourcefile, $tmpdir);
270 verify("$tmpdir/3xHybrid.sys", $hash);
271 extract("$tmpdir/3xHybrid.sys", 465304, 9584, $outfile);
277 my $fwfile = "dvb-fe-or51211.fw";
278 my $url = "http://linuxtv.org/downloads/firmware/$fwfile";
279 my $hash = "d830949c771a289505bf9eafc225d491";
283 wgetfile($fwfile, $url);
284 verify($fwfile, $hash);
290 my $fwfile = "dvb-fe-or51132-qam.fw";
291 my $url = "http://linuxtv.org/downloads/firmware/$fwfile";
292 my $hash = "7702e8938612de46ccadfe9b413cb3b5";
296 wgetfile($fwfile, $url);
297 verify($fwfile, $hash);
303 my $fwfile = "dvb-fe-or51132-vsb.fw";
304 my $url = "http://linuxtv.org/downloads/firmware/$fwfile";
305 my $hash = "c16208e02f36fc439a557ad4c613364a";
309 wgetfile($fwfile, $url);
310 verify($fwfile, $hash);
316 my $url = "http://www.linuxtv.org/download/dvb/firmware/dvb-usb-bluebird-01.fw";
317 my $outfile = "dvb-usb-bluebird-01.fw";
318 my $hash = "658397cb9eba9101af9031302671f49d";
322 wgetfile($outfile, $url);
323 verify($outfile,$hash);
328 # ---------------------------------------------------------------
332 if (system("which unzip > /dev/null 2>&1")) {
333 die "This firmware requires the unzip command - see ftp://ftp.info-zip.org/pub/infozip/UnZip.html\n";
335 if (system("which md5sum > /dev/null 2>&1")) {
336 die "This firmware requires the md5sum command - see http://www.gnu.org/software/coreutils/\n";
338 if (system("which wget > /dev/null 2>&1")) {
339 die "This firmware requires the wget command - see http://wget.sunsite.dk/\n";
344 if (system("which unshield > /dev/null 2>&1")) {
345 die "This firmware requires the unshield command - see http://sourceforge.net/projects/synce/\n";
350 my ($sourcefile, $url) = @_;
352 if (! -f $sourcefile) {
353 system("wget -O \"$sourcefile\" \"$url\"") and die "wget failed - unable to download firmware";
358 my ($sourcefile, $todir) = @_;
360 $status = system("unzip -q -o -d \"$todir\" \"$sourcefile\" 2>/dev/null" );
361 if ((($status >> 8) > 2) || (($status & 0xff) != 0)) {
362 die ("unzip failed - unable to extract firmware");
367 my ($sourcefile, $todir) = @_;
369 system("unshield x -d \"$todir\" \"$sourcefile\" > /dev/null" ) and die ("unshield failed - unable to extract firmware");
373 my ($filename, $hash) = @_;
376 open(CMD, "md5sum \"$filename\"|");
378 $testhash =~ /([a-zA-Z0-9]*)/;
381 die "Hash of extracted file does not match!\n" if ($testhash ne $hash);
385 my ($from, $to) = @_;
387 system("cp -f \"$from\" \"$to\"") and die ("cp failed");
391 my ($infile, $offset, $length, $outfile) = @_;
392 my ($chunklength, $buf, $rcount);
394 open INFILE, "<$infile";
395 open OUTFILE, ">$outfile";
396 sysseek(INFILE, $offset, SEEK_SET);
400 $chunklength = $length if ($chunklength > $length);
402 $rcount = sysread(INFILE, $buf, $chunklength);
403 die "Ran out of data\n" if ($rcount != $chunklength);
404 syswrite(OUTFILE, $buf);
412 my ($FH, $infile) = @_;
415 open INFILE, "<$infile";
417 $rcount = sysread(INFILE, $buf, 2048);
418 last if ($rcount == 0);
425 print STDERR "syntax: get_dvb_firmware <component>\n";
426 print STDERR "Supported components:\n";
427 for($i=0; $i < scalar(@components); $i++) {
428 print STDERR "\t" . $components[$i] . "\n";