Skip to content

Commit 3ba0b73

Browse files
ArekBalysNordicjukkar
authored andcommitted
[nrf noup] drivers: flash: Allow reading secure mem by nrf_rram.
fixup! [nrf noup] tree-wide: support NCS Partition Manager (PM) definitions To read the secure memory we need to use soc_secure_mem_read function instead of memcpy. This commit allows to use the soc_secure_mem_read function if the CONFIG_TRUSTED_EXECUTION_NONSECURE and PARTITION_MANAGER is enabled. Signed-off-by: Arkadiusz Balys <[email protected]> (cherry picked from commit 711346a)
1 parent a97deec commit 3ba0b73

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/flash/soc_flash_nrf_rram.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ LOG_MODULE_REGISTER(flash_nrf_rram, CONFIG_FLASH_LOG_LEVEL);
5454
#define WRITE_BLOCK_SIZE_FROM_DT DT_PROP(RRAM, write_block_size)
5555
#define ERASE_VALUE 0xFF
5656

57+
#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER
58+
#include <soc_secure.h>
59+
#include <pm_config.h>
60+
#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER */
61+
5762
#ifdef CONFIG_MULTITHREADING
5863
static struct k_sem sem_lock;
5964
#define SYNC_INIT() k_sem_init(&sem_lock, 1, 1)
@@ -279,6 +284,12 @@ static int nrf_rram_read(const struct device *dev, off_t addr, void *data, size_
279284
}
280285
addr += RRAM_START;
281286

287+
#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER && PM_APP_ADDRESS
288+
if (addr < PM_APP_ADDRESS) {
289+
return soc_secure_mem_read(data, (void *)addr, len);
290+
}
291+
#endif
292+
282293
memcpy(data, (void *)addr, len);
283294

284295
return 0;

0 commit comments

Comments
 (0)