From 3ba0b73aefd7e573871d75a0ddb3dc021f0f4cb8 Mon Sep 17 00:00:00 2001 From: Arkadiusz Balys Date: Thu, 19 Sep 2024 13:02:57 +0200 Subject: [PATCH] [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 (cherry picked from commit 711346aa377a65263784cd0d37efc9230e68229b) --- drivers/flash/soc_flash_nrf_rram.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/flash/soc_flash_nrf_rram.c b/drivers/flash/soc_flash_nrf_rram.c index 35a6c98862c..b697df505b3 100644 --- a/drivers/flash/soc_flash_nrf_rram.c +++ b/drivers/flash/soc_flash_nrf_rram.c @@ -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 +#include +#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) @@ -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;