Skip to content

Instantly share code, notes, and snippets.

@tachang
Created August 28, 2020 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tachang/b687875acd9c966f9a9640aa81b2c60a to your computer and use it in GitHub Desktop.
Save tachang/b687875acd9c966f9a9640aa81b2c60a to your computer and use it in GitHub Desktop.
Extract Firmware Pieces from Dump of Flash for Lenovo C2E Camera
#!/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