diff options
-rw-r--r-- | bootloader/main-pp.c | 56 | ||||
-rw-r--r-- | rbutil/sansapatcher/sansapatcher.c | 25 |
2 files changed, 32 insertions, 49 deletions
diff --git a/bootloader/main-pp.c b/bootloader/main-pp.c index b0add13fb4..0262384d91 100644 --- a/bootloader/main-pp.c +++ b/bootloader/main-pp.c | |||
@@ -344,32 +344,6 @@ int load_mi4(unsigned char* buf, char* firmware, unsigned int buffer_size) | |||
344 | } | 344 | } |
345 | 345 | ||
346 | #if defined(SANSA_E200) || defined(SANSA_C200) | 346 | #if defined(SANSA_E200) || defined(SANSA_C200) |
347 | #ifdef SANSA_E200 | ||
348 | struct OFDB_info { | ||
349 | char *version; | ||
350 | int version_length; | ||
351 | int sector; | ||
352 | int offset; | ||
353 | } OFDatabaseOffsets[] = { | ||
354 | { "PP5022AF-05.51-S301-01.11-S301.01.11A-D", 39, 0x3c08, 0xe1 }, | ||
355 | { "PP5022AF-05.51-S301-00.12-S301.00.12E-D", 39, 0x3c5c, 0x2 }, | ||
356 | { "PP5022AF-05.51-S301-00.12-S301.00.12A-D", 39, 0x3c08, 0xe1 }, | ||
357 | { "PP5022AF-05.51-S301-02.15-S301.02.15E-D", 39, 0x3c08, 0xe1 }, | ||
358 | { "PP5022AF-05.51-S301-02.18-S301.02.18A-D", 39, 0x3c08, 0xe1 }, | ||
359 | { "PP5022AF-05.51-S301-02.18-S301.02.18E-D", 39, 0x3c08, 0xe1 } | ||
360 | }; | ||
361 | #else /* SANSA_C200 */ | ||
362 | /* TODO: need to determine these for the c200 */ | ||
363 | struct OFDB_info { | ||
364 | char *version; | ||
365 | int version_length; | ||
366 | int sector; | ||
367 | int offset; | ||
368 | } OFDatabaseOffsets[] = { | ||
369 | { "PP5022AF-05.51-S301-01.11-S301.01.11A-D", 39, 0x3c08, 0xe1 }, | ||
370 | }; | ||
371 | #endif | ||
372 | |||
373 | /* Load mi4 firmware from a hidden disk partition */ | 347 | /* Load mi4 firmware from a hidden disk partition */ |
374 | int load_mi4_part(unsigned char* buf, struct partinfo* pinfo, | 348 | int load_mi4_part(unsigned char* buf, struct partinfo* pinfo, |
375 | unsigned int buffer_size, bool disable_rebuild) | 349 | unsigned int buffer_size, bool disable_rebuild) |
@@ -424,31 +398,19 @@ int load_mi4_part(unsigned char* buf, struct partinfo* pinfo, | |||
424 | if(sum != mi4header.crc32) | 398 | if(sum != mi4header.crc32) |
425 | return EBAD_CHKSUM; | 399 | return EBAD_CHKSUM; |
426 | 400 | ||
401 | #ifdef SANSA_E200 | ||
427 | if (disable_rebuild) | 402 | if (disable_rebuild) |
428 | { | 403 | { |
429 | char block[512]; | 404 | char block[512]; |
430 | int sector = 0, offset = 0; | 405 | |
431 | unsigned int i; | 406 | printf("Disabling database rebuild"); |
432 | /* check which known version we have */ | 407 | |
433 | /* These are taken from the PPPS section, 0x00780240 */ | 408 | ata_read_sectors(IF_MV2(0,) pinfo->start + 0x3c08, 1, block); |
434 | ata_read_sectors(IF_MV2(0,) pinfo->start + 0x3C01, 1, block); | 409 | block[0xe1] = 0; |
435 | for (i=0; i<sizeof(OFDatabaseOffsets)/sizeof(*OFDatabaseOffsets); i++) | 410 | ata_write_sectors(IF_MV2(0,) pinfo->start + 0x3c08, 1, block); |
436 | { | ||
437 | if (!memcmp(&block[0x40], OFDatabaseOffsets[i].version, | ||
438 | OFDatabaseOffsets[i].version_length)) | ||
439 | { | ||
440 | sector = pinfo->start + OFDatabaseOffsets[i].sector; | ||
441 | offset = OFDatabaseOffsets[i].offset; | ||
442 | break; | ||
443 | } | ||
444 | } | ||
445 | if (sector && offset) | ||
446 | { | ||
447 | ata_read_sectors(IF_MV2(0,) sector, 1, block); | ||
448 | block[offset] = 0; | ||
449 | ata_write_sectors(IF_MV2(0,) sector, 1, block); | ||
450 | } | ||
451 | } | 411 | } |
412 | #endif | ||
413 | |||
452 | return EOK; | 414 | return EOK; |
453 | } | 415 | } |
454 | #endif | 416 | #endif |
diff --git a/rbutil/sansapatcher/sansapatcher.c b/rbutil/sansapatcher/sansapatcher.c index 2d44e75303..bc03108930 100644 --- a/rbutil/sansapatcher/sansapatcher.c +++ b/rbutil/sansapatcher/sansapatcher.c | |||
@@ -34,7 +34,9 @@ | |||
34 | #include "bootimg_e200.h" | 34 | #include "bootimg_e200.h" |
35 | #endif | 35 | #endif |
36 | /* The offset of the MI4 image header in the firmware partition */ | 36 | /* The offset of the MI4 image header in the firmware partition */ |
37 | #define PPMI_OFFSET 0x80000 | 37 | #define PPMI_OFFSET 0x80000 |
38 | #define NVPARAMS_OFFSET 0x780000 | ||
39 | #define NVPARAMS_SIZE (0x80000-0x200) | ||
38 | 40 | ||
39 | extern int verbose; | 41 | extern int verbose; |
40 | 42 | ||
@@ -882,7 +884,26 @@ int sansa_update_of(struct sansa_t* sansa, char* filename) | |||
882 | fprintf(stderr,"[ERR] Short write in sansa_update_of\n"); | 884 | fprintf(stderr,"[ERR] Short write in sansa_update_of\n"); |
883 | return -1; | 885 | return -1; |
884 | } | 886 | } |
885 | 887 | ||
888 | /* Step 4 - zero out the nvparams section - we have to do this or we end up | ||
889 | with multiple copies of the nvparams data and don't know which one to | ||
890 | work with for the database rebuild disabling trick in our bootloader */ | ||
891 | if (strcmp(sansa->targetname,"e200") == 0) { | ||
892 | printf("[INFO] Resetting Original Firmware settings\n"); | ||
893 | if (sansa_seek(sansa, sansa->start+NVPARAMS_OFFSET+0x200) < 0) { | ||
894 | fprintf(stderr,"[ERR] Seek to 0x%08llx in sansa_update_of failed.\n", | ||
895 | sansa->start+NVPARAMS_OFFSET+0x200); | ||
896 | return -1; | ||
897 | } | ||
898 | |||
899 | memset(sectorbuf,0,NVPARAMS_SIZE); | ||
900 | n=sansa_write(sansa, sectorbuf, NVPARAMS_SIZE); | ||
901 | if (n < NVPARAMS_SIZE) { | ||
902 | fprintf(stderr,"[ERR] Short write in sansa_update_of\n"); | ||
903 | return -1; | ||
904 | } | ||
905 | } | ||
906 | |||
886 | return 0; | 907 | return 0; |
887 | } | 908 | } |
888 | 909 | ||