Created
August 28, 2020 18:29
-
-
Save tachang/b687875acd9c966f9a9640aa81b2c60a to your computer and use it in GitHub Desktop.
Extract Firmware Pieces from Dump of Flash for Lenovo C2E Camera
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding=utf-8 | |
import click | |
import os | |
CHECK_FOLDER = os.path.isdir("flash") | |
if not CHECK_FOLDER: | |
os.makedirs("flash") | |
@click.command() | |
@click.argument('inputfile', default="demo_5.5.1.194.bin", type=click.Path(exists=True)) | |
def cli(inputfile): | |
dic = [ | |
("uboot", 0x40000), | |
("kernel", 0x180000), | |
("rootfs", 0x280000), | |
("rom", 0x20000), | |
("config", 0x80000), | |
("appfs", 0x900000), | |
("appfs1", 0x220000), | |
] | |
inputfile = click.format_filename(inputfile) | |
fullflash = open(inputfile, 'rb') | |
fullflash.seek(0) | |
for name, size in dic: | |
filename = "flash/" + name + ".bin" | |
buffer = fullflash.read(size) | |
f = open(filename, "wb") | |
f.write(buffer) | |
if __name__ == '__main__': | |
cli() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment