Skip to content

Commit 5056ab2

Browse files
SebastianBoeAnas Nashif
authored and
Anas Nashif
committed
runner: nrfjprog: Improve error messages
When a debugger is already connected to the JLink debug adapter nrfjprog.py would incorrectly detect that the snr is '0' and try to flash a device with that snr. Also, when there were no boards connected, nrfjprog.py would incorrectly state that there were multiple boards connected. This patch improves the error feedback so that a user can more easily debug why he can't flash his device. Signed-off-by: Sebastian Bøe <[email protected]>
1 parent 86e6e67 commit 5056ab2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

scripts/support/runner/nrfjprog.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,13 @@ def get_board_snr_from_user(self):
4040
snrs = self.check_output(['nrfjprog', '--ids'])
4141
snrs = snrs.decode(sys.getdefaultencoding()).strip().splitlines()
4242

43-
if len(snrs) == 1:
44-
return snrs[0]
43+
if len(snrs) == 0:
44+
raise Exception('"nrfjprog --ids" did not find a board; Is the board connected?')
45+
elif len(snrs) == 1:
46+
board_snr = snrs[0]
47+
if board_snr == '0':
48+
raise Exception('"nrfjprog --ids" returned 0; is a debugger already connected?')
49+
return board_snr
4550

4651
print('There are multiple boards connected.')
4752
for i, snr in enumerate(snrs, 1):

0 commit comments

Comments
 (0)