freemyipod r776 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r775‎ | r776 | r777 >
Date:16:17, 13 October 2011
Author:theseven
Status:new
Tags:
Comment:
emcore.py: Make ipodnano2g_restorenand handle blank pages correctly
TODO: Make this more efficient
Modified paths:
  • /emcore/trunk/tools/emcore.py (modified) (history)

Diff [purge]

Index: emcore/trunk/tools/emcore.py
@@ -841,28 +841,27 @@
842842 except IOError:
843843 raise ArgumentError("Can not open input files!")
844844 try:
845 - buf = self.emcore.memalign(0x10, banks * ppb * 0x844)
 845+ buf = self.emcore.memalign(0x10, 0x844)
846846 for block in range(info["blocks"]):
847847 for bank in range(info["banks"]):
848 - self.logger.info("\r Erasing block %d bank %d" % (block, bank))
 848+ self.logger.info("\r Erasing block %d bank %d " % (block, bank))
849849 self.emcore.ipodnano2g_nanderase(buf, block * banks + bank, 1)
850850 rc = struct.unpack("<I", self.emcore.read(buf, 4))[0]
851851 if rc != 0: self.logger.info("\rBlock %d bank %d erase failed with RC %08X\n" % (block, bank, rc))
852 - self.logger.info("\r Uploading block %d data " % block)
853 - self.emcore.write(buf, datafile.read(banks * ppb * 2048))
854 - self.emcore.write(buf + banks * ppb * 2048, sparefile.read(banks * ppb * 64))
855 - self.logger.info("\rProgramming block %d " % block)
856 - self.emcore.ipodnano2g_nandwrite(buf, block * banks * ppb, banks * ppb, 0)
857 - rc = struct.unpack("<%dI" % (banks * ppb), self.emcore.read(buf + banks * ppb * 2112, banks * ppb * 4))
858852 for page in range(ppb):
859 - for bank in range(banks):
860 - if rc[banks * page + bank] != 0:
861 - self.logger.info("\rBlock %d bank %d page %d programming failed with RC %08X\n" % (block, bank, page, rc[banks * page + bank]))
 853+ for bank in range(banks):
 854+ data = datafile.read(2048) + sparefile.read(64)
 855+ if data == "\xff" * 2112: continue
 856+ self.emcore.write(buf, data)
 857+ self.logger.info("\rProgramming block %d page %d bank %d" % (block, page, bank))
 858+ self.emcore.ipodnano2g_nandwrite(buf, ((block * ppb) + page) * banks + bank, 1, 0)
 859+ rc = struct.unpack("<I", self.emcore.read(buf + 2112, 4))[0]
 860+ if rc != 0: self.logger.info("\rBlock %d bank %d page %d programming failed with RC %08X\n" % (block, bank, page, rc))
862861 finally:
863862 self.emcore.free(buf)
864863 datafile.close()
865864 sparefile.close()
866 - self.logger.info("\rdone\n")
 865+ self.logger.info("\ndone\n")
867866
868867 @command
869868 def ipodnano2g_wipenand(self, filename, force=False):