diff --git a/DumpUBoot.py b/DumpUBoot.py index afc2eb7..17f72f7 100644 --- a/DumpUBoot.py +++ b/DumpUBoot.py @@ -11,7 +11,7 @@ class uImage: IH_OS_FREEBSD = 3 IH_OS_4_4BSD = 4 IH_OS_LINUX = 5 - IH_OS_SVR 4= 6 + IH_OS_SVR4= 6 IH_OS_ESIX = 7 IH_OS_SOLARIS = 8 IH_OS_IRIX = 9 @@ -33,7 +33,7 @@ class uImage: IH_OS_STR_FREEBSD = "FreeBSD" IH_OS_STR_4_4BSD = "4.4BSD" IH_OS_STR_LINUX = "Linux" - IH_OS_STR_SVR 4= "SVR4" + IH_OS_STR_SVR4= "SVR4" IH_OS_STR_ESIX = "Esix" IH_OS_STR_SOLARIS = "Solaris" IH_OS_STR_IRIX = "Irix" @@ -52,40 +52,40 @@ class uImage: IH_CPU_INVALID = 0 IH_CPU_ALPHA = 1 IH_CPU_ARM = 2 - IH_CPU_I38 6= 3 - IH_CPU_IA6 4= 4 + IH_CPU_I386= 3 + IH_CPU_IA64= 4 IH_CPU_MIPS = 5 - IH_CPU_MIPS6 4= 6 + IH_CPU_MIPS64= 6 IH_CPU_PPC = 7 - IH_CPU_S39 0= 8 + IH_CPU_S390= 8 IH_CPU_SH = 9 IH_CPU_SPARC = 10 - IH_CPU_SPARC6 4= 11 + IH_CPU_SPARC64= 11 IH_CPU_M68K = 12 IH_CPU_NIOS = 13 IH_CPU_MICROBLAZE = 14 - IH_CPU_NIOS 2= 15 + IH_CPU_NIOS2= 15 IH_CPU_BLACKFIN = 16 - IH_CPU_AVR3 2= 17 + IH_CPU_AVR32= 17 IH_CPU_STR_INVALID = "Invalid CPU" IH_CPU_STR_ALPHA = "Alpha" IH_CPU_STR_ARM = "ARM" - IH_CPU_STR_I38 6= "Intel x86" - IH_CPU_STR_IA6 4= "IA64" + IH_CPU_STR_I386= "Intel x86" + IH_CPU_STR_IA64= "IA64" IH_CPU_STR_MIPS = "MIPS" - IH_CPU_STR_MIPS6 4= "MIPS 64 Bit" + IH_CPU_STR_MIPS64= "MIPS 64 Bit" IH_CPU_STR_PPC = "PowerPC" - IH_CPU_STR_S39 0= "IBM S390" + IH_CPU_STR_S390= "IBM S390" IH_CPU_STR_SH = "SuperH" IH_CPU_STR_SPARC = "Sparc" - IH_CPU_STR_SPARC6 4= "Sparc 64 Bit" + IH_CPU_STR_SPARC64= "Sparc 64 Bit" IH_CPU_STR_M68K = "M68K" IH_CPU_STR_NIOS = "Nios-32" IH_CPU_STR_MICROBLAZE = "MicroBlaze" - IH_CPU_STR_NIOS 2= "Nios-II" + IH_CPU_STR_NIOS2= "Nios-II" IH_CPU_STR_BLACKFIN = "Blackfin" - IH_CPU_STR_AVR3 2= "AVR32" + IH_CPU_STR_AVR32= "AVR32" IH_TYPE_INVALID = 0 IH_TYPE_STANDALONE = 1 @@ -109,7 +109,7 @@ class uImage: COMP_NONE = 0 COMP_GZIP = 1 - COMP_BZIP 2= 2 + COMP_BZIP2= 2 def __init__(self): pass diff --git a/FlashDevice.py b/FlashDevice.py index 84de0b5..dd88f27 100644 --- a/FlashDevice.py +++ b/FlashDevice.py @@ -16,23 +16,23 @@ class NandIO: NAND_CMD_READID = 0x90 - NAND_CMD_READ 0= 0 - NAND_CMD_READ 1= 1 + NAND_CMD_READ0= 0 + NAND_CMD_READ1= 1 NAND_CMD_RNDOUT = 5 NAND_CMD_PAGEPROG = 0x10 NAND_CMD_READOOB = 0x50 - NAND_CMD_ERASE 1= 0x60 + NAND_CMD_ERASE1= 0x60 NAND_CMD_STATUS = 0x70 NAND_CMD_STATUS_MULTI = 0x71 NAND_CMD_SEQIN = 0x80 NAND_CMD_RNDIN = 0x85 NAND_CMD_READID = 0x90 - NAND_CMD_ERASE 2= 0xd0 + NAND_CMD_ERASE2= 0xd0 NAND_CMD_PARAM = 0xec NAND_CMD_RESET = 0xff NAND_CMD_LOCK = 0x2a - NAND_CMD_UNLOCK 1= 0x23 - NAND_CMD_UNLOCK 2= 0x24 + NAND_CMD_UNLOCK1= 0x23 + NAND_CMD_UNLOCK2= 0x24 NAND_CMD_READSTART = 0x30 NAND_CMD_RNDOUTSTART = 0xE0 NAND_CMD_CACHEDPROG = 0x15 @@ -170,7 +170,7 @@ def WaitReady(self): while 1: self.Ftdi.write_data(Array('B', [Ftdi.GET_BITS_HIGH])) data = self.Ftdi.read_data_bytes(1) - if data[0]& 2= =0x2: + if data[0]&2 ==0x2: return else: if self.Debug>0: @@ -181,9 +181,9 @@ def nandRead(self, cl, al, count): cmds = [] cmd_type = 0 if cl == 1: - cmd_type| = self.ADR_CL + cmd_type|= self.ADR_CL if al == 1: - cmd_type| = self.ADR_AL + cmd_type|= self.ADR_AL cmds += [Ftdi.READ_EXTENDED, cmd_type, 0] @@ -288,7 +288,7 @@ def GetID(self): else: onfi = False - if id[0] == 0x98: + if id[0] == 0x98: self.Manufacturer = "Toshiba" elif id[0] == 0xec: self.Manufacturer = "Samsung" diff --git a/FlashUtil.py b/FlashUtil.py index 7c8d19f..8da6312 100644 --- a/FlashUtil.py +++ b/FlashUtil.py @@ -68,7 +68,7 @@ def CheckECC(self, start_page = 0, end_page = -1): oob_ecc1 = ord(data[self.io.PageSize+1]) oob_ecc2 = ord(data[self.io.PageSize+2]) - if (oob_ecc 0= =0xff and oob_ecc 1= =0xff and oob_ecc 2= =0xff) or (oob_ecc 0= =0x00 and oob_ecc 1= =0x00 and oob_ecc 2= =0x00): + if (oob_ecc0 ==0xff and oob_ecc1==0xff and oob_ecc2==0xff) or (oob_ecc0==0x00 and oob_ecc1==0x00 and oob_ecc2==0x00): continue (ecc0, ecc1, ecc2) = ecc.CalcECC(body) @@ -269,7 +269,7 @@ def ReadSeqPages(self, start_page = -1, end_page = -1, remove_oob = False, filen return whole_data[0:maximum] return whole_data - def AddOOB(self, filename, output_filename, jffs 2= False): + def AddOOB(self, filename, output_filename, jffs2= False): fd = open(filename, 'rb') wfd = open(output_filename, "wb") @@ -287,7 +287,7 @@ def AddOOB(self, filename, output_filename, jffs 2= False): oob_postfix = '\xFF' * 13 if current_output_size% self.io.BlockSize == 0: - if jffs2 and current_block_number% 2= =0: + if jffs2 and current_block_number% 2==0: oob_postfix = "\xFF\xFF\xFF\xFF\xFF\x85\x19\x03\x20\x08\x00\x00\x00" current_block_number += 1