From 3790371b3c60a35302df97cfd437bae11100d022 Mon Sep 17 00:00:00 2001 From: Jacob Siverskog Date: Fri, 9 Oct 2026 13:56:54 +0200 Subject: [PATCH] target: nrf54l: fix reprogramming of locked devices once an nrf54l15 has been programmed with firmware that leaves APPROTECT enabled, connecting triggers the auto-unlock mass erase. the AHB-AP object was created while the device was locked though, so the first memory access afterwards (the FICR read in check_part_info) fails with: Memory transfer fault (SWD/JTAG communication failure (FAULT ACK)) @ 0x00ffc31c-0x00ffc31f re-create the AHB-AP after a successful mass erase (and re-apply the rom base fixup), as the nrf52 target does. also bail out if the mass erase fails instead of continuing with a locked device. Signed-off-by: Jacob Siverskog --- pyocd/target/family/target_nRF54L.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pyocd/target/family/target_nRF54L.py b/pyocd/target/family/target_nRF54L.py index b81968572..c94ee0c4d 100644 --- a/pyocd/target/family/target_nRF54L.py +++ b/pyocd/target/family/target_nRF54L.py @@ -143,7 +143,13 @@ def check_flash_security(self): if self.session.options.get('auto_unlock'): LOG.warning("%s APPROTECT enabled: will try to unlock via mass erase", self.part_number) - self.mass_erase() + if not self.mass_erase(): + LOG.error("%s: mass erase failed", self.part_number) + raise exceptions.TargetError("unable to unlock device") + # Cached badness from create_ap run during AP lockout prevents memory accesses + # through the AHB-AP from succeeding. + self._discoverer._create_1_ap(AHB_AP_NUM) + self.fixup_rom_base() else: LOG.warning("%s is not in a secure state", self.part_number)