Skip to content

Commit

Permalink
scripts: west_commands: extend west ncs-provision command with --dev-id
Browse files Browse the repository at this point in the history
Extend west ncs-provision command with option to select connected
device by its serial number.

Signed-off-by: Grzegorz Chwierut <[email protected]>
  • Loading branch information
gchwier authored and rlubos committed Oct 30, 2024
1 parent d8f5a50 commit 19c0f9c
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions scripts/west_commands/ncs-provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def do_add_parser(self, parser_adder):
help="Input .pem file with ED25519 private key"
)
upload_parser.add_argument("-s", "--soc", type=str, help="SoC",
choices=["nrf54l15"], required=True)
choices=["nrf54l15"], required=True)
upload_parser.add_argument("--dev-id", help="Device serial number")

return parser

Expand All @@ -50,8 +51,8 @@ def do_run(self, args, unknown_args):
with open(keyfile, 'rb') as f:
priv_key = load_pem_private_key(f.read(), password=None)
pub_key = priv_key.public_key()
nrfprovision = subprocess.run(
["nrfprovision",
command = [
"nrfprovision",
"provision",
"-r",
"REVOKED",
Expand All @@ -65,9 +66,15 @@ def do_run(self, args, unknown_args):
"ED25519",
"-d",
"0x20000000",
"--verify"],
stderr=subprocess.PIPE,
text=True)
"--verify"
]
if args.dev_id:
command.extend(["--snr", args.dev_id])
nrfprovision = subprocess.run(
command,
stderr=subprocess.PIPE,
text=True
)
stderr = nrfprovision.stderr
print(stderr, file=sys.stderr)
if re.search('fail', stderr) or nrfprovision.returncode:
Expand Down

0 comments on commit 19c0f9c

Please sign in to comment.