def Handle_uImage(self, Key): OrigPath = os.path.join(self.Source, Key + ".uImage") DestPath = os.path.join(self.BuildDir, Key) DataPath = os.path.join(self.BuildDir, Key + ".raw") # Read uImage header of the original file. OrigFile = open(OrigPath, "rb") Header = uImage.parseHeader(OrigFile) OrigFile.close() if Header["magic"] != uImage.HEADER_MAGIC: OrigFile.close() self.Logger.error("Invalid uImage magic number!") return 1 Arch = uImage.archType[Header["arch"]][1] OS = uImage.osType[Header["osType"]][1] ImageType = uImage.imageType[Header["imageType"]][1] Compression = uImage.compressType[Header["compression"]][1] LoadAddress = str(hex(Header["loadAddr"]))[2:] EntryPoint = str(hex(Header["entryAddr"]))[2:] Name = Header["name"].decode("ascii", errors="ignore").rstrip('\0') Result = subprocess.call([ "mkimage", "-A", Arch, "-O", OS, "-T", ImageType, "-C", Compression, "-a", LoadAddress, "-e", EntryPoint, "-n", Name, "-d", DataPath, DestPath ]) self.Logger.debug("Adding '%s' to zip file list.", Key) self.ZipFileList.append((DestPath, Key)) return Result
def Handle_uImage(self, Key): Path = os.path.join(self.DestDir, Key) OrigFile = open(Path, "rb") # Read uImage header. Header = uImage.parseHeader(OrigFile) if Header["magic"] != uImage.HEADER_MAGIC: OrigFile.close() self.Logger.error("Invalid uImage magic number!") return 1 # Save uImage header HeaderFile = open(Path + ".uImage", "wb") HeaderFile.write(OrigFile.read(uImage.HEADER_SIZE)) HeaderFile.close() # Save raw image RawFile = open(Path + ".raw", "wb") shutil.copyfileobj(OrigFile, RawFile) RawFile.close() OrigFile.close() return 0