diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2005-11-16 22:35:13 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2005-11-16 22:35:13 +0000 |
commit | 32877021a5f72984117d059b461a561b3439b47b (patch) | |
tree | 7197c77befad5da0872cec06f174ef5990c6dd9d /tools/mkboot.c | |
parent | c6bf8e62d1b9d7c0e22226bde12e3ce913d58fa1 (diff) | |
download | rockbox-32877021a5f72984117d059b461a561b3439b47b.tar.gz rockbox-32877021a5f72984117d059b461a561b3439b47b.zip |
Can now patch a bootloader image into an H300 firmware
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7914 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/mkboot.c')
-rw-r--r-- | tools/mkboot.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/tools/mkboot.c b/tools/mkboot.c index 420ae248e6..df23687006 100644 --- a/tools/mkboot.c +++ b/tools/mkboot.c | |||
@@ -18,15 +18,16 @@ | |||
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include <stdio.h> | 19 | #include <stdio.h> |
20 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | #include <string.h> | ||
21 | 22 | ||
22 | void usage(void) | 23 | void usage(void) |
23 | { | 24 | { |
24 | printf("usage: mkboot <firmware file> <boot file> <output file>\n"); | 25 | printf("usage: mkboot [-h300] <firmware file> <boot file> <output file>\n"); |
25 | 26 | ||
26 | exit(1); | 27 | exit(1); |
27 | } | 28 | } |
28 | 29 | ||
29 | unsigned char image[0x200000 + 0x220 + 0x200000/0x200]; | 30 | unsigned char image[0x400000 + 0x220 + 0x400000/0x200]; |
30 | 31 | ||
31 | int main(int argc, char *argv[]) | 32 | int main(int argc, char *argv[]) |
32 | { | 33 | { |
@@ -37,14 +38,25 @@ int main(int argc, char *argv[]) | |||
37 | int file_length; | 38 | int file_length; |
38 | int len; | 39 | int len; |
39 | int actual_length, total_length, binary_length, num_chksums; | 40 | int actual_length, total_length, binary_length, num_chksums; |
41 | int origin = 0x1f0000; /* H1x0 bootloader address */ | ||
40 | 42 | ||
41 | if(argc < 3) { | 43 | if(argc < 3) { |
42 | usage(); | 44 | usage(); |
43 | } | 45 | } |
44 | 46 | ||
45 | infile = argv[1]; | 47 | if(!strcmp(argv[1], "-h300")) { |
46 | bootfile = argv[2]; | 48 | infile = argv[2]; |
47 | outfile = argv[3]; | 49 | bootfile = argv[3]; |
50 | outfile = argv[4]; | ||
51 | |||
52 | origin = 0x3f0000; /* H3x0 bootloader address */ | ||
53 | } | ||
54 | else | ||
55 | { | ||
56 | infile = argv[1]; | ||
57 | bootfile = argv[2]; | ||
58 | outfile = argv[3]; | ||
59 | } | ||
48 | 60 | ||
49 | memset(image, 0xff, sizeof(image)); | 61 | memset(image, 0xff, sizeof(image)); |
50 | 62 | ||
@@ -88,7 +100,7 @@ int main(int argc, char *argv[]) | |||
88 | 100 | ||
89 | fseek(f, 0, SEEK_SET); | 101 | fseek(f, 0, SEEK_SET); |
90 | 102 | ||
91 | i = fread(image+0x220 + 0x1f0000, 1, len, f); | 103 | i = fread(image+0x220 + 0x3f0000, 1, len, f); |
92 | if(i < len) { | 104 | if(i < len) { |
93 | perror(bootfile); | 105 | perror(bootfile); |
94 | exit(1); | 106 | exit(1); |
@@ -103,13 +115,13 @@ int main(int argc, char *argv[]) | |||
103 | } | 115 | } |
104 | 116 | ||
105 | /* Patch the reset vector to start the boot loader */ | 117 | /* Patch the reset vector to start the boot loader */ |
106 | image[0x220 + 4] = image[0x1f0000 + 0x220 + 4]; | 118 | image[0x220 + 4] = image[origin + 0x220 + 4]; |
107 | image[0x220 + 5] = image[0x1f0000 + 0x220 + 5]; | 119 | image[0x220 + 5] = image[origin + 0x220 + 5]; |
108 | image[0x220 + 6] = image[0x1f0000 + 0x220 + 6]; | 120 | image[0x220 + 6] = image[origin + 0x220 + 6]; |
109 | image[0x220 + 7] = image[0x1f0000 + 0x220 + 7]; | 121 | image[0x220 + 7] = image[origin + 0x220 + 7]; |
110 | 122 | ||
111 | /* This is the actual length of the binary, excluding all headers */ | 123 | /* This is the actual length of the binary, excluding all headers */ |
112 | actual_length = 0x1f0000 + len; | 124 | actual_length = origin + len; |
113 | 125 | ||
114 | /* Patch the ESTFBINR header */ | 126 | /* Patch the ESTFBINR header */ |
115 | image[0x20c] = (actual_length >> 24) & 0xff; | 127 | image[0x20c] = (actual_length >> 24) & 0xff; |