Skip to content

Commit e9fb2df

Browse files
SebastianBoerlubos
authored andcommitted
west: ncs-ironside-se-update: Improve error reporting
Improve error reporting for west ncs-ironside-se-update. return codes are now checked for underlying "nrfutil device" commands, and the existence of files is now checked. Ref: NCSDK-NONE Signed-off-by: Sebastian Bøe <[email protected]>
1 parent 7b1ea16 commit e9fb2df

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

scripts/west_commands/ncs_ironside_se_update.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,14 @@ def do_run(self, args, unknown_args):
8888
def nrfutil_device(cmd: str) -> str:
8989
cmd = f"nrfutil device {cmd} --serial-number {args.serial}"
9090
self.dbg(cmd)
91+
9192
result = subprocess.run(cmd, shell=True, text=True, capture_output=True)
93+
9294
self.dbg(result.stdout)
95+
96+
if result.returncode != 0:
97+
self.die(f"{cmd} returned '{result.returncode}' and '{result.stderr.strip()}'")
98+
9399
return result.stdout
94100

95101
def nrfutil_read(address: int, num_bytes: int) -> bytes:
@@ -112,12 +118,15 @@ def get_status() -> str:
112118
return self._decode_status(nrfutil_read(UPDATE_STATUS_ADDR, 4))
113119

114120
def program(hex_file: PosixPath) -> None:
121+
if not hex_file.exists():
122+
self.die(f"Firmware file does not exist: {hex_file}")
123+
115124
nrfutil_device(
116125
f"program --options chip_erase_mode=ERASE_NONE --firmware {hex_file}"
117126
)
118127

119128
if not args.allow_erase:
120-
raise RuntimeError(
129+
self.die(
121130
"Unable to perform update without erasing the device, set '--allow-erase'"
122131
)
123132
with TemporaryDirectory() as tmpdir:
@@ -130,8 +139,13 @@ def program(hex_file: PosixPath) -> None:
130139
update_hex = "ironside_se_update.hex"
131140

132141
update_to_install = Path(tmpdir, "update", update_hex)
142+
143+
# Check if required files exist in the extracted ZIP
144+
if not update_app.exists():
145+
self.die(f"Update application file not found in ZIP: {update_app}")
146+
133147
if not update_to_install.exists():
134-
raise RuntimeError("Unable to locate update hex within zip file")
148+
self.die(f"Update firmware file not found in ZIP: {update_to_install}")
135149

136150
self.inf(
137151
f"Version before update: {get_version()}, status: {get_status()}"

0 commit comments

Comments
 (0)