From e979314ddaef8ba1200d29d2ef5785878f94bbfc Mon Sep 17 00:00:00 2001 From: Jonathan Nilsen Date: Wed, 23 Oct 2024 12:30:31 +0200 Subject: [PATCH] [nrf noup] scripts: west_commands: runners: nrf: workarounds for SDFW v8.0.0 SDFW v8.0.0 introduces certain changes that require matching changes in nrfutil device to ensure that west flash works properly on nrf54h20dk and nrf9280pdk. This commit adds a few temporary workarounds to ensure that west flash works with an older nrfutil device version as well: 1. Don't erase UICR, as this tries to erase the extended UICR regions as well, and those regions no longer exist (resulting in an error). 2. Reset after erasing domains with west flash --erase. This is needed for the memory owned by the different domains to be freely accessible and able to be allocated to different domains. 2. Unless doing a west flash --erase, do a RESET_VIA_SECDOM reset before programming firmware. This ensures that all the cores are stopped before writing firmware. Removing the UICR erase step seemed to cause some instability when programming, which is suspected to be caused by the firmware running while programming. Signed-off-by: Jonathan Nilsen --- scripts/west_commands/runners/nrf_common.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/scripts/west_commands/runners/nrf_common.py b/scripts/west_commands/runners/nrf_common.py index 6423253233c..8ccb6a31c03 100644 --- a/scripts/west_commands/runners/nrf_common.py +++ b/scripts/west_commands/runners/nrf_common.py @@ -273,6 +273,12 @@ def program_hex(self): if self.erase: self.exec_op('erase', core='NRFDL_DEVICE_CORE_APPLICATION') self.exec_op('erase', core='NRFDL_DEVICE_CORE_NETWORK') + # A reset is needed if repartitioning the device memory or changing peripheral + # allocations. + self.reset_target() + else: + # Ensure that firmware is not executing while erasing/programming + self.exec_op("reset", option="RESET_VIA_SECDOM") # Manage SUIT artifacts. # This logic should be executed only once per build. @@ -298,16 +304,8 @@ def program_hex(self): self.op_program(app_root_envelope_hex_file, 'ERASE_NONE', None, defer=True, core='NRFDL_DEVICE_CORE_APPLICATION') if cpuapp: - if not self.erase and self.build_conf.getboolean('CONFIG_NRF_REGTOOL_GENERATE_UICR'): - self.exec_op('erase', core='NRFDL_DEVICE_CORE_APPLICATION', - option={'chip_erase_mode': 'ERASE_UICR', - 'qspi_erase_mode': 'ERASE_NONE'}) core = 'NRFDL_DEVICE_CORE_APPLICATION' elif cpurad: - if not self.erase and self.build_conf.getboolean('CONFIG_NRF_REGTOOL_GENERATE_UICR'): - self.exec_op('erase', core='NRFDL_DEVICE_CORE_NETWORK', - option={'chip_erase_mode': 'ERASE_UICR', - 'qspi_erase_mode': 'ERASE_NONE'}) core = 'NRFDL_DEVICE_CORE_NETWORK' else: if self.erase: