summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2004-12-23 20:15:13 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2004-12-23 20:15:13 +0000
commit431be7f5977eba0521d44a8767230f6a55ec0c35 (patch)
treea55292c781ed2c2bb4878ce32029edcb96041040
parente432b4d2c36016a4b502d35ba6032e46e0fa135b (diff)
downloadrockbox-431be7f5977eba0521d44a8767230f6a55ec0c35.tar.gz
rockbox-431be7f5977eba0521d44a8767230f6a55ec0c35.zip
now can compose images with ROMbox, too
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5509 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--flash/make_firmware/make_firmware.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/flash/make_firmware/make_firmware.c b/flash/make_firmware/make_firmware.c
index 220db4e5f1..ffc366fe5e 100644
--- a/flash/make_firmware/make_firmware.c
+++ b/flash/make_firmware/make_firmware.c
@@ -37,6 +37,7 @@
37#define SECTORSIZE 4096 37#define SECTORSIZE 4096
38 38
39#define BOOTLOAD_DEST 0x0FFFF500 // for the "normal" one 39#define BOOTLOAD_DEST 0x0FFFF500 // for the "normal" one
40#define FLASH_START 0x02000000
40#define BOOTLOAD_SCR 0x02000100 41#define BOOTLOAD_SCR 0x02000100
41#define ROCKBOX_DEST 0x09000000 42#define ROCKBOX_DEST 0x09000000
42#define ROCKBOX_EXEC 0x09000200 43#define ROCKBOX_EXEC 0x09000200
@@ -130,6 +131,7 @@ UINT32 PlaceImage(char* filename, UINT32 pos, UINT8* pFirmware, UINT32 limit)
130 FILE* pFile; 131 FILE* pFile;
131 UINT32 align; 132 UINT32 align;
132 UINT32 flags; 133 UINT32 flags;
134 UINT32 load_addr = ROCKBOX_DEST, exec_addr = ROCKBOX_EXEC; // defaults
133 135
134 // magic file header for compressed files 136 // magic file header for compressed files
135 static const UINT8 magic[8] = { 0x00,0xe9,0x55,0x43,0x4c,0xff,0x01,0x1a }; 137 static const UINT8 magic[8] = { 0x00,0xe9,0x55,0x43,0x4c,0xff,0x01,0x1a };
@@ -151,7 +153,8 @@ UINT32 PlaceImage(char* filename, UINT32 pos, UINT8* pFirmware, UINT32 limit)
151 fread(ucl_header, 1, sizeof(ucl_header), pFile); 153 fread(ucl_header, 1, sizeof(ucl_header), pFile);
152 if (memcmp(magic, ucl_header, sizeof(magic)) == 0) 154 if (memcmp(magic, ucl_header, sizeof(magic)) == 0)
153 { 155 {
154 if (ucl_header[12] != 0x2E) // check algorithm 156 if (ucl_header[12] != 0x2E // check algorithm
157 && ucl_header[12] != 0x2B) // or uncompressed
155 { 158 {
156 printf("UCL compressed files must use algorithm 2e, not %d\n", ucl_header[12]); 159 printf("UCL compressed files must use algorithm 2e, not %d\n", ucl_header[12]);
157 printf("Generate with: uclpack --best --2e rockbox.bin %s\n", filename); 160 printf("Generate with: uclpack --best --2e rockbox.bin %s\n", filename);
@@ -163,6 +166,15 @@ UINT32 PlaceImage(char* filename, UINT32 pos, UINT8* pFirmware, UINT32 limit)
163 { // normal case 166 { // normal case
164 flags = 0x00000001; // flags for UCL compressed 167 flags = 0x00000001; // flags for UCL compressed
165 } 168 }
169
170 if (ucl_header[12] == 0x2B) // uncompressed means "ROMbox", for direct flash execution
171 {
172 UINT8 reset_vec[4];
173 fread(reset_vec, 1, sizeof(reset_vec), pFile); // read the reset vector from image
174 fseek(pFile, 0-sizeof(reset_vec), SEEK_CUR); // wind back
175 load_addr = FLASH_START + pos + 16; // behind 16 byte header
176 exec_addr = Read32(reset_vec);
177 }
166 } 178 }
167 else 179 else
168 { 180 {
@@ -177,9 +189,9 @@ UINT32 PlaceImage(char* filename, UINT32 pos, UINT8* pFirmware, UINT32 limit)
177 189
178 // write header 190 // write header
179 align = (pos + 16 + size + SECTORSIZE-1) & ~(SECTORSIZE-1); // round up to next flash sector 191 align = (pos + 16 + size + SECTORSIZE-1) & ~(SECTORSIZE-1); // round up to next flash sector
180 Write32(pFirmware + pos, ROCKBOX_DEST); // load address 192 Write32(pFirmware + pos, load_addr); // load address
181 Write32(pFirmware + pos + 4, align - (pos + 16)); // image size 193 Write32(pFirmware + pos + 4, align - (pos + 16)); // image size
182 Write32(pFirmware + pos + 8, ROCKBOX_EXEC); // execution address 194 Write32(pFirmware + pos + 8, exec_addr); // execution address
183 Write32(pFirmware + pos + 12, flags); // compressed or not 195 Write32(pFirmware + pos + 12, flags); // compressed or not
184 pos += 16; 196 pos += 16;
185 197