示例#1
0
                        inputChunk, outputChunk))
                    utils.lzo(inputChunk, outputChunk)
                else:
                    outputChunk = inputChunk

                # Size, offset (hex)
                size = "{:02X}".format(os.path.getsize(outputChunk))
                offset = "{:02X}".format(
                    os.path.getsize(binPart) + HEADER_SIZE)

                directive.filepartload(SCRIPT_FIRMWARE_FILE_NAME, offset, size)
                print('[i]     Align chunk')
                utils.alignFile(outputChunk)

                print('[i]     Append: {} -> {}'.format(outputChunk, binPart))
                utils.appendFile(outputChunk, binPart)

                if lzo:
                    if index == 0:
                        directive.unlzo(name, size)
                    else:
                        directive.unlzo_cont(name, size)
                else:
                    if len(chunks) == 1:
                        directive.write_p(name, size)
                    else:
                        # filepartload 50000000 MstarUpgrade.bin e04000 c800000
                        # mmc write.p.continue 50000000 system 0 c800000 1

                        # filepartload 50000000 MstarUpgrade.bin d604000 c800000
                        # mmc write.p.continue 50000000 system 64000 c800000 1
示例#2
0
                if not params["partition_name"] in counter:
                    counter[params["partition_name"]] = 0
                counter[params["partition_name"]] += 1

                outputImgFile = os.path.join(outputDirectory,
                                             params["partition_name"] + ".img")
                outputChunkLzoFile = os.path.join(
                    outputDirectory, params["partition_name"] +
                    str(counter[params["partition_name"]]) + ".lzo")
                outputChunkImgFile = os.path.join(
                    outputDirectory, params["partition_name"] +
                    str(counter[params["partition_name"]]) + ".img")
                # save .lzo
                print(
                    "[i] Partition: {}\tOffset: {}\tSize {} ({}) -> {}".format(
                        params["partition_name"], offset, size,
                        utils.sizeStr(int(size, 16)), outputChunkLzoFile))
                utils.copyPart(inputFile, outputChunkLzoFile, int(offset, 16),
                               int(size, 16))
                # unpack chunk .lzo -> .img
                print("[i]     Unpacking LZO (Please be patient) {} -> {}".
                      format(outputChunkLzoFile, outputChunkImgFile))
                utils.unlzo(outputChunkLzoFile, outputChunkImgFile)
                # append the chunk to main .img
                print("[i]     {} append to {}".format(outputChunkImgFile,
                                                       outputImgFile))
                utils.appendFile(outputChunkImgFile, outputImgFile)
                # delete chunk
                os.remove(outputChunkLzoFile)
                os.remove(outputChunkImgFile)