Simplified the cli of flashing scripts.

This commit is contained in:
Ole Odendahl 2022-10-23 18:00:11 +02:00
parent 8202761646
commit a25ec5ca58
No known key found for this signature in database
GPG key ID: E31DACC635D3BE01

View file

@ -9,10 +9,10 @@ from pyocd.flash.file_programmer import FileProgrammer
from mac_address_reader import MacAddressReader
parser = argparse.ArgumentParser()
parser.add_argument("-a", "--all", action="store_true", help="Flash softdevice and firmware.")
parser.add_argument("--only-mac", action="store_true", help="Read only the mac address from controller.")
parser.add_argument("-s", "--softdevice", action="store", help="File path to softdevice file.", default="../sdk/s140nrf52720/s140_nrf52_7.2.0_softdevice.hex", type=Path)
parser.add_argument("-f", "--firmware", action="store", help="File path to firmware file.", default="../code/b-parasite/_build/nrf52840_xxaa.hex", type=Path)
parser.add_argument("-s", "--softdevice", action="store", help="Optional file path to softdevice file.", default="../sdk/s140nrf52720/s140_nrf52_7.2.0_softdevice.hex", type=Path)
parser.add_argument("-f", "--firmware", action="store", help="Optional file path to firmware file.", default="../code/b-parasite/_build/nrf52840_xxaa.hex", type=Path)
parser.add_argument("--skip-softdevice", action="store_true", help="Skip flashing of the softdevice.")
parser.add_argument("--skip-firmware", action="store_true", help="Skip flashing of firmware.")
args = parser.parse_args()
@ -21,15 +21,15 @@ with ConnectHelper.session_with_chosen_probe() as session:
board = session.board
target: Target = board.target
if not args.only_mac:
if args.all:
softdevice_path: Path = args.softdevice
print(f"Flashing softdevice {softdevice_path.name}...")
FileProgrammer(session).program(str(softdevice_path))
if not args.skip_softdevice:
softdevice_path: Path = args.softdevice
print(f"Flashing softdevice {softdevice_path.name}...")
FileProgrammer(session).program(str(softdevice_path))
target.reset_and_halt()
target.resume()
target.reset_and_halt()
target.resume()
if not args.skip_firmware:
firmware_path: Path = args.firmware
print(f"Flashing firmware {firmware_path.name}...")
FileProgrammer(session).program(str(firmware_path))