Files
Linux_Drivers/build/tools/cv181x/usb_dl/cv181x_dl.py
sam.xiang a4f213ceb0 [build] add cvitek build scripts
Change-Id: If63ce4a669e5d4d72b8e3b9253336dd99bf74c30
2023-03-10 20:35:59 +08:00

70 lines
1.7 KiB
Python

#!/usr/bin/python3
import argparse
import logging
import os
FORMAT = "%(levelname)s: %(message)s"
logging.basicConfig(level=logging.INFO, format=FORMAT)
parser = argparse.ArgumentParser(description="Create CVITEK device image")
def parse_Args():
cur_dir = os.path.abspath(os.getcwd())
parser.add_argument(
"--image_dir",
metavar="path",
type=str,
default=cur_dir,
help="the folder path to dir inclued fip,rootfs kernel and xml",
)
parser.add_argument(
"-v", "--verbose", help="increase output verbosity", action="store_true"
)
parser.add_argument("--mac",
metavar="mac address",
type=str,
help="set mac address")
group = parser.add_mutually_exclusive_group()
group.add_argument("--serial", action="store_true", default=False)
group.add_argument("--libusb", action="store_true", default=False)
args = parser.parse_args()
return args
def main():
args = parse_Args()
image_dir = args.image_dir
mac = args.mac
if (not args.serial and not args.libusb) or args.serial:
driver = "serial"
else:
driver = "libusb"
logging.info("Using %s" % driver)
logging.info("CV181X USB download start\n")
cmd = (
"python rom_usb_dl/cv181x_rom_usb_download.py --image_dir "
+ image_dir
)
os.system(cmd)
cmd = (
"python rom_usb_dl/cv181x_uboot_usb_download.py --image_dir "
+ image_dir
+ " --"
+ driver
)
if (mac):
cmd = cmd + " --mac " + mac
os.system(cmd)
logging.info("CV181X USB download end\n")
if __name__ == "__main__":
main()