From bd54f06ff7d34d38cc7b2eecb91d3f3f970d8ff2 Mon Sep 17 00:00:00 2001 From: Brad Campbell Date: Tue, 10 Dec 2024 12:27:58 +0400 Subject: [PATCH] fix vcom0 detection It wasn't working before we were just getting lucky --- setup.py | 1 + tockloader/bootloader_serial.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 96282de..b72719b 100644 --- a/setup.py +++ b/setup.py @@ -33,6 +33,7 @@ "colorama >= 0.3.7", "crcmod >= 1.7", "pycryptodome >= 3.15.0", + "pynrfjprog == 10.19.0", "pyserial >= 3.0.1", "siphash >= 0.0.1", "toml >= 0.10.2", diff --git a/tockloader/bootloader_serial.py b/tockloader/bootloader_serial.py index 846643f..48bb6b9 100644 --- a/tockloader/bootloader_serial.py +++ b/tockloader/bootloader_serial.py @@ -230,12 +230,22 @@ def _determine_port(self, any=False): break if vcom0_path != None: + # On mac, the nrfjprog tool uses the /dev/tty* paths, + # and we need the /dev/cu* paths. We just hack in a + # substitution here which will only have an effect on + # the mac paths. + vcom0_path_standarized = vcom0_path.replace( + "/dev/tty.usbmodem", "/dev/cu.usbmodem" + ) + # Update list of ports to just the one we found for # VCOM0. - ports = [p for p in ports if vcom0_path not in p.device] + ports = [p for p in ports if vcom0_path_standarized in p.device] index = 0 logging.info( - 'Discovered "{}" as nRF52840dk VCOM0.'.format(vcom0_path) + 'Discovered "{}" as nRF52840dk VCOM0.'.format( + vcom0_path_standarized + ) ) # Must close this to end the underlying pynrfjprog process.