summaryrefslogtreecommitdiff
path: root/utils/rbutilqt/irivertools/mksums.pl
diff options
context:
space:
mode:
Diffstat (limited to 'utils/rbutilqt/irivertools/mksums.pl')
-rwxr-xr-xutils/rbutilqt/irivertools/mksums.pl69
1 files changed, 69 insertions, 0 deletions
diff --git a/utils/rbutilqt/irivertools/mksums.pl b/utils/rbutilqt/irivertools/mksums.pl
new file mode 100755
index 0000000000..99786fe161
--- /dev/null
+++ b/utils/rbutilqt/irivertools/mksums.pl
@@ -0,0 +1,69 @@
1#!/usr/bin/perl
2
3# This script creates the h100sums.h and h300sums.h files for fwpatcher.
4#
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.
19#
20# It also expects the bootloader binaries in the current directory:
21# bootloader-h100.bin
22# bootloader-h120.bin
23# bootloader-h300.bin
24
25$orig_path = "~/orig-firmware";
26
27mksumfile("100");
28mksumfile("120");
29mksumfile("300");
30
31sub mksumfile {
32 ($model) = @_;
33
34 open FILE, ">h${model}sums.h" or die "Can't open h${model}sums.h";
35
36 print FILE "/* Checksums of firmwares for ihp_$model */\n";
37 print FILE "/* order: unpatched, patched */\n\n";
38
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";
52 }
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";
66 }
67 }
68 close FILE;
69}