Skip to content

Commit 0c19ec7

Browse files
hakonfammbolivar-nordic
authored andcommitted
[nrf toup] drivers/flash: leverage nsc flash read
When current image is non-secure and address being read is configured as secure, use the Non Secure Callable function spm_request_read to try and read the secure flash area. Signed-off-by: Håkon Øye Amundsen <[email protected]> (cherry picked from commit 8fd3c78) Signed-off-by: Martí Bolívar <[email protected]>
1 parent f020faa commit 0c19ec7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/flash/soc_flash_nrf.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
#include <string.h>
1717
#include <nrfx_nvmc.h>
1818

19+
#if CONFIG_ARM_NONSECURE_FIRMWARE
20+
#include <secure_services.h>
21+
#include <pm_config.h>
22+
#endif
23+
1924
#if defined(CONFIG_SOC_FLASH_NRF_RADIO_SYNC)
2025
#include <sys/__assert.h>
2126
#include <bluetooth/hci.h>
@@ -141,6 +146,12 @@ static int flash_nrf_read(struct device *dev, off_t addr,
141146
return 0;
142147
}
143148

149+
#if CONFIG_ARM_NONSECURE_FIRMWARE
150+
if (addr < PM_APP_ADDRESS) {
151+
return spm_request_read(data, addr, len);
152+
}
153+
#endif
154+
144155
memcpy(data, (void *)addr, len);
145156

146157
return 0;

0 commit comments

Comments
 (0)