Merge branch 'master' into sim-target-tree
[kugel-rb.git] / tools / fwpatcher / mksums.pl
blob99786fe16167909cf32cd777539bf21ea3237e55
1 #!/usr/bin/perl
3 # This script creates the h100sums.h and h300sums.h files for fwpatcher.
5 # It expects a file tree with scrambled and descrambled
6 # firmwares like this:
7 # orig-firmware/
8 # h1xx/
9 # 1.66jp/
10 # ihp_100.bin
11 # ihp_100.hex
12 # ihp_120.bin
13 # ihp_120.hex
14 # h3xx/
15 # 1.29jp/
16 # H300.bin
17 # H300.hex
18 # etc.
20 # It also expects the bootloader binaries in the current directory:
21 # bootloader-h100.bin
22 # bootloader-h120.bin
23 # bootloader-h300.bin
25 $orig_path = "~/orig-firmware";
27 mksumfile("100");
28 mksumfile("120");
29 mksumfile("300");
31 sub mksumfile {
32 ($model) = @_;
34 open FILE, ">h${model}sums.h" or die "Can't open h${model}sums.h";
36 print FILE "/* Checksums of firmwares for ihp_$model */\n";
37 print FILE "/* order: unpatched, patched */\n\n";
39 if($model < 300) {
40 foreach("1.63eu","1.63k", "1.63us", "1.65eu","1.65k", "1.65us",
41 "1.66eu", "1.66k", "1.66us", "1.66jp") {
42 `../mkboot $orig_path/h1xx/$_/ihp_$model.bin bootloader-h$model.bin ihp_$model.bin`;
43 `../scramble -iriver ihp_$model.bin ihp_$model.hex`;
44 $origsum = `md5sum $orig_path/h1xx/$_/ihp_$model.hex`;
45 chomp $origsum;
46 ($os, $or) = split / /, $origsum;
47 $sum = `md5sum ihp_$model.hex`;
48 chomp $sum;
49 ($s, $r) = split / /, $sum;
50 print FILE "/* $_ */\n";
51 print FILE "{\"$os\", \"$s\"},\n";
53 } else {
54 foreach("1.28eu", "1.28k", "1.28jp", "1.29eu", "1.29k", "1.29jp",
55 "1.30eu") {
56 `../mkboot -h300 $orig_path/h3xx/$_/H$model.bin bootloader-h$model.bin H$model.bin`;
57 `../scramble -iriver H$model.bin H$model.hex`;
58 $origsum = `md5sum $orig_path/h3xx/$_/H$model.hex`;
59 chomp $origsum;
60 ($os, $or) = split / /, $origsum;
61 $sum = `md5sum H$model.hex`;
62 chomp $sum;
63 ($s, $r) = split / /, $sum;
64 print FILE "/* $_ */\n";
65 print FILE "{\"$os\", \"$s\"},\n";
68 close FILE;