* [PATCH 0/5] v4l-utils: add some scripts from the wiki.
@ 2012-10-10 13:39 Antonio Ospite
2012-10-10 13:39 ` [PATCH 1/5] contrib: add some scripts to extract m920x firmwares from USB dumps Antonio Ospite
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Antonio Ospite @ 2012-10-10 13:39 UTC (permalink / raw)
To: linux-media; +Cc: Aapo Tahkola, Antonio Ospite, CityK
Hi,
I recently used some scripts I found on the linuxtv.org wiki to extract
a firmware for a m920x device from USB dumps made with UsbSniff2.0 on
WIndows XP.
I thought these scripts may be collected in v4l-utils where it is easier
to change them.
The first two patches add the scripts as they are now on the wiki, I am
sending them on behalf of the original author even if I was not able to
contact him, I hope this is OK.
The subsequent changes are little fixes to make m920x_parse.pl work for me.
Regards,
Antonio
Aapo Tahkola (2):
contrib: add some scripts to extract m920x firmwares from USB dumps
contrib: add a script to convert usbmon captures to usbsnoop
Antonio Ospite (3):
m920x_parse.pl: use string comparison operators
m920x_parse.pl: fix strict and warnings checks
m920x_parse.pl: add support for consuming the output of
parse-sniffusb2.pl
contrib/m920x/m920x_parse.pl | 295 ++++++++++++++++++++++++++++++++++++
contrib/m920x/m920x_sp_firmware.pl | 115 ++++++++++++++
contrib/usbmon2usbsnoop.pl | 53 +++++++
3 files changed, 463 insertions(+)
create mode 100755 contrib/m920x/m920x_parse.pl
create mode 100755 contrib/m920x/m920x_sp_firmware.pl
create mode 100755 contrib/usbmon2usbsnoop.pl
--
Antonio Ospite
http://ao2.it
A: Because it messes up the order in which people normally read text.
See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/5] contrib: add some scripts to extract m920x firmwares from USB dumps
2012-10-10 13:39 [PATCH 0/5] v4l-utils: add some scripts from the wiki Antonio Ospite
@ 2012-10-10 13:39 ` Antonio Ospite
2012-10-10 13:39 ` [PATCH 2/5] contrib: add a script to convert usbmon captures to usbsnoop Antonio Ospite
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Antonio Ospite @ 2012-10-10 13:39 UTC (permalink / raw)
To: linux-media; +Cc: Aapo Tahkola, CityK
From: Aapo Tahkola <aet@rasterburn.org>
Signed-off-by: Aapo Tahkola <aet@rasterburn.org>
---
contrib/m920x/m920x_parse.pl | 277 ++++++++++++++++++++++++++++++++++++
contrib/m920x/m920x_sp_firmware.pl | 115 +++++++++++++++
2 files changed, 392 insertions(+)
create mode 100755 contrib/m920x/m920x_parse.pl
create mode 100755 contrib/m920x/m920x_sp_firmware.pl
diff --git a/contrib/m920x/m920x_parse.pl b/contrib/m920x/m920x_parse.pl
new file mode 100755
index 0000000..135ed5a
--- /dev/null
+++ b/contrib/m920x/m920x_parse.pl
@@ -0,0 +1,277 @@
+#!/usr/bin/perl
+#
+# This ULi M920x specific script processes usbsnoop log files (as well as those which have been parsed by mrec's parser.pl utility).
+# Taken from http://www.linuxtv.org/wiki/index.php/ULi_M920x_parse
+
+use Getopt::Std;
+
+sub expand_string {
+ my @arr = ();
+ my ($str) = @_;
+
+ if (length($str) == 8) {
+ push(@arr, substr($str, 0, 2));
+ push(@arr, substr($str, 2, 2));
+ push(@arr, substr($str, 4, 2));
+ push(@arr, substr($str, 6, 2));
+ }elsif(length($str) == 4) {
+ push(@arr, substr($str, 0, 2));
+ push(@arr, substr($str, 2, 2));
+ }elsif(length($str) == 2) {
+ push(@arr, $str);
+ }elsif(length($str) == 1) {
+ return;
+ }
+ return @arr;
+}
+
+sub expand_string_long {
+ my @bytes = ();
+ my (@str) = @_;
+
+ foreach(@str) {
+ #@arr = expand_string($_);
+ #foreach(@arr){
+ # push(@bytes, $_);
+ #}
+ @bytes = ( @bytes, expand_string($_) );
+ }
+
+ return @bytes;
+}
+
+sub print_array_bytes {
+ my (@str) = @_;
+
+ foreach(expand_string_long(@str)){
+ print "$_ ";
+ }
+}
+
+sub print_bytes {
+ my ($str) = @_;
+
+ print_array_bytes(split(/ /, $str));
+}
+
+sub check {
+ my ($cmd, @bytes) = @_;
+ my @cmp;
+ my $i;
+ #print "cmd <$cmd>\n";
+ my $fail = 0;
+
+ @cmp = split(/ /, $cmd);
+ for ($i = 0; $i < scalar(@cmp); $i++) {
+ #print "check $bytes[$i] vs $cmp[$i]\n";
+ if ($cmp[$i] == "-1") {
+ next;
+ }
+
+ if (not($bytes[$i] =~ m/$cmp[$i]/)) {
+ $fail = 1;
+ print "($bytes[$i]!=$cmp[$i], $i)";
+ }
+ }
+ if ($fail) {
+ print "\n";
+ print_array_bytes(@bytes);
+ print "\n$cmd\n";
+ }
+}
+
+sub get_line {
+ my ($cmd) = @_; # xxx: could be more flexible
+ my @ret;
+ my @cmp;
+ my $i;
+
+ again:
+ while($line = <STDIN>) {
+ #001295: OUT: 000002 ms 135775 ms 40 23 c0 00 80 00 00 00 >>>
+ if($input eq "us" && $line =~ m/\S+: \S+: \S+ ms \S+ ms ([a-fA-F0-9 ]+)/) {
+ @ret = split(/ /, $1); $foo = $1;
+ @ret[2,3,4,5,6,7] = @ret[3,2,5,4,7,6];
+ last;
+ }
+
+ if($input eq "um" && $line =~ m/\S+ \S+ \S+ \S+ s ([a-fA-F0-9 ]+)/) {
+ @ret = expand_string_long(split(/ /, $1)); $foo = $1;
+ last;
+ }
+ }
+ @cmp = split(/ /, $cmd);
+ for ($i = 0; $i < scalar(@cmp); $i++) {
+ if ($cmp[$i] == "-1") {
+ next;
+ }
+
+ if (not($cmp[$i] eq $ret[$i])) {
+ #print "fail\n";
+ goto again;
+ }
+ }
+
+ return @ret;
+}
+
+sub us_get_write {
+ #print "<$line>\n";
+ if($input == "us" && $line =~ m/>>>\s+([a-fA-F0-9 ]+)/) {
+ return split(/ /, $1);
+ }
+ if($input == "um") {
+ if($line =~ m/\S+ \S+ \S+ \S+ \S+ \S+ \S+ \S+ \S+ \S+ \S+ = ([a-fA-F0-9 ]+)/) {
+ #print "read match $line\n";
+ return expand_string_long(split(/ /, $1));
+ }
+ }
+}
+
+sub get_read {
+ #print "<$line>\n";
+ if($input == "us" && $line =~ m/<<< ([a-fA-F0-9 ]+)/) {
+ return split(/ /, $1);
+ }
+ if($input == "um") {
+ while($line = <STDIN>) {
+ if($line =~ m/\S+ \S+ \S+ \S+ \S+ \S+ = ([a-fA-F0-9 ]+)/) {
+ return expand_string_long(split(/ /, $1));
+ }
+
+ }
+ }
+}
+
+sub usage {
+ print STDERR << "EOF";
+
+ -i um (usbmon)
+ us (usb snoop)
+ sp (snoopy pro)
+
+ -m fw (extract firmware)
+ i2c (show i2c traffic)
+EOF
+exit;
+}
+
+getopts("m:i:", \%opt ) or usage();
+
+$mode = $opt{m};
+$input = $opt{i};
+
+if ($input != "um" && $input != "us" && $input != "sp") {
+ usage();
+}
+
+if ($mode != "fw" && $mode != "i2c") {
+ usage();
+}
+
+if ($mode eq "fw") {
+ open(out, ">fw") || die "Can't open fw";
+
+ while(@bytes = get_line()) {
+ if(scalar(@bytes) <= 1) {
+ last;
+ }
+
+ $len = hex($bytes[6] . $bytes[7]);
+ if ($len < 32) {
+ next;
+ }
+
+ @fw_bytes = us_get_write();
+ if ($len != scalar(@fw_bytes)) {
+ #note: usbmon will not log bulk writes longer than 32 bytes by default
+ print "bulk size doesn't match! Check usbmon.\n";
+ print $len . " != " . scalar(@fw_bytes) . "\n";
+ exit(0);
+ }
+ print out pack("v", hex($bytes[2] . $bytes[3]));
+ print out pack("v", hex($bytes[4] . $bytes[5]));
+ print out pack("v", scalar(@fw_bytes));
+
+ foreach(@fw_bytes) {
+ print out pack("C", hex($_));
+ }
+ }
+ exit(1);
+}
+
+while(@bytes = get_line("-1")) {
+ if(scalar(@bytes) <= 1) {
+ last;
+ }
+
+ $master_line = $. - 1;
+
+ if ($bytes[0] == "40" && $bytes[1] == "23") {
+
+ if ($bytes[4] == "80" || $bytes[4] == "00") {
+ my $multibyte = 0;
+ my $addr;
+
+ $addr = $bytes[2];
+
+ printf "%06d: ", $master_line;
+ print "addr $addr ";
+
+ if (hex($addr) & 0x1) {
+ print "Invalid address\n";
+ }
+
+ @bytes = get_line("40 23");
+
+ $reg = $bytes[2];
+ if ($bytes[4] == "80") {
+ $multibyte = 1;
+ } else {
+ @bytes = get_line("40 23");
+ }
+ #if ($bytes[4] != "40") {
+ # print "(missing 40)";
+ #}
+
+ if ($bytes[4] == "80") {
+ if ($multibyte == 0) {
+ $raddr = sprintf("%02x", hex($addr) | 0x1);
+
+ check("40 23 $raddr 00 80 00 00 00", @bytes);
+
+ @bytes = get_line("c0 23");
+ print "reg $reg = ";
+ } else {
+ print "$reg = ";
+ @bytes = get_line("c0 23");
+ while ($bytes[4] == "21") {
+ check("c0 23 00 00 21 00 -1 -1", @bytes);
+
+ @bytes = get_read();
+ print_array_bytes(@bytes);
+
+ @bytes = get_line("c0 23");
+ }
+ }
+
+ check("c0 23 -1 00 60 00 -1 -1", @bytes);
+
+ @bytes = get_read();
+ print_array_bytes(@bytes);
+ print "read\n";
+
+ } else {
+ check("40 23 -1 00 4|00 00 00 00", @bytes);
+ print "reg $reg = $bytes[2]";
+
+ while ($bytes[4] != "40") {
+ @bytes = get_line("40 23");
+ check("40 23 -1 00 4|00 00 00 00", @bytes);
+ print " $bytes[2]";
+ }
+ print "\n";
+ }
+ }
+ }
+}
diff --git a/contrib/m920x/m920x_sp_firmware.pl b/contrib/m920x/m920x_sp_firmware.pl
new file mode 100755
index 0000000..3c1f0fd
--- /dev/null
+++ b/contrib/m920x/m920x_sp_firmware.pl
@@ -0,0 +1,115 @@
+#!/usr/bin/perl
+#
+# This script converts the output from SnoopyPro's log window into a M920x driver compatible binary form.
+# Taken from http://www.linuxtv.org/wiki/index.php/ULi_M920x_sp_firmware
+
+sub get_line {
+
+
+ while($line = <STDIN>) {
+ if($line =~ m/\S+ \S+ \S+ \S+ \S+ \S+ \S+ \S+ \S+ \S+ \S+/) {
+ #print "returning line $line";
+ return $line;
+ }else{
+ #print "not matched $line\n";
+ }
+ }
+
+ #exit;
+}
+
+sub get_line_read {
+
+ while($line = <STDIN>) {
+
+ #d5748560 78669980 C Ci:004:00 0 1 = 50
+ #d3ea8260 44357030 C Ci:004:00 0 1 = bc
+ if($line =~ m/\S+ \S+ C \S+ \S+ (\S+) = (\S+)/) {
+ return $2;
+ }else{
+ #print "not matched $line\n";
+ }
+ }
+
+}
+
+$linenum = 0;
+sub get_tf_data {
+ $full = "";
+
+ $line = <STDIN>; $linenum++;
+ while($line =~ m/^\S\S\S\S: (.+)/) {
+ $full .= $1;
+ #print "$1";
+ $line = <STDIN>; $linenum++;
+ }
+ return $full;
+}
+
+open(out,">fw") || die "Can't open fw";
+
+sub write_bytes {
+ my($str) = @_;
+
+ #print "ds $str sd\n";
+
+ @bytes = split(/ /, $str);
+ foreach(@bytes){
+ #print "$_\n";
+ print out pack("C", hex($_));
+ }
+
+ #exit(1);
+}
+
+sub to_words {
+ my($str) = @_;
+
+ print "ds $str sd\n";
+
+ @bytes = split(/\S+ \S+/, $str);
+ foreach(@bytes){
+ print "$_\n";
+ print out pack("v", hex($_));
+ }
+
+ exit(1);
+}
+
+while($line = <STDIN>) { $linenum++;
+
+ if($line =~ m/SetupPacket:/) {
+ $setup_linenum = $linenum;
+ $setup = get_tf_data();
+
+ #to_words($setup);
+
+ #write_bytes($setup);
+
+ #print "$line\n";
+
+ while($line = <STDIN>) { $linenum++;
+ if($line =~ m/TransferBuffer: 0x00000040/) {
+ #print "$setup, $setup_linenum\n";
+
+ @bytes = split(/ /, $setup);
+ print out pack("v", hex($bytes[3] . $bytes[2]));
+ print out pack("v", hex($bytes[5] . $bytes[4]));
+ print out pack("v", hex("0x40"));
+
+ $lid = get_tf_data();
+ write_bytes($lid);
+ #print $lid;
+ #print "\n";
+
+ last;
+ }elsif($line =~ m/No TransferBuffer/) {
+ last;
+ }elsif($line =~ m/TransferBuffer:/) {
+ last;
+ }
+
+ }
+ }
+
+}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/5] contrib: add a script to convert usbmon captures to usbsnoop
2012-10-10 13:39 [PATCH 0/5] v4l-utils: add some scripts from the wiki Antonio Ospite
2012-10-10 13:39 ` [PATCH 1/5] contrib: add some scripts to extract m920x firmwares from USB dumps Antonio Ospite
@ 2012-10-10 13:39 ` Antonio Ospite
2012-10-10 13:39 ` [PATCH 3/5] m920x_parse.pl: use string comparison operators Antonio Ospite
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Antonio Ospite @ 2012-10-10 13:39 UTC (permalink / raw)
To: linux-media; +Cc: Aapo Tahkola, CityK
From: Aapo Tahkola <aet@rasterburn.org>
This makes it possible to reuse tools written for usbsnoop with captures
done using a virtual machine and usbmon.
Signed-off-by: Aapo Tahkola <aet@rasterburn.org>
---
contrib/usbmon2usbsnoop.pl | 53 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
create mode 100755 contrib/usbmon2usbsnoop.pl
diff --git a/contrib/usbmon2usbsnoop.pl b/contrib/usbmon2usbsnoop.pl
new file mode 100755
index 0000000..c656687
--- /dev/null
+++ b/contrib/usbmon2usbsnoop.pl
@@ -0,0 +1,53 @@
+#!/usr/bin/perl
+#
+# This perl script converts output from usbmon to a format (usbsnoop's log format) that is compatible with usbreplay.
+# Taken from http://www.linuxtv.org/wiki/index.php/Usbmon2usbsnoop
+
+sub print_bytes{
+ my($str) = @_;
+
+ @str_1 = split(/ /, $str);
+
+ foreach(@str_1){
+ if (length($_) == 8) {
+ print substr($_, 0, 2) . " " . substr($_, 2, 2) . " " . substr($_, 4, 2) . " " . substr($_, 6, 2);
+ }elsif(length($_) == 4) {
+ print substr($_, 2, 2) . " " . substr($_, 0, 2);
+ }elsif(length($_) == 2) {
+ print $_;
+ }elsif(length($_) == 1) {
+ next;
+ }
+ print " ";
+ }
+}
+
+
+$i = 0;
+while($line = <STDIN>) {
+ $i++;
+
+ if($line =~ m/\S+ \S+ \S+ \S+ \S+ (.+) \S+ </) {
+ printf "%06d: OUT: %06d ms %06d ms ", $i, 1, $i;
+ print_bytes($1);
+ print "<<< ";
+ $line = <STDIN>;
+ $i++;
+ if($line =~ m/\S+ \S+ \S+ \S+ [a-fA-F0-9 ]+ = ([a-fA-F0-9 ]+)/) {
+ print_bytes($1);
+ #print "\n";
+ #print " $1\n";
+ }
+ print "\n";
+ }elsif($line =~ m/\S+ \S+ \S+ \S+ ([a-fA-F0-9 ]+) [a-fA-F0-9]+ = ([a-fA-F0-9 ]+)/) {
+ printf "%06d: OUT: %06d ms %06d ms ", $i, 1, $i;
+ print_bytes($1);
+ print ">>> ";
+ print_bytes($2);
+ print "\n";
+ }elsif($line =~ m/\S+ \S+ \S+ \S+ s (.+)/) {
+ printf "%06d: OUT: %06d ms %06d ms ", $i, 1, $i;
+ print_bytes($1);
+ print ">>>\n";
+ }
+}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/5] m920x_parse.pl: use string comparison operators
2012-10-10 13:39 [PATCH 0/5] v4l-utils: add some scripts from the wiki Antonio Ospite
2012-10-10 13:39 ` [PATCH 1/5] contrib: add some scripts to extract m920x firmwares from USB dumps Antonio Ospite
2012-10-10 13:39 ` [PATCH 2/5] contrib: add a script to convert usbmon captures to usbsnoop Antonio Ospite
@ 2012-10-10 13:39 ` Antonio Ospite
2012-10-10 13:39 ` [PATCH 4/5] m920x_parse.pl: fix strict and warnings checks Antonio Ospite
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Antonio Ospite @ 2012-10-10 13:39 UTC (permalink / raw)
To: linux-media; +Cc: Aapo Tahkola, Antonio Ospite, CityK
---
contrib/m920x/m920x_parse.pl | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/contrib/m920x/m920x_parse.pl b/contrib/m920x/m920x_parse.pl
index 135ed5a..9093e16 100755
--- a/contrib/m920x/m920x_parse.pl
+++ b/contrib/m920x/m920x_parse.pl
@@ -64,7 +64,7 @@ sub check {
@cmp = split(/ /, $cmd);
for ($i = 0; $i < scalar(@cmp); $i++) {
#print "check $bytes[$i] vs $cmp[$i]\n";
- if ($cmp[$i] == "-1") {
+ if ($cmp[$i] eq "-1") {
next;
}
@@ -102,7 +102,7 @@ sub get_line {
}
@cmp = split(/ /, $cmd);
for ($i = 0; $i < scalar(@cmp); $i++) {
- if ($cmp[$i] == "-1") {
+ if ($cmp[$i] eq "-1") {
next;
}
@@ -117,10 +117,10 @@ sub get_line {
sub us_get_write {
#print "<$line>\n";
- if($input == "us" && $line =~ m/>>>\s+([a-fA-F0-9 ]+)/) {
+ if($input eq "us" && $line =~ m/>>>\s+([a-fA-F0-9 ]+)/) {
return split(/ /, $1);
}
- if($input == "um") {
+ if($input eq "um") {
if($line =~ m/\S+ \S+ \S+ \S+ \S+ \S+ \S+ \S+ \S+ \S+ \S+ = ([a-fA-F0-9 ]+)/) {
#print "read match $line\n";
return expand_string_long(split(/ /, $1));
@@ -130,10 +130,10 @@ sub us_get_write {
sub get_read {
#print "<$line>\n";
- if($input == "us" && $line =~ m/<<< ([a-fA-F0-9 ]+)/) {
+ if($input eq "us" && $line =~ m/<<< ([a-fA-F0-9 ]+)/) {
return split(/ /, $1);
}
- if($input == "um") {
+ if($input eq "um") {
while($line = <STDIN>) {
if($line =~ m/\S+ \S+ \S+ \S+ \S+ \S+ = ([a-fA-F0-9 ]+)/) {
return expand_string_long(split(/ /, $1));
@@ -161,11 +161,11 @@ getopts("m:i:", \%opt ) or usage();
$mode = $opt{m};
$input = $opt{i};
-if ($input != "um" && $input != "us" && $input != "sp") {
+if ($input ne "um" && $input ne "us" && $input ne "sp") {
usage();
}
-if ($mode != "fw" && $mode != "i2c") {
+if ($mode ne "fw" && $mode ne "i2c") {
usage();
}
@@ -207,9 +207,9 @@ while(@bytes = get_line("-1")) {
$master_line = $. - 1;
- if ($bytes[0] == "40" && $bytes[1] == "23") {
+ if ($bytes[0] eq "40" && $bytes[1] eq "23") {
- if ($bytes[4] == "80" || $bytes[4] == "00") {
+ if ($bytes[4] eq "80" || $bytes[4] eq "00") {
my $multibyte = 0;
my $addr;
@@ -225,16 +225,16 @@ while(@bytes = get_line("-1")) {
@bytes = get_line("40 23");
$reg = $bytes[2];
- if ($bytes[4] == "80") {
+ if ($bytes[4] eq "80") {
$multibyte = 1;
} else {
@bytes = get_line("40 23");
}
- #if ($bytes[4] != "40") {
+ #if ($bytes[4] ne "40") {
# print "(missing 40)";
#}
- if ($bytes[4] == "80") {
+ if ($bytes[4] eq "80") {
if ($multibyte == 0) {
$raddr = sprintf("%02x", hex($addr) | 0x1);
@@ -245,7 +245,7 @@ while(@bytes = get_line("-1")) {
} else {
print "$reg = ";
@bytes = get_line("c0 23");
- while ($bytes[4] == "21") {
+ while ($bytes[4] eq "21") {
check("c0 23 00 00 21 00 -1 -1", @bytes);
@bytes = get_read();
@@ -265,7 +265,7 @@ while(@bytes = get_line("-1")) {
check("40 23 -1 00 4|00 00 00 00", @bytes);
print "reg $reg = $bytes[2]";
- while ($bytes[4] != "40") {
+ while ($bytes[4] ne "40") {
@bytes = get_line("40 23");
check("40 23 -1 00 4|00 00 00 00", @bytes);
print " $bytes[2]";
--
1.7.10.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/5] m920x_parse.pl: fix strict and warnings checks
2012-10-10 13:39 [PATCH 0/5] v4l-utils: add some scripts from the wiki Antonio Ospite
` (2 preceding siblings ...)
2012-10-10 13:39 ` [PATCH 3/5] m920x_parse.pl: use string comparison operators Antonio Ospite
@ 2012-10-10 13:39 ` Antonio Ospite
2012-10-10 13:39 ` [PATCH 5/5] m920x_parse.pl: add support for consuming the output of parse-sniffusb2.pl Antonio Ospite
2012-10-10 14:22 ` [PATCH 0/5] v4l-utils: add some scripts from the wiki Antti Palosaari
5 siblings, 0 replies; 8+ messages in thread
From: Antonio Ospite @ 2012-10-10 13:39 UTC (permalink / raw)
To: linux-media; +Cc: Aapo Tahkola, Antonio Ospite, CityK
Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
---
contrib/m920x/m920x_parse.pl | 30 ++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/contrib/m920x/m920x_parse.pl b/contrib/m920x/m920x_parse.pl
index 9093e16..b315400 100755
--- a/contrib/m920x/m920x_parse.pl
+++ b/contrib/m920x/m920x_parse.pl
@@ -3,8 +3,15 @@
# This ULi M920x specific script processes usbsnoop log files (as well as those which have been parsed by mrec's parser.pl utility).
# Taken from http://www.linuxtv.org/wiki/index.php/ULi_M920x_parse
+use strict;
+use warnings;
use Getopt::Std;
+my $line;
+my $mode;
+my $input;
+my %opt;
+
sub expand_string {
my @arr = ();
my ($str) = @_;
@@ -85,6 +92,7 @@ sub get_line {
my @ret;
my @cmp;
my $i;
+ my $foo;
again:
while($line = <STDIN>) {
@@ -169,32 +177,34 @@ if ($mode ne "fw" && $mode ne "i2c") {
usage();
}
+my @bytes;
+
if ($mode eq "fw") {
- open(out, ">fw") || die "Can't open fw";
+ open(OUT, ">", "fw") || die "Can't open fw";
while(@bytes = get_line()) {
if(scalar(@bytes) <= 1) {
last;
}
- $len = hex($bytes[6] . $bytes[7]);
+ my $len = hex($bytes[6] . $bytes[7]);
if ($len < 32) {
next;
}
- @fw_bytes = us_get_write();
+ my @fw_bytes = us_get_write();
if ($len != scalar(@fw_bytes)) {
#note: usbmon will not log bulk writes longer than 32 bytes by default
print "bulk size doesn't match! Check usbmon.\n";
print $len . " != " . scalar(@fw_bytes) . "\n";
exit(0);
}
- print out pack("v", hex($bytes[2] . $bytes[3]));
- print out pack("v", hex($bytes[4] . $bytes[5]));
- print out pack("v", scalar(@fw_bytes));
+ print OUT pack("v", hex($bytes[2] . $bytes[3]));
+ print OUT pack("v", hex($bytes[4] . $bytes[5]));
+ print OUT pack("v", scalar(@fw_bytes));
foreach(@fw_bytes) {
- print out pack("C", hex($_));
+ print OUT pack("C", hex($_));
}
}
exit(1);
@@ -205,7 +215,7 @@ while(@bytes = get_line("-1")) {
last;
}
- $master_line = $. - 1;
+ my $master_line = $. - 1;
if ($bytes[0] eq "40" && $bytes[1] eq "23") {
@@ -224,7 +234,7 @@ while(@bytes = get_line("-1")) {
@bytes = get_line("40 23");
- $reg = $bytes[2];
+ my $reg = $bytes[2];
if ($bytes[4] eq "80") {
$multibyte = 1;
} else {
@@ -236,7 +246,7 @@ while(@bytes = get_line("-1")) {
if ($bytes[4] eq "80") {
if ($multibyte == 0) {
- $raddr = sprintf("%02x", hex($addr) | 0x1);
+ my $raddr = sprintf("%02x", hex($addr) | 0x1);
check("40 23 $raddr 00 80 00 00 00", @bytes);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/5] m920x_parse.pl: add support for consuming the output of parse-sniffusb2.pl
2012-10-10 13:39 [PATCH 0/5] v4l-utils: add some scripts from the wiki Antonio Ospite
` (3 preceding siblings ...)
2012-10-10 13:39 ` [PATCH 4/5] m920x_parse.pl: fix strict and warnings checks Antonio Ospite
@ 2012-10-10 13:39 ` Antonio Ospite
2012-10-10 14:22 ` [PATCH 0/5] v4l-utils: add some scripts from the wiki Antti Palosaari
5 siblings, 0 replies; 8+ messages in thread
From: Antonio Ospite @ 2012-10-10 13:39 UTC (permalink / raw)
To: linux-media; +Cc: Aapo Tahkola, Antonio Ospite, CityK
---
contrib/m920x/m920x_parse.pl | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/contrib/m920x/m920x_parse.pl b/contrib/m920x/m920x_parse.pl
index b315400..b309250 100755
--- a/contrib/m920x/m920x_parse.pl
+++ b/contrib/m920x/m920x_parse.pl
@@ -103,6 +103,13 @@ sub get_line {
last;
}
+ #40 23 c0 00 80 00 00 00 >>>
+ if($input eq "us2" && $line =~ m/([a-fA-F0-9 ]+)/) {
+ @ret = split(/ /, $1); $foo = $1;
+ @ret[2,3,4,5,6,7] = @ret[3,2,5,4,7,6];
+ last;
+ }
+
if($input eq "um" && $line =~ m/\S+ \S+ \S+ \S+ s ([a-fA-F0-9 ]+)/) {
@ret = expand_string_long(split(/ /, $1)); $foo = $1;
last;
@@ -125,7 +132,7 @@ sub get_line {
sub us_get_write {
#print "<$line>\n";
- if($input eq "us" && $line =~ m/>>>\s+([a-fA-F0-9 ]+)/) {
+ if(($input eq "us" || $input eq "us2") && $line =~ m/>>>\s+([a-fA-F0-9 ]+)/) {
return split(/ /, $1);
}
if($input eq "um") {
@@ -138,7 +145,7 @@ sub us_get_write {
sub get_read {
#print "<$line>\n";
- if($input eq "us" && $line =~ m/<<< ([a-fA-F0-9 ]+)/) {
+ if(($input eq "us" || $input eq "us2") && $line =~ m/<<<\s+([a-fA-F0-9 ]+)/) {
return split(/ /, $1);
}
if($input eq "um") {
@@ -156,6 +163,7 @@ sub usage {
-i um (usbmon)
us (usb snoop)
+ us2 (usb snoop as produced by parse-sniffusb2.pl)
sp (snoopy pro)
-m fw (extract firmware)
@@ -169,7 +177,7 @@ getopts("m:i:", \%opt ) or usage();
$mode = $opt{m};
$input = $opt{i};
-if ($input ne "um" && $input ne "us" && $input ne "sp") {
+if ($input ne "um" && $input ne "us" && $input ne "us2" && $input ne "sp") {
usage();
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 0/5] v4l-utils: add some scripts from the wiki.
2012-10-10 13:39 [PATCH 0/5] v4l-utils: add some scripts from the wiki Antonio Ospite
` (4 preceding siblings ...)
2012-10-10 13:39 ` [PATCH 5/5] m920x_parse.pl: add support for consuming the output of parse-sniffusb2.pl Antonio Ospite
@ 2012-10-10 14:22 ` Antti Palosaari
2012-10-10 14:53 ` Antonio Ospite
5 siblings, 1 reply; 8+ messages in thread
From: Antti Palosaari @ 2012-10-10 14:22 UTC (permalink / raw)
To: Antonio Ospite; +Cc: linux-media, Aapo Tahkola, CityK
On 10/10/2012 04:39 PM, Antonio Ospite wrote:
> Hi,
>
> I recently used some scripts I found on the linuxtv.org wiki to extract
> a firmware for a m920x device from USB dumps made with UsbSniff2.0 on
> WIndows XP.
>
> I thought these scripts may be collected in v4l-utils where it is easier
> to change them.
>
> The first two patches add the scripts as they are now on the wiki, I am
> sending them on behalf of the original author even if I was not able to
> contact him, I hope this is OK.
I am almost 100% it is not OK to sign those to Kernel behalf of Aapo.
Maybe it is possible to keep Aapo as a author, but sign with yourself.
>
> The subsequent changes are little fixes to make m920x_parse.pl work for me.
>
> Regards,
> Antonio
>
>
> Aapo Tahkola (2):
> contrib: add some scripts to extract m920x firmwares from USB dumps
> contrib: add a script to convert usbmon captures to usbsnoop
>
> Antonio Ospite (3):
> m920x_parse.pl: use string comparison operators
> m920x_parse.pl: fix strict and warnings checks
> m920x_parse.pl: add support for consuming the output of
> parse-sniffusb2.pl
>
> contrib/m920x/m920x_parse.pl | 295 ++++++++++++++++++++++++++++++++++++
> contrib/m920x/m920x_sp_firmware.pl | 115 ++++++++++++++
> contrib/usbmon2usbsnoop.pl | 53 +++++++
> 3 files changed, 463 insertions(+)
> create mode 100755 contrib/m920x/m920x_parse.pl
> create mode 100755 contrib/m920x/m920x_sp_firmware.pl
> create mode 100755 contrib/usbmon2usbsnoop.pl
>
regards
Antti
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/5] v4l-utils: add some scripts from the wiki.
2012-10-10 14:22 ` [PATCH 0/5] v4l-utils: add some scripts from the wiki Antti Palosaari
@ 2012-10-10 14:53 ` Antonio Ospite
0 siblings, 0 replies; 8+ messages in thread
From: Antonio Ospite @ 2012-10-10 14:53 UTC (permalink / raw)
To: Antti Palosaari; +Cc: linux-media
On Wed, 10 Oct 2012 17:22:53 +0300
Antti Palosaari <crope@iki.fi> wrote:
> On 10/10/2012 04:39 PM, Antonio Ospite wrote:
> > Hi,
> >
> > I recently used some scripts I found on the linuxtv.org wiki to extract
> > a firmware for a m920x device from USB dumps made with UsbSniff2.0 on
> > WIndows XP.
> >
> > I thought these scripts may be collected in v4l-utils where it is easier
> > to change them.
> >
> > The first two patches add the scripts as they are now on the wiki, I am
> > sending them on behalf of the original author even if I was not able to
> > contact him, I hope this is OK.
>
> I am almost 100% it is not OK to sign those to Kernel behalf of Aapo.
> Maybe it is possible to keep Aapo as a author, but sign with yourself.
>
I can do that of course, I'll wait some days to see if anyone else has
an opinion on that.
BTW if anyone here has the new Appo Tahkola's email address I will ask
him directly too.
Thanks,
Antonio
P.S. removed Aapo and CityK from CC as I get Delivery error messages on
both addresses.
--
Antonio Ospite
http://ao2.it
A: Because it messes up the order in which people normally read text.
See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-10-10 14:53 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-10 13:39 [PATCH 0/5] v4l-utils: add some scripts from the wiki Antonio Ospite
2012-10-10 13:39 ` [PATCH 1/5] contrib: add some scripts to extract m920x firmwares from USB dumps Antonio Ospite
2012-10-10 13:39 ` [PATCH 2/5] contrib: add a script to convert usbmon captures to usbsnoop Antonio Ospite
2012-10-10 13:39 ` [PATCH 3/5] m920x_parse.pl: use string comparison operators Antonio Ospite
2012-10-10 13:39 ` [PATCH 4/5] m920x_parse.pl: fix strict and warnings checks Antonio Ospite
2012-10-10 13:39 ` [PATCH 5/5] m920x_parse.pl: add support for consuming the output of parse-sniffusb2.pl Antonio Ospite
2012-10-10 14:22 ` [PATCH 0/5] v4l-utils: add some scripts from the wiki Antti Palosaari
2012-10-10 14:53 ` Antonio Ospite
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).