diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/iriver_flash.c | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/apps/plugins/iriver_flash.c b/apps/plugins/iriver_flash.c index 449bf349a8..a9cf62d3c4 100644 --- a/apps/plugins/iriver_flash.c +++ b/apps/plugins/iriver_flash.c | |||
@@ -66,11 +66,11 @@ enum sections { | |||
66 | static volatile uint16_t* FB = (uint16_t*)0x00000000; /* Flash base address */ | 66 | static volatile uint16_t* FB = (uint16_t*)0x00000000; /* Flash base address */ |
67 | #endif | 67 | #endif |
68 | 68 | ||
69 | #ifdef IRIVER_H100 | 69 | #ifdef IRIVER_H100 /* iRiver H110/H115 */ |
70 | #define MODEL "h100" | 70 | #define MODEL "h100" |
71 | #elif defined(IRIVER_H120) | 71 | #elif defined(IRIVER_H120) /* iRiver H120/H140 */ |
72 | #define MODEL "h120" | 72 | #define MODEL "h120" |
73 | #elif defined(IRIVER_H300) | 73 | #elif defined(IRIVER_H300) /* iRiver H320/H340 */ |
74 | #define MODEL "h300" | 74 | #define MODEL "h300" |
75 | #endif | 75 | #endif |
76 | 76 | ||
@@ -307,33 +307,29 @@ static off_t load_firmware_file(const char* filename, uint32_t* out_checksum) | |||
307 | return len; | 307 | return len; |
308 | } | 308 | } |
309 | 309 | ||
310 | unsigned long valid_bootloaders[][2] = { | 310 | static const uint32_t valid_bootloaders[][2] = { |
311 | /* Size-8 CRC32 */ | 311 | /* Size-8, CRC32 */ |
312 | #ifdef IRIVER_H120 /* Iriver H120/H140 checksums */ | 312 | #ifdef IRIVER_H100 /* iRiver H110/H115 */ |
313 | { 48760, 0x2efc3323 }, /* 7-pre4 */ | ||
314 | { 56896, 0x0cd8dad4 }, /* 7-pre5 */ | ||
315 | #elif defined(IRIVER_H120) /* iRiver H120/H140 */ | ||
313 | { 63788, 0x08ff01a9 }, /* 7-pre3, improved failsafe functions */ | 316 | { 63788, 0x08ff01a9 }, /* 7-pre3, improved failsafe functions */ |
314 | { 48764, 0xc674323e }, /* 7-pre4. Fixed audio thump & remote bootup */ | 317 | { 48764, 0xc674323e }, /* 7-pre4. Fixed audio thump & remote bootup */ |
315 | { 56896, 0x167f5d25 }, /* 7-pre5, various ATA fixes */ | 318 | { 56896, 0x167f5d25 }, /* 7-pre5, various ATA fixes */ |
319 | #elif defined(IRIVER_H300) /* iRiver H320/H340 */ | ||
316 | #endif | 320 | #endif |
317 | #ifdef IRIVER_H100 | 321 | {} |
318 | { 48760, 0x2efc3323 }, /* 7-pre4 */ | ||
319 | { 56896, 0x0cd8dad4 }, /* 7-pre5 */ | ||
320 | #endif | ||
321 | { 0, 0 } | ||
322 | }; | 322 | }; |
323 | 323 | ||
324 | 324 | /* check if the bootloader is a known good one */ | |
325 | bool detect_valid_bootloader(const unsigned char *addr, int len) | 325 | static bool detect_valid_bootloader(const uint8_t* pAddr, uint32_t len) |
326 | { | 326 | { |
327 | int i; | 327 | for (size_t i = 0; valid_bootloaders[i][0]; i++) |
328 | unsigned long crc32; | ||
329 | |||
330 | /* Try to scan through all valid bootloaders. */ | ||
331 | for (i = 0; valid_bootloaders[i][0]; i++) | ||
332 | { | 328 | { |
333 | if (len > 0 && len != (long)valid_bootloaders[i][0]) | 329 | if (len != valid_bootloaders[i][0]) |
334 | continue; | 330 | continue; |
335 | 331 | ||
336 | crc32 = rb->crc_32(addr, valid_bootloaders[i][0], 0xffffffff); | 332 | uint32_t crc32 = rb->crc_32(pAddr, valid_bootloaders[i][0], 0xffffffff); |
337 | if (crc32 == valid_bootloaders[i][1]) | 333 | if (crc32 == valid_bootloaders[i][1]) |
338 | return true; | 334 | return true; |
339 | } | 335 | } |