Index: emcore/trunk/tools/emcore.py |
— | — | @@ -808,13 +808,14 @@ |
809 | 809 | self.logger.info("done\n")
|
810 | 810 |
|
811 | 811 | @command
|
812 | | - def ipodclassic_writebbt(self, tempaddr, filename):
|
| 812 | + def ipodclassic_writebbt(self, filename, tempaddr = None):
|
813 | 813 | """
|
814 | 814 | Target-specific function: ipodclassic
|
815 | | - Uploads the bad block table <filename> to
|
816 | | - memory at <tempaddr> and writes it to the hard disk
|
| 815 | + Uploads the bad block table <filename> to memory at <tempaddr>
|
| 816 | + (or an allocated block if not given) and writes it to the hard disk
|
817 | 817 | """
|
818 | | - tempaddr = to_int(tempaddr)
|
| 818 | + if tempaddr != None:
|
| 819 | + tempaddr = to_int(tempaddr)
|
819 | 820 | try:
|
820 | 821 | f = open(filename, 'rb')
|
821 | 822 | except IOError:
|
Index: emcore/trunk/tools/libemcore.py |
— | — | @@ -542,11 +542,11 @@ |
543 | 543 | Access the hard disk, type = 0 (read) / 1 (write)
|
544 | 544 | """
|
545 | 545 | rc = self.lib.monitorcommand(struct.pack("<IIQIIII", 0xffff0002, type, sector, count, addr, 0, 0), "III", ("rc", None, None))
|
546 | | - if (rc > 0x80000000):
|
547 | | - raise DeviceError("HDD access (type=%d, sector=%d, count=%d, addr=0x%08X) failed with RC 0x%08X" % (type, sector, count, addr, rc))
|
| 546 | + if (rc.rc > 0x80000000):
|
| 547 | + raise DeviceError("HDD access (type=%d, sector=%d, count=%d, addr=0x%08X) failed with RC 0x%08X" % (type, sector, count, addr, rc.rc))
|
548 | 548 |
|
549 | 549 | @command(target = 0x4c435049)
|
550 | | - def ipodclassic_writebbt(self, bbt, tempaddr):
|
| 550 | + def ipodclassic_writebbt(self, bbt, tempaddr = None):
|
551 | 551 | """ Target-specific function: ipodclassic
|
552 | 552 | Write hard drive bad block table
|
553 | 553 | """
|
— | — | @@ -558,19 +558,29 @@ |
559 | 559 | raise ArgumentError("The specified file is not an emCORE hard disk BBT")
|
560 | 560 | virtualsectors = bbtheader[2]
|
561 | 561 | bbtsectors = bbtheader[3]
|
562 | | - self.write(tempaddr, bbt)
|
563 | | - sector = 0
|
564 | | - count = 1
|
565 | | - offset = 0
|
566 | | - for i in range(bbtsectors):
|
567 | | - if bbtheader[4][i] == sector + count:
|
568 | | - count = count + 1
|
569 | | - else:
|
570 | | - self.ipodclassic_hddaccess(1, sector, count, tempaddr + offset)
|
571 | | - offset = offset + count * 4096
|
572 | | - sector = bbtheader[4][i]
|
573 | | - count = 1
|
574 | | - self.ipodclassic_hddaccess(1, sector, count, tempaddr + offset)
|
| 562 | + if tempaddr is None:
|
| 563 | + tempaddr = self.malloc(len(bbt))
|
| 564 | + malloc = True
|
| 565 | + else:
|
| 566 | + malloc = False
|
| 567 | + try:
|
| 568 | + self.write(tempaddr, bbt)
|
| 569 | + sector = 0
|
| 570 | + count = 1
|
| 571 | + offset = 0
|
| 572 | + for i in range(bbtsectors):
|
| 573 | + if bbtheader[4][i] == sector + count:
|
| 574 | + count = count + 1
|
| 575 | + else:
|
| 576 | + self.ipodclassic_hddaccess(1, sector, count, tempaddr + offset)
|
| 577 | + offset = offset + count * 4096
|
| 578 | + sector = bbtheader[4][i]
|
| 579 | + count = 1
|
| 580 | + self.ipodclassic_hddaccess(1, sector, count, tempaddr + offset)
|
| 581 | + except:
|
| 582 | + if malloc == True:
|
| 583 | + self.free(tempaddr)
|
| 584 | + raise
|
575 | 585 |
|
576 | 586 | @command()
|
577 | 587 | def storage_get_info(self, volume):
|