-
Notifications
You must be signed in to change notification settings - Fork 1
/
uboot_extract.py
executable file
·33 lines (28 loc) · 1.06 KB
/
uboot_extract.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/python3
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright 2023 Yang Xiwen
# Extract essential binaries from stock u-boot
# AUXCODE.img, BOOT[0-2].reg etc
import click
import os
from image import FastbootImageV1
@click.command()
@click.argument("filename", type=click.File("rb"), required=True)
@click.option("-p", "--print", "p", type=bool, required=False, default=False, is_flag=True, help="print image info")
@click.option("-d", "--path", "d", type=click.Path(), required=False, default=".", show_default=True, help="set the output path of the images")
@click.option("-e", "--strip", "e", type=bool, required=False, default=False, is_flag=True, help="strip the suffix 0s to minimize the image size")
def extract(filename, p, d, e):
"""
A tool to extract some essential binaries for l-loader from stock firmware
"""
i = FastbootImageV1(filename)
i.parse_image()
i.extract_images()
if e:
i.truncate_to_minimal()
i.write_to_directory(d)
if p:
click.echo(i)
return None
if __name__ == '__main__':
extract();