freemyipod r174 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r173‎ | r174 | r175 >
Date:08:42, 24 August 2010
Author:farthen
Status:new
Tags:
Comment:
libembios/embios: Implement writerawbootflash() and readrawbootflash()
Modified paths:
  • /embios/trunk/tools/embios.py (modified) (history)
  • /embios/trunk/tools/libembios.py (modified) (history)

Diff [purge]

Index: embios/trunk/tools/embios.py
@@ -606,10 +606,12 @@
607607 addr_flash = self._hexint(addr_flash)
608608 addr_mem = self._hexint(addr_mem)
609609 size = self._hexint(size)
610 - raise NotImplementedError
 610+ self.logger.info("Dumping boot flash addresses "+self._hex(addr_flash)+" - "+
 611+ hex(addr_flash+size)+" to "+self._hex(addr_mem)+" - "+self._hex(addr_mem+size)+"\n")
 612+ self.embios.bootflashread(addr_flash, addr_mem, size)
611613
612614 @command
613 - def writerawbootflash(self, addr_flash, addr_mem, size):
 615+ def writerawbootflash(self, addr_flash, addr_mem, size, force=False):
614616 """
615617 Writes <size> bytes from memory to bootflash.
616618 ATTENTION: Don't call this unless you really know what you're doing!
@@ -616,11 +618,22 @@
617619 This may BRICK your device (unless it has a good recovery option)
618620 <addr_mem>: the address in memory to copy the data from
619621 <addr_bootflsh>: the address in bootflash to write to
 622+ <force>: Use this flag to suppress the 5 seconds delay
620623 """
621624 addr_flash = self._hexint(addr_flash)
622625 addr_mem = self._hexint(addr_mem)
623626 size = self._hexint(size)
624 - raise NotImplementedError
 627+ force = self._bool(force)
 628+ self.logger.info("Writing boot flash from the memory in "+self._hex(addr_mem)+" - "+
 629+ hex(addr_mem+size)+" to "+self._hex(addr_flash)+" - "+self._hex(addr_flash+size)+"\n")
 630+ if force == False:
 631+ self.logger.info("If this was not what you intended press Ctrl-C NOW")
 632+ import time
 633+ for i in range(5):
 634+ self.logger.info(".")
 635+ time.sleep(1)
 636+ self.logger.info("\n")
 637+ self.embios.bootflashwrite(addr_flash, addr_mem, size)
625638
626639 @command
627640 def flushcaches(self):
Index: embios/trunk/tools/libembios.py
@@ -364,11 +364,13 @@
365365 """ Copies the data in the bootflash at 'flashaddr' of the specified size
366366 to the memory at addr 'memaddr'
367367 """
 368+ return self.lib.monitorcommand(struct.pack("IIII", 22, memaddr, flashaddr, size), "III", (None, None, None))
368369
369370 def bootflashwrite(self, memaddr, flashaddr, size):
370371 """ Copies the data in the memory at 'memaddr' of the specified size
371372 to the boot flash at addr 'flashaddr'
372373 """
 374+ return self.lib.monitorcommand(struct.pack("IIII", 23, memaddr, flashaddr, size), "III", (None, None, None))
373375
374376 def execfirmware(self, addr):
375377 """ Executes the firmware at 'addr' and passes all control to it. """