V4L/DVB (5829): Firmware extract and loading for opera dvb-usb update

Better way of creating and loading the firmware used.
Update for get_dvb_firmware script to extract the files for opera usb-box
Help file for creating the firmware added

Signed-off-by: Marco Gittler <g.marco@freenet.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This commit is contained in:
Marco Gittler 2007-07-04 19:18:34 -03:00 committed by Mauro Carvalho Chehab
parent b31c33bd8b
commit 59800555f7
3 changed files with 97 additions and 8 deletions

View File

@ -24,7 +24,8 @@ use IO::Handle;
@components = ( "sp8870", "sp887x", "tda10045", "tda10046",
"tda10046lifeview", "av7110", "dec2000t", "dec2540t",
"dec3000s", "vp7041", "dibusb", "nxt2002", "nxt2004",
"or51211", "or51132_qam", "or51132_vsb", "bluebird");
"or51211", "or51132_qam", "or51132_vsb", "bluebird",
"opera1");
# Check args
syntax() if (scalar(@ARGV) != 1);
@ -210,6 +211,45 @@ sub dec3000s {
$outfile;
}
sub opera1{
my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 0);
checkstandard();
my $fwfile1="dvb-usb-opera1-fpga-01.fw";
my $fwfile2="dvb-usb-opera-01.fw";
extract("2830SCap2.sys", 0x62e8, 55024, "$tmpdir/opera1-fpga.fw");
extract("2830SLoad2.sys",0x3178,0x3685-0x3178,"$tmpdir/fw1part1");
extract("2830SLoad2.sys",0x0980,0x3150-0x0980,"$tmpdir/fw1part2");
delzero("$tmpdir/fw1part1","$tmpdir/fw1part1-1");
delzero("$tmpdir/fw1part2","$tmpdir/fw1part2-1");
verify("$tmpdir/fw1part1-1","5e0909858fdf0b5b09ad48b9fe622e70");
verify("$tmpdir/fw1part2-1","d6e146f321427e931df2c6fcadac37a1");
verify("$tmpdir/opera1-fpga.fw","0f8133f5e9051f5f3c1928f7e5a1b07d");
my $RES1="\x01\x92\x7f\x00\x01\x00";
my $RES0="\x01\x92\x7f\x00\x00\x00";
my $DAT1="\x01\x00\xe6\x00\x01\x00";
my $DAT0="\x01\x00\xe6\x00\x00\x00";
open FW,">$tmpdir/opera.fw";
print FW "$RES1";
print FW "$DAT1";
print FW "$RES1";
print FW "$DAT1";
appendfile(FW,"$tmpdir/fw1part1-1");
print FW "$RES0";
print FW "$DAT0";
print FW "$RES1";
print FW "$DAT1";
appendfile(FW,"$tmpdir/fw1part2-1");
print FW "$RES1";
print FW "$DAT1";
print FW "$RES0";
print FW "$DAT0";
copy ("$tmpdir/opera1-fpga.fw",$fwfile1);
copy ("$tmpdir/opera.fw",$fwfile2);
$fwfile1.",".$fwfile2;
}
sub vp7041 {
my $sourcefile = "2.422.zip";
@ -440,6 +480,25 @@ sub appendfile {
close(INFILE);
}
sub delzero{
my ($infile,$outfile) =@_;
open INFILE,"<$infile";
open OUTFILE,">$outfile";
while (1){
$rcount=sysread(INFILE,$buf,22);
$len=ord(substr($buf,0,1));
print OUTFILE substr($buf,0,1);
print OUTFILE substr($buf,2,$len+3);
last if ($rcount<1);
printf OUTFILE "%c",0;
#print $len." ".length($buf)."\n";
}
close(INFILE);
close(OUTFILE);
}
sub syntax() {
print STDERR "syntax: get_dvb_firmware <component>\n";
print STDERR "Supported components:\n";

View File

@ -0,0 +1,27 @@
To extract the firmware for the Opera DVB-S1 USB-Box
you need to copy the files:
2830SCap2.sys
2830SLoad2.sys
from the windriver disk into this directory.
Then run
./get_dvb_firware opera1
and after that you have 2 files:
dvb-usb-opera-01.fw
dvb-usb-opera1-fpga-01.fw
in here.
Copy them into /lib/firmware/ .
After that the driver can load the firmware
(if you have enabled firmware loading
in kernel config and have hotplug running).
Marco Gittler <g.marco@freenet.de>

View File

@ -435,9 +435,9 @@ static int opera1_xilinx_load_firmware(struct usb_device *dev,
{
const struct firmware *fw = NULL;
u8 *b, *p;
int ret = 0, i;
int ret = 0, i,fpgasize=40;
u8 testval;
info("start downloading fpga firmware");
info("start downloading fpga firmware %s",filename);
if ((ret = request_firmware(&fw, filename, &dev->dev)) != 0) {
err("did not find the firmware file. (%s) "
@ -454,17 +454,20 @@ static int opera1_xilinx_load_firmware(struct usb_device *dev,
/* clear fpga ? */
opera1_xilinx_rw(dev, 0xbc, 0xaa, &fpga_command, 1,
OPERA_WRITE_MSG);
for (i = 0; p[i] != 0 && i < fw->size;) {
for (i = 0; i < fw->size;) {
if ( (fw->size - i) <fpgasize){
fpgasize=fw->size-i;
}
b = (u8 *) p + i;
if (opera1_xilinx_rw
(dev, OPERA_WRITE_FX2, 0x0, b + 1, b[0],
OPERA_WRITE_MSG) != b[0]
(dev, OPERA_WRITE_FX2, 0x0, b , fpgasize,
OPERA_WRITE_MSG) != fpgasize
) {
err("error while transferring firmware");
ret = -EINVAL;
break;
}
i = i + 1 + b[0];
i = i + fpgasize;
}
/* restart the CPU */
if (ret || opera1_xilinx_rw
@ -538,7 +541,7 @@ static int opera1_probe(struct usb_interface *intf,
if (udev->descriptor.idProduct == USB_PID_OPERA1_WARM &&
udev->descriptor.idVendor == USB_VID_OPERA1 &&
opera1_xilinx_load_firmware(udev, "dvb-usb-opera1-fpga.fw") != 0
opera1_xilinx_load_firmware(udev, "dvb-usb-opera1-fpga-01.fw") != 0
) {
return -EINVAL;
}