diff --git a/hal/nrf5340.c b/hal/nrf5340.c index 7dce15ad..f1772a4b 100644 --- a/hal/nrf5340.c +++ b/hal/nrf5340.c @@ -68,10 +68,11 @@ #define USE_IPC_RECV 0 #endif -/* SHM: Shared Memory between network and application cores */ -/* first 64KB (0x10000) is used by wolfBoot and limited in nrf5340.ld */ +/* SHM: Shared Memory between network and application cores. + * Reserve most of single-cycle RAM for wolfBoot; + * use end of RAM (0x3F800 - 0x7FFFF) as shared memory */ #ifndef SHARED_MEM_ADDR - #define SHARED_MEM_ADDR (0x20000000UL + (64 * 1024)) + #define SHARED_MEM_ADDR 0x2003F800 #endif /* Shared memory states (mask, easier to check) */ @@ -875,13 +876,21 @@ static void periph_unsecure() /* Unsecure RTC0 */ SPU_PERIPHID_PERM(RTC0_PERIPHID) &= ~SPU_PERIPHID_PERM_SECATTR; + + /* Unsecure QSPI */ + SPU_PERIPHID_PERM(QSPI_PERIPHID) &= ~SPU_PERIPHID_PERM_SECATTR; } #endif void hal_prepare_boot(void) { - /* Write protect bootloader region of flash */ + /* Write protect bootloader region of flash. + * Not needed in TrustZone configs because the application + * runs in non-secure mode and the bootloader partition is marked as + * secure. */ +#ifndef TZEN hal_flash_protect(WOLFBOOT_ORIGIN, BOOTLOADER_PARTITION_SIZE); +#endif if (enableShm) { #ifdef TARGET_nrf5340_net diff --git a/hal/nrf5340.h b/hal/nrf5340.h index d128ca9b..cc30b822 100644 --- a/hal/nrf5340.h +++ b/hal/nrf5340.h @@ -371,6 +371,8 @@ void uart_write_sz(const char* c, unsigned int sz); /* QSPI */ #ifdef TARGET_nrf5340_app + #define QSPI_PERIPHID 43 + #if TZ_SECURE() #define QSPI_BASE (0x5002B000) #else diff --git a/test-app/Makefile b/test-app/Makefile index 0a63829f..135dbfd5 100644 --- a/test-app/Makefile +++ b/test-app/Makefile @@ -306,7 +306,11 @@ ifeq ($(QSPI_FLASH),1) ifeq ($(ARCH),RENESAS_RX) APP_OBJS+=../hal/spi/spi_drv_renesas_rx.o else - APP_OBJS+=../hal/spi/spi_drv_$(SPI_TARGET).o + ifeq ($(TZEN),1) + APP_OBJS+=../hal/spi/spi_drv_$(SPI_TARGET)_ns.o + else + APP_OBJS+=../hal/spi/spi_drv_$(SPI_TARGET).o + endif endif endif @@ -596,6 +600,9 @@ delta-extra-data: image.bin ../hal/$(TARGET)_ns.o: ../hal/$(TARGET).c FORCE $(Q)$(CC) $(CFLAGS) -c -o $(@) ../hal/$(TARGET).c -DNONSECURE_APP +../hal/spi/spi_drv_$(SPI_TARGET)_ns.o: ../hal/spi/spi_drv_$(SPI_TARGET).c FORCE + $(Q)$(CC) $(CFLAGS) -c -o $(@) ../hal/spi/spi_drv_$(SPI_TARGET).c -DNONSECURE_APP + %.o:%.c @echo "\t[CC-$(ARCH)] $@" $(Q)$(CC) $(CFLAGS) -c $(OUTPUT_FLAG) $@ $^