Skip to content

Commit

Permalink
[nrf noup] drivers: flash: Allow reading secure mem by nrf_rram.
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
ArekBalysNordic authored and jukkar committed Dec 12, 2024
1 parent a97deec commit 3ba0b73
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/flash/soc_flash_nrf_rram.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ LOG_MODULE_REGISTER(flash_nrf_rram, CONFIG_FLASH_LOG_LEVEL);
#define WRITE_BLOCK_SIZE_FROM_DT DT_PROP(RRAM, write_block_size)
#define ERASE_VALUE 0xFF

#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER
#include <soc_secure.h>
#include <pm_config.h>
#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER */

#ifdef CONFIG_MULTITHREADING
static struct k_sem sem_lock;
#define SYNC_INIT() k_sem_init(&sem_lock, 1, 1)
Expand Down Expand Up @@ -279,6 +284,12 @@ static int nrf_rram_read(const struct device *dev, off_t addr, void *data, size_
}
addr += RRAM_START;

#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER && PM_APP_ADDRESS
if (addr < PM_APP_ADDRESS) {
return soc_secure_mem_read(data, (void *)addr, len);
}
#endif

memcpy(data, (void *)addr, len);

return 0;
Expand Down

0 comments on commit 3ba0b73

Please sign in to comment.