Skip to content

Commit 6cf5135

Browse files
degjorvanordicjm
authored andcommitted
[nrf noup] drivers: flash: Update to support PM removal
Update conditions for soc_secure_mem_read to support Non-Secure builds without Partition Manager. noup as Partition Manager is a NCS construct. Signed-off-by: Dag Erik Gjørvad <dag.erik.gjorvad@nordicsemi.no> (cherry picked from commit b71134c)
1 parent 649703a commit 6cf5135

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

drivers/flash/soc_flash_nrf.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ LOG_MODULE_REGISTER(flash_nrf);
3636

3737
#define SOC_NV_FLASH_NODE DT_INST(0, soc_nv_flash)
3838

39-
#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER
39+
#if CONFIG_TRUSTED_EXECUTION_NONSECURE
4040
#include <soc_secure.h>
41+
#if USE_PARTITION_MANAGER
4142
#include <pm_config.h>
42-
#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER */
43+
#endif /* USE_PARTITION_MANAGER */
44+
#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE */
4345

4446
#ifndef CONFIG_SOC_FLASH_NRF_RADIO_SYNC_NONE
4547
#define FLASH_SLOT_WRITE 7500
@@ -170,11 +172,17 @@ static int flash_nrf_read(const struct device *dev, off_t addr,
170172
}
171173
#endif
172174

173-
#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER && PM_APP_ADDRESS
175+
#if CONFIG_TRUSTED_EXECUTION_NONSECURE
176+
#if USE_PARTITION_MANAGER && PM_APP_ADDRESS
174177
if (addr < PM_APP_ADDRESS) {
175178
return soc_secure_mem_read(data, (void *)addr, len);
176179
}
180+
#elif !USE_PARTITION_MANAGER && DT_NODE_EXISTS(DT_NODELABEL(slot0_ns_partition))
181+
if ((uintptr_t)addr < DT_REG_ADDR(DT_NODELABEL(slot0_ns_partition))) {
182+
return soc_secure_mem_read(data, (void *)addr, len);
183+
}
177184
#endif
185+
#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE */
178186

179187
nrf_nvmc_buffer_read(data, (uint32_t)addr, len);
180188

0 commit comments

Comments
 (0)