Index: embios/trunk/tools/embios.py |
— | — | @@ -697,7 +697,7 @@ |
698 | 698 | doecc = int(doecc)
|
699 | 699 | checkempty = int(checkempty)
|
700 | 700 | self.logger.info("Reading "+self._hex(count)+" NAND pages starting at "+self._hex(start)+" to "+self._hex(addr)+"...")
|
701 | | - self.embios.lib.dev.timeout = 20000
|
| 701 | + self.embios.lib.dev.timeout = 30000
|
702 | 702 | self.embios.ipodnano2g_nandread(addr, start, count, doecc, checkempty)
|
703 | 703 | self.logger.info("done\n")
|
704 | 704 |
|
— | — | @@ -712,7 +712,7 @@ |
713 | 713 | count = self._hexint(count)
|
714 | 714 | doecc = int(doecc)
|
715 | 715 | self.logger.info("Writing "+self._hex(count)+" NAND pages starting at "+self._hex(start)+" from "+self._hex(addr)+"...")
|
716 | | - self.embios.lib.dev.timeout = 20000
|
| 716 | + self.embios.lib.dev.timeout = 30000
|
717 | 717 | self.embios.ipodnano2g_nandwrite(addr, start, count, doecc)
|
718 | 718 | self.logger.info("done\n")
|
719 | 719 |
|
— | — | @@ -726,10 +726,71 @@ |
727 | 727 | start = self._hexint(start)
|
728 | 728 | count = self._hexint(count)
|
729 | 729 | self.logger.info("Erasing "+self._hex(count)+" NAND blocks starting at "+self._hex(start)+" and logging to "+self._hex(addr)+"...")
|
730 | | - self.embios.lib.dev.timeout = 20000
|
| 730 | + self.embios.lib.dev.timeout = 30000
|
731 | 731 | self.embios.ipodnano2g_nanderase(addr, start, count)
|
732 | 732 | self.logger.info("done\n")
|
733 | 733 |
|
| 734 | + @command
|
| 735 | + def ipodnano2g_dumpnand(self, filenameprefix):
|
| 736 | + """
|
| 737 | + Target-specific function: ipodnano2g
|
| 738 | + Dumps the whole NAND chip to four files
|
| 739 | + """
|
| 740 | + info = self.embios.ipodnano2g_getnandinfo()
|
| 741 | + self.logger.info("Dumping NAND contents...")
|
| 742 | + try:
|
| 743 | + infofile = open(filenameprefix+"_info.txt", 'wb')
|
| 744 | + datafile = open(filenameprefix+"_data.bin", 'wb')
|
| 745 | + sparefile = open(filenameprefix+"_spare.bin", 'wb')
|
| 746 | + statusfile = open(filenameprefix+"_status.bin", 'wb')
|
| 747 | + except IOError:
|
| 748 | + raise ArgumentError("Can not open file for writing!")
|
| 749 | + infofile.write("NAND chip type: "+self._hex(info["type"])+"\r\n")
|
| 750 | + infofile.write("Number of banks: "+str(info["banks"])+"\r\n")
|
| 751 | + infofile.write("Number of blocks: "+str(info["blocks"])+"\r\n")
|
| 752 | + infofile.write("Number of user blocks: "+str(info["userblocks"])+"\r\n")
|
| 753 | + infofile.write("Pages per block: "+str(info["pagesperblock"])+"\r\n")
|
| 754 | + self.embios.lib.dev.timeout = 30000
|
| 755 | + for i in range(info["banks"] * info["blocks"] * info["pagesperblock"] / 8192):
|
| 756 | + self.logger.info(".")
|
| 757 | + self.embios.ipodnano2g_nandread(0x08000000, i * 8192, 8192, 1, 1)
|
| 758 | + datafile.write(self.embios.read(0x08000000, 0x01000000))
|
| 759 | + sparefile.write(self.embios.read(0x09000000, 0x00080000))
|
| 760 | + statusfile.write(self.embios.read(0x09080000, 0x00008000))
|
| 761 | + infofile.close()
|
| 762 | + datafile.close()
|
| 763 | + sparefile.close()
|
| 764 | + statusfile.close()
|
| 765 | + self.logger.info("done\n")
|
| 766 | +
|
| 767 | + @command
|
| 768 | + def ipodnano2g_wipenand(self, filename, force=False):
|
| 769 | + """
|
| 770 | + Target-specific function: ipodnano2g
|
| 771 | + Wipes the whole NAND chip and logs the result to a file
|
| 772 | + <force>: Use this flag to suppress the 5 seconds delay
|
| 773 | + """
|
| 774 | + self.logger.info("Wiping the whole NAND chip!\n")
|
| 775 | + if force == False:
|
| 776 | + self.logger.info("If this was not what you intended press Ctrl-C NOW")
|
| 777 | + for i in range(10):
|
| 778 | + self.logger.info(".")
|
| 779 | + time.sleep(1)
|
| 780 | + self.logger.info("\n")
|
| 781 | + info = self.embios.ipodnano2g_getnandinfo()
|
| 782 | + self.logger.info("Wiping NAND contents...")
|
| 783 | + try:
|
| 784 | + statusfile = open(filename, 'wb')
|
| 785 | + except IOError:
|
| 786 | + raise ArgumentError("Can not open file for writing!")
|
| 787 | + self.embios.lib.dev.timeout = 30000
|
| 788 | + for i in range(info["banks"] * info["blocks"] / 64):
|
| 789 | + self.logger.info(".")
|
| 790 | + self.embios.ipodnano2g_nanderase(0x08000000, i * 64, 64, 1, 1)
|
| 791 | + statusfile.write(self.embios.read(0x08000000, 0x00000100))
|
| 792 | + statusfile.close()
|
| 793 | + self.logger.info("done\n")
|
| 794 | +
|
734 | 795 | if __name__ == "__main__":
|
735 | 796 | if len(sys.argv) < 2:
|
736 | 797 | usage("No command specified")
|