summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bootloader/main-pp.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/bootloader/main-pp.c b/bootloader/main-pp.c
index 86e9868554..b95b7a10f4 100644
--- a/bootloader/main-pp.c
+++ b/bootloader/main-pp.c
@@ -406,6 +406,17 @@ int load_mi4(unsigned char* buf, char* firmware, unsigned int buffer_size)
406} 406}
407 407
408#ifdef SANSA_E200 408#ifdef SANSA_E200
409struct OFDB_info {
410 char *version;
411 int version_length;
412 int sector;
413 int offset;
414} OFDatabaseOffsets[] = {
415 { "PP5022AF-05.51-S301-01.11-S301.01.11A-D", 39, 0x3c08, 0xe1 },
416 { "PP5022AF-05.51-S301-00.12-S301.00.12E-D", 39, 0x3c5c, 0x2 },
417 { "PP5022AF-05.51-S301-00.12-S301.00.12A-D", 39, 0x3c08, 0xe1 },
418};
419
409/* Load mi4 firmware from a hidden disk partition */ 420/* Load mi4 firmware from a hidden disk partition */
410int load_mi4_part(unsigned char* buf, struct partinfo* pinfo, 421int load_mi4_part(unsigned char* buf, struct partinfo* pinfo,
411 unsigned int buffer_size, bool disable_rebuild) 422 unsigned int buffer_size, bool disable_rebuild)
@@ -464,27 +475,26 @@ int load_mi4_part(unsigned char* buf, struct partinfo* pinfo,
464 { 475 {
465 char block[512]; 476 char block[512];
466 int sector = 0, offset = 0; 477 int sector = 0, offset = 0;
467 478 unsigned int i;
468 /* check which known version we have */ 479 /* check which known version we have */
469 /* These are taken from the PPPS section, 0x00780240 */ 480 /* These are taken from the PPPS section, 0x00780240 */
470 ata_read_sectors(pinfo->start + 0x3C01, 1, block); 481 ata_read_sectors(pinfo->start + 0x3C01, 1, block);
471 if (!memcmp(&block[0x40], 482 for (i=0; i<sizeof(OFDatabaseOffsets)/sizeof(*OFDatabaseOffsets); i++)
472 "PP5022AF-05.51-S301-01.11-S301.01.11A-D", 39)) 483 {
473 { /* American e200, OF version 1.01.11A */ 484 if (!memcmp(&block[0x40], OFDatabaseOffsets[i].version,
474 sector = pinfo->start + 0x3c08; 485 OFDatabaseOffsets[i].version_length))
475 offset = 0xe1; 486 {
487 sector = pinfo->start + OFDatabaseOffsets[i].sector;
488 offset = OFDatabaseOffsets[i].offset;
489 break;
490 }
476 } 491 }
477 else if (!memcmp(&block[0x40], 492 if (sector && offset)
478 "PP5022AF-05.51-S301-00.12-S301.00.12E-D", 39)) 493 {
479 { /* European e200, OF version 1.00.12 */ 494 ata_read_sectors(sector, 1, block);
480 sector = pinfo->start + 0x3c5c; 495 block[offset] = 0;
481 offset = 0x2; 496 ata_write_sectors(sector, 1, block);
482 } 497 }
483 else
484 return EOK;
485 ata_read_sectors(sector, 1, block);
486 block[offset] = 0;
487 ata_write_sectors(sector, 1, block);
488 } 498 }
489 return EOK; 499 return EOK;
490} 500}
@@ -628,8 +638,10 @@ void* main(void)
628 fd = open("/part.bin", O_CREAT|O_RDWR); 638 fd = open("/part.bin", O_CREAT|O_RDWR);
629 char sector[512]; 639 char sector[512];
630 for(i=0; i<40960; i++){ 640 for(i=0; i<40960; i++){
631 printf("dumping sector %d", i); 641 if (!(i%100))
632 lcd_update(); 642 {
643 printf("dumping sector %d", i);
644 }
633 ata_read_sectors(pinfo->start + i,1 , sector); 645 ata_read_sectors(pinfo->start + i,1 , sector);
634 write(fd,sector,512); 646 write(fd,sector,512);
635 } 647 }