summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Wardell <rockbox@barrywardell.net>2007-03-17 19:07:20 +0000
committerBarry Wardell <rockbox@barrywardell.net>2007-03-17 19:07:20 +0000
commite293bbb4514ce877a3d449ecbc7a216a790f627a (patch)
tree6e9cceda48038e13ac517d534225bbeaeb46cdca
parent3d39c4de289ba8f2d84fd38026273f9c4fa9a36a (diff)
downloadrockbox-e293bbb4514ce877a3d449ecbc7a216a790f627a.tar.gz
rockbox-e293bbb4514ce877a3d449ecbc7a216a790f627a.zip
If loading rockbox.mi4 fails, then drop back to trying rockbox.h10/rockbox.e200 instead. This will allow the new bootloader to be used with older rockbox builds.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12824 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--bootloader/main-pp.c45
-rw-r--r--firmware/export/config-e200.h23
-rw-r--r--firmware/export/config-h10.h23
-rw-r--r--firmware/export/config-h10_5gb.h20
4 files changed, 48 insertions, 63 deletions
diff --git a/bootloader/main-pp.c b/bootloader/main-pp.c
index 1ab6ebdd6f..e598a29fa0 100644
--- a/bootloader/main-pp.c
+++ b/bootloader/main-pp.c
@@ -125,9 +125,10 @@ unsigned char *loadbuffer = (unsigned char *)DRAM_START;
125char version[] = APPSVERSION; 125char version[] = APPSVERSION;
126 126
127/* Locations and sizes in hidden partition on Sansa */ 127/* Locations and sizes in hidden partition on Sansa */
128#define PPMI_OFFSET 1024 128#define PPMI_SECTOR_OFFSET 1024
129#define PPMI_SIZE 1 129#define PPMI_SECTORS 1
130#define MI4_HEADER_SIZE 1 130#define MI4_HEADER_SECTORS 1
131#define MI4_HEADER_SIZE 0x200
131 132
132/* mi4 header structure */ 133/* mi4 header structure */
133struct mi4header_t { 134struct mi4header_t {
@@ -170,10 +171,10 @@ int load_mi4(unsigned char* buf, char* firmware, unsigned int buffer_size)
170 return EFILE_NOT_FOUND; 171 return EFILE_NOT_FOUND;
171 } 172 }
172 173
173 read(fd, &mi4header, 0x200); 174 read(fd, &mi4header, MI4_HEADER_SIZE);
174 175
175 /* We don't support encrypted mi4 files yet */ 176 /* We don't support encrypted mi4 files yet */
176 if( (mi4header.plaintext + 0x200) != mi4header.mi4size) 177 if( (mi4header.plaintext + MI4_HEADER_SIZE) != mi4header.mi4size)
177 return EINVALID_FORMAT; 178 return EINVALID_FORMAT;
178 179
179 /* MI4 file size */ 180 /* MI4 file size */
@@ -192,13 +193,13 @@ int load_mi4(unsigned char* buf, char* firmware, unsigned int buffer_size)
192 printf("Binary type: %4s", mi4header.type); 193 printf("Binary type: %4s", mi4header.type);
193 194
194 /* Load firmware */ 195 /* Load firmware */
195 lseek(fd, FIRMWARE_OFFSET_FILE_DATA, SEEK_SET); 196 lseek(fd, MI4_HEADER_SIZE, SEEK_SET);
196 rc = read(fd, buf, mi4header.mi4size-0x200); 197 rc = read(fd, buf, mi4header.mi4size-MI4_HEADER_SIZE);
197 if(rc < (int)mi4header.mi4size-0x200) 198 if(rc < (int)mi4header.mi4size-MI4_HEADER_SIZE)
198 return EREAD_IMAGE_FAILED; 199 return EREAD_IMAGE_FAILED;
199 200
200 /* Check CRC32 to see if we have a valid file */ 201 /* Check CRC32 to see if we have a valid file */
201 sum = chksum_crc32 (buf,mi4header.mi4size-0x200); 202 sum = chksum_crc32 (buf,mi4header.mi4size-MI4_HEADER_SIZE);
202 203
203 printf("Calculated CRC32: %x", sum); 204 printf("Calculated CRC32: %x", sum);
204 205
@@ -217,7 +218,8 @@ int load_mi4_part(unsigned char* buf, struct partinfo* pinfo, unsigned int buffe
217 unsigned long sum; 218 unsigned long sum;
218 219
219 /* Read header to find out how long the mi4 file is. */ 220 /* Read header to find out how long the mi4 file is. */
220 ata_read_sectors(pinfo->start + PPMI_OFFSET, PPMI_SIZE, &ppmi_header); 221 ata_read_sectors(pinfo->start + PPMI_SECTOR_OFFSET,
222 PPMI_SECTORS, &ppmi_header);
221 223
222 /* The first four characters at 0x80000 (sector 1024) should be PPMI*/ 224 /* The first four characters at 0x80000 (sector 1024) should be PPMI*/
223 if( memcmp(ppmi_header.magic, "PPMI", 4) ) 225 if( memcmp(ppmi_header.magic, "PPMI", 4) )
@@ -226,11 +228,11 @@ int load_mi4_part(unsigned char* buf, struct partinfo* pinfo, unsigned int buffe
226 printf("BL mi4 size: %x", ppmi_header.length); 228 printf("BL mi4 size: %x", ppmi_header.length);
227 229
228 /* Read mi4 header of the OF */ 230 /* Read mi4 header of the OF */
229 ata_read_sectors(pinfo->start + PPMI_OFFSET + PPMI_SIZE 231 ata_read_sectors(pinfo->start + PPMI_SECTOR_OFFSET + PPMI_SECTORS
230 + (ppmi_header.length/512), MI4_HEADER_SIZE, &mi4header); 232 + (ppmi_header.length/512), MI4_HEADER_SECTORS, &mi4header);
231 233
232 /* We don't support encrypted mi4 files yet */ 234 /* We don't support encrypted mi4 files yet */
233 if( (mi4header.plaintext + 0x200) != mi4header.mi4size) 235 if( (mi4header.plaintext + MI4_HEADER_SIZE) != mi4header.mi4size)
234 return EINVALID_FORMAT; 236 return EINVALID_FORMAT;
235 237
236 /* MI4 file size */ 238 /* MI4 file size */
@@ -249,12 +251,12 @@ int load_mi4_part(unsigned char* buf, struct partinfo* pinfo, unsigned int buffe
249 printf("Binary type: %4s", mi4header.type); 251 printf("Binary type: %4s", mi4header.type);
250 252
251 /* Load firmware */ 253 /* Load firmware */
252 ata_read_sectors(pinfo->start + PPMI_OFFSET + PPMI_SIZE 254 ata_read_sectors(pinfo->start + PPMI_SECTOR_OFFSET + PPMI_SECTORS
253 + (ppmi_header.length/512) + MI4_HEADER_SIZE, 255 + (ppmi_header.length/512) + MI4_HEADER_SECTORS,
254 (mi4header.length-0x200)/512, buf); 256 (mi4header.length-MI4_HEADER_SIZE)/512, buf);
255 257
256 /* Check CRC32 to see if we have a valid file */ 258 /* Check CRC32 to see if we have a valid file */
257 sum = chksum_crc32 (buf,mi4header.mi4size-0x200); 259 sum = chksum_crc32 (buf,mi4header.mi4size-MI4_HEADER_SIZE);
258 260
259 printf("Calculated CRC32: %x", sum); 261 printf("Calculated CRC32: %x", sum);
260 262
@@ -383,7 +385,14 @@ void* main(void)
383 rc=load_mi4(loadbuffer, BOOTFILE, MAX_LOADSIZE); 385 rc=load_mi4(loadbuffer, BOOTFILE, MAX_LOADSIZE);
384 if (rc < EOK) { 386 if (rc < EOK) {
385 printf("Can't load %s:", BOOTFILE); 387 printf("Can't load %s:", BOOTFILE);
386 error(EBOOTFILE, rc); 388 printf(strerror(rc));
389
390 /* Try loading rockbox from old rockbox.e200/rockbox.h10 format */
391 rc=load_firmware(loadbuffer, OLD_BOOTFILE, MAX_LOADSIZE);
392 if (rc < EOK) {
393 printf("Can't load %s:", OLD_BOOTFILE);
394 printf(strerror(rc));
395 }
387 } 396 }
388 } 397 }
389 398
diff --git a/firmware/export/config-e200.h b/firmware/export/config-e200.h
index 0126cdf739..094bd7f7b0 100644
--- a/firmware/export/config-e200.h
+++ b/firmware/export/config-e200.h
@@ -107,20 +107,10 @@
107/* Type of LCD TODO: hopefully the same as the x5 but check this*/ 107/* Type of LCD TODO: hopefully the same as the x5 but check this*/
108#define CONFIG_LCD LCD_X5 108#define CONFIG_LCD LCD_X5
109 109
110/* Offset ( in the firmware file's header ) to the file length */ 110/* Offset ( in the firmware file's header ) to the file CRC and data. These are
111#define FIRMWARE_OFFSET_FILE_LENGTH 0x8 111 only used when loading the old format rockbox.e200 file */
112 112#define FIRMWARE_OFFSET_FILE_CRC 0x0
113/* Offset ( in the firmware file's header ) to the file CRC */ 113#define FIRMWARE_OFFSET_FILE_DATA 0x8
114#define FIRMWARE_OFFSET_FILE_CRC 0x0c
115
116/* Offset ( in the firmware file's header ) to the file type */
117#define FIRMWARE_OFFSET_FILE_TYPE 0x1f8
118
119/* Offset ( in the firmware file's header ) to the file model id */
120#define FIRMWARE_OFFSET_FILE_MODEL 0x1fc
121
122/* Offset ( in the firmware file's header ) to the real data */
123#define FIRMWARE_OFFSET_FILE_DATA 0x200
124 114
125/* #define USB_IPODSTYLE */ 115/* #define USB_IPODSTYLE */
126 116
@@ -136,8 +126,9 @@
136/* Define this if you have adjustable CPU frequency */ 126/* Define this if you have adjustable CPU frequency */
137/*#define HAVE_ADJUSTABLE_CPU_FREQ Let's say we don't for now*/ 127/*#define HAVE_ADJUSTABLE_CPU_FREQ Let's say we don't for now*/
138 128
139#define BOOTFILE_EXT "e200" 129#define BOOTFILE_EXT "mi4"
140#define BOOTFILE "rockbox." BOOTFILE_EXT 130#define BOOTFILE "rockbox." BOOTFILE_EXT
131#define OLD_BOOTFILE "rockbox.e200"
141 132
142#define ICODE_ATTR_TREMOR_NOT_MDCT 133#define ICODE_ATTR_TREMOR_NOT_MDCT
143 134
diff --git a/firmware/export/config-h10.h b/firmware/export/config-h10.h
index ec6f83fecb..18f78efb91 100644
--- a/firmware/export/config-h10.h
+++ b/firmware/export/config-h10.h
@@ -137,20 +137,10 @@
137/* We're able to shut off power to the HDD */ 137/* We're able to shut off power to the HDD */
138#define HAVE_ATA_POWER_OFF 138#define HAVE_ATA_POWER_OFF
139 139
140/* Offset ( in the firmware file's header ) to the file length */ 140/* Offset ( in the firmware file's header ) to the file CRC and data. These are
141#define FIRMWARE_OFFSET_FILE_LENGTH 0x8 141 only used when loading the old format rockbox.h10 file */
142 142#define FIRMWARE_OFFSET_FILE_CRC 0x0
143/* Offset ( in the firmware file's header ) to the file CRC */ 143#define FIRMWARE_OFFSET_FILE_DATA 0x8
144#define FIRMWARE_OFFSET_FILE_CRC 0x0c
145
146/* Offset ( in the firmware file's header ) to the file type */
147#define FIRMWARE_OFFSET_FILE_TYPE 0x1f8
148
149/* Offset ( in the firmware file's header ) to the file model id */
150#define FIRMWARE_OFFSET_FILE_MODEL 0x1fc
151
152/* Offset ( in the firmware file's header ) to the real data */
153#define FIRMWARE_OFFSET_FILE_DATA 0x200
154 144
155/* #define USB_IPODSTYLE */ 145/* #define USB_IPODSTYLE */
156 146
@@ -166,8 +156,9 @@
166/* Define this if you have adjustable CPU frequency */ 156/* Define this if you have adjustable CPU frequency */
167/*#define HAVE_ADJUSTABLE_CPU_FREQ*/ 157/*#define HAVE_ADJUSTABLE_CPU_FREQ*/
168 158
169#define BOOTFILE_EXT "h10" 159#define BOOTFILE_EXT "mi4"
170#define BOOTFILE "rockbox." BOOTFILE_EXT 160#define BOOTFILE "rockbox." BOOTFILE_EXT
161#define OLD_BOOTFILE "rockbox.h10"
171 162
172#define ICODE_ATTR_TREMOR_NOT_MDCT 163#define ICODE_ATTR_TREMOR_NOT_MDCT
173 164
diff --git a/firmware/export/config-h10_5gb.h b/firmware/export/config-h10_5gb.h
index b809f3471c..1df9462ee6 100644
--- a/firmware/export/config-h10_5gb.h
+++ b/firmware/export/config-h10_5gb.h
@@ -120,17 +120,10 @@
120/* Offset ( in the firmware file's header ) to the file length */ 120/* Offset ( in the firmware file's header ) to the file length */
121#define FIRMWARE_OFFSET_FILE_LENGTH 0x8 121#define FIRMWARE_OFFSET_FILE_LENGTH 0x8
122 122
123/* Offset ( in the firmware file's header ) to the file CRC */ 123/* Offset ( in the firmware file's header ) to the file CRC and data. These are
124#define FIRMWARE_OFFSET_FILE_CRC 0x0c 124 only used when loading the old format rockbox.h10 file */
125 125#define FIRMWARE_OFFSET_FILE_CRC 0x0
126/* Offset ( in the firmware file's header ) to the file type */ 126#define FIRMWARE_OFFSET_FILE_DATA 0x8
127#define FIRMWARE_OFFSET_FILE_TYPE 0x1f8
128
129/* Offset ( in the firmware file's header ) to the file model id */
130#define FIRMWARE_OFFSET_FILE_MODEL 0x1fc
131
132/* Offset ( in the firmware file's header ) to the real data */
133#define FIRMWARE_OFFSET_FILE_DATA 0x200
134 127
135/* #define USB_IPODSTYLE */ 128/* #define USB_IPODSTYLE */
136 129
@@ -146,8 +139,9 @@
146/* Define this if you have adjustable CPU frequency */ 139/* Define this if you have adjustable CPU frequency */
147/*#define HAVE_ADJUSTABLE_CPU_FREQ*/ 140/*#define HAVE_ADJUSTABLE_CPU_FREQ*/
148 141
149#define BOOTFILE_EXT "h10" 142#define BOOTFILE_EXT "mi4"
150#define BOOTFILE "rockbox." BOOTFILE_EXT 143#define BOOTFILE "rockbox." BOOTFILE_EXT
144#define OLD_BOOTFILE "rockbox.h10"
151 145
152#define ICODE_ATTR_TREMOR_NOT_MDCT 146#define ICODE_ATTR_TREMOR_NOT_MDCT
153 147