summaryrefslogtreecommitdiffstats
path: root/tools/fwpatcher
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2005-11-18 20:01:51 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2005-11-18 20:01:51 +0000
commit88a2a8a53a875f6af90fa2b479dc281e752881d2 (patch)
tree2de233d8ccfab4ea2add7606e3ab8ebd5b9de7c8 /tools/fwpatcher
parentd2779e5f3a00f0ff94ff2e62ae034baca3d8f7b3 (diff)
downloadrockbox-88a2a8a53a875f6af90fa2b479dc281e752881d2.tar.gz
rockbox-88a2a8a53a875f6af90fa2b479dc281e752881d2.tar.bz2
rockbox-88a2a8a53a875f6af90fa2b479dc281e752881d2.zip
Added H300 to the fwpatcher utility
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7969 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/fwpatcher')
-rw-r--r--tools/fwpatcher/Makefile2
-rw-r--r--tools/fwpatcher/h300sums.h5
-rw-r--r--tools/fwpatcher/main.c42
-rw-r--r--tools/fwpatcher/resource.h1
-rw-r--r--tools/fwpatcher/resource.rc1
5 files changed, 40 insertions, 11 deletions
diff --git a/tools/fwpatcher/Makefile b/tools/fwpatcher/Makefile
index 922e2faf65..a209be183e 100644
--- a/tools/fwpatcher/Makefile
+++ b/tools/fwpatcher/Makefile
@@ -44,7 +44,7 @@ $(TARGET): $(OBJS)
$(TARGETU): $(OBJSU)
$(CC) $(LDFLAGS) $(OBJSU) -o $@
-resource.o: resource.rc bootloader-h100.bin bootloader-h120.bin rockbox.ico
+resource.o: resource.rc bootloader-h100.bin bootloader-h120.bin bootloader-h300.bin rockbox.ico
$(WINDRES) -v $< $@
iriveru.o: iriver.c iriver.h
diff --git a/tools/fwpatcher/h300sums.h b/tools/fwpatcher/h300sums.h
new file mode 100644
index 0000000000..ea7ae72817
--- /dev/null
+++ b/tools/fwpatcher/h300sums.h
@@ -0,0 +1,5 @@
+/* Checksums of firmwares for ihp_300 */
+/* order: unpatched, patched */
+
+/* 1.28eu */
+{"0b2083d37f24899b82d21a14d2b38060", "937c0a745227281da62e41da78efcfe8"},
diff --git a/tools/fwpatcher/main.c b/tools/fwpatcher/main.c
index 1ec67678df..3015c8fc61 100644
--- a/tools/fwpatcher/main.c
+++ b/tools/fwpatcher/main.c
@@ -56,15 +56,21 @@ static struct sumpairs h120pairs[] = {
#include "h120sums.h"
};
+/* precalculated checksums for H320/H340 */
+static struct sumpairs h300pairs[] = {
+#include "h300sums.h"
+};
+
HICON rbicon;
HFONT deffont;
HWND controls[CTL_NUM];
/* begin mkboot.c excerpt */
-unsigned char image[0x200000 + 0x220 + 0x200000/0x200];
+unsigned char image[0x400000 + 0x220 + 0x400000/0x200];
-int mkboot(TCHAR *infile, TCHAR *outfile, unsigned char *bldata, int bllen)
+int mkboot(TCHAR *infile, TCHAR *outfile, unsigned char *bldata, int bllen,
+ int origin)
{
FILE *f;
int i;
@@ -101,7 +107,7 @@ int mkboot(TCHAR *infile, TCHAR *outfile, unsigned char *bldata, int bllen)
fclose(f);
- memcpy(image + 0x220 + 0x1f0000, bldata, bllen);
+ memcpy(image + 0x220 + origin, bldata, bllen);
f = _tfopen(outfile, TEXT("wb"));
if(!f) {
@@ -110,13 +116,13 @@ int mkboot(TCHAR *infile, TCHAR *outfile, unsigned char *bldata, int bllen)
}
/* Patch the reset vector to start the boot loader */
- image[0x220 + 4] = image[0x1f0000 + 0x220 + 4];
- image[0x220 + 5] = image[0x1f0000 + 0x220 + 5];
- image[0x220 + 6] = image[0x1f0000 + 0x220 + 6];
- image[0x220 + 7] = image[0x1f0000 + 0x220 + 7];
+ image[0x220 + 4] = image[origin + 0x220 + 4];
+ image[0x220 + 5] = image[origin + 0x220 + 5];
+ image[0x220 + 6] = image[origin + 0x220 + 6];
+ image[0x220 + 7] = image[origin + 0x220 + 7];
/* This is the actual length of the binary, excluding all headers */
- actual_length = 0x1f0000 + bllen;
+ actual_length = origin + bllen;
/* Patch the ESTFBINR header */
image[0x20c] = (actual_length >> 24) & 0xff;
@@ -216,16 +222,24 @@ int PatchFirmware(int series, int table_entry)
DWORD blsize;
int i;
struct sumpairs *sums;
+ int origin;
/* get pointer to the correct bootloader.bin */
switch(series) {
case 100:
res = FindResource(NULL, MAKEINTRESOURCE(IDI_BOOTLOADERH100), TEXT("BIN"));
sums = &h100pairs[0];
+ origin = 0x1f0000;
break;
case 120:
res = FindResource(NULL, MAKEINTRESOURCE(IDI_BOOTLOADERH120), TEXT("BIN"));
sums = &h120pairs[0];
+ origin = 0x1f0000;
+ break;
+ case 300:
+ res = FindResource(NULL, MAKEINTRESOURCE(IDI_BOOTLOADERH300), TEXT("BIN"));
+ sums = &h300pairs[0];
+ origin = 0x3f0000;
break;
}
resload = LoadResource(NULL, res);
@@ -246,7 +260,7 @@ int PatchFirmware(int series, int table_entry)
TEXT("Error"), MB_ICONERROR);
goto error;
}
- if (!mkboot(name1, name2, bootloader, blsize)) {
+ if (!mkboot(name1, name2, bootloader, blsize, origin)) {
MessageBox(NULL, TEXT("Error in patching"),
TEXT("Error"), MB_ICONERROR);
goto error;
@@ -380,8 +394,16 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
else {
table_entry = intable(md5sum_str, &h100pairs[0],
sizeof(h100pairs)/sizeof(struct sumpairs));
- if (table_entry >= 0)
+ if (table_entry >= 0) {
series = 100;
+ }
+ else {
+ table_entry =
+ intable(md5sum_str, &h300pairs[0],
+ sizeof(h300pairs)/sizeof(struct sumpairs));
+ if (table_entry >= 0)
+ series = 300;
+ }
}
if (series == 0) {
MessageBox(NULL, TEXT("Unrecognised firmware"), TEXT("Fail"), MB_OK);
diff --git a/tools/fwpatcher/resource.h b/tools/fwpatcher/resource.h
index c255bff0b4..c1287e46ee 100644
--- a/tools/fwpatcher/resource.h
+++ b/tools/fwpatcher/resource.h
@@ -1,4 +1,5 @@
#define IDI_RBICON 101
#define IDI_BOOTLOADERH100 102
#define IDI_BOOTLOADERH120 103
+#define IDI_BOOTLOADERH300 104
diff --git a/tools/fwpatcher/resource.rc b/tools/fwpatcher/resource.rc
index a1dcb4835f..b30646316d 100644
--- a/tools/fwpatcher/resource.rc
+++ b/tools/fwpatcher/resource.rc
@@ -3,3 +3,4 @@
IDI_RBICON ICON "rockbox.ico"
IDI_BOOTLOADERH100 BIN "bootloader-h100.bin"
IDI_BOOTLOADERH120 BIN "bootloader-h120.bin"
+IDI_BOOTLOADERH300 BIN "bootloader-h300.bin"