Skip to content

Commit b8f70ad

Browse files
committed
Various small fixes for nrf5340 TrustZone PKCS11
1 parent 2fc6fe8 commit b8f70ad

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

hal/nrf5340.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@
6868
#define USE_IPC_RECV 0
6969
#endif
7070

71-
/* SHM: Shared Memory between network and application cores */
72-
/* first 64KB (0x10000) is used by wolfBoot and limited in nrf5340.ld */
71+
/* SHM: Shared Memory between network and application cores.
72+
* Reserve most of single-cycle RAM for wolfBoot;
73+
* use end of RAM (0x3F800 - 0x7FFFF) as shared memory */
7374
#ifndef SHARED_MEM_ADDR
74-
#define SHARED_MEM_ADDR (0x20000000UL + (64 * 1024))
75+
#define SHARED_MEM_ADDR 0x2003F800
7576
#endif
7677

7778
/* Shared memory states (mask, easier to check) */
@@ -875,13 +876,21 @@ static void periph_unsecure()
875876

876877
/* Unsecure RTC0 */
877878
SPU_PERIPHID_PERM(RTC0_PERIPHID) &= ~SPU_PERIPHID_PERM_SECATTR;
879+
880+
/* Unsecure QSPI */
881+
SPU_PERIPHID_PERM(QSPI_PERIPHID) &= ~SPU_PERIPHID_PERM_SECATTR;
878882
}
879883
#endif
880884

881885
void hal_prepare_boot(void)
882886
{
883-
/* Write protect bootloader region of flash */
887+
/* Write protect bootloader region of flash.
888+
* Not needed in TrustZone configs because the application
889+
* runs in non-secure mode and the bootloader partition is marked as
890+
* secure. */
891+
#ifndef TZEN
884892
hal_flash_protect(WOLFBOOT_ORIGIN, BOOTLOADER_PARTITION_SIZE);
893+
#endif
885894

886895
if (enableShm) {
887896
#ifdef TARGET_nrf5340_net

hal/nrf5340.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,8 @@ void uart_write_sz(const char* c, unsigned int sz);
371371

372372
/* QSPI */
373373
#ifdef TARGET_nrf5340_app
374+
#define QSPI_PERIPHID 43
375+
374376
#if TZ_SECURE()
375377
#define QSPI_BASE (0x5002B000)
376378
#else

test-app/Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,11 @@ ifeq ($(QSPI_FLASH),1)
306306
ifeq ($(ARCH),RENESAS_RX)
307307
APP_OBJS+=../hal/spi/spi_drv_renesas_rx.o
308308
else
309-
APP_OBJS+=../hal/spi/spi_drv_$(SPI_TARGET).o
309+
ifeq ($(TZEN),1)
310+
APP_OBJS+=../hal/spi/spi_drv_$(SPI_TARGET)_ns.o
311+
else
312+
APP_OBJS+=../hal/spi/spi_drv_$(SPI_TARGET).o
313+
endif
310314
endif
311315
endif
312316

@@ -596,6 +600,9 @@ delta-extra-data: image.bin
596600
../hal/$(TARGET)_ns.o: ../hal/$(TARGET).c FORCE
597601
$(Q)$(CC) $(CFLAGS) -c -o $(@) ../hal/$(TARGET).c -DNONSECURE_APP
598602

603+
../hal/spi/spi_drv_$(SPI_TARGET)_ns.o: ../hal/spi/spi_drv_$(SPI_TARGET).c FORCE
604+
$(Q)$(CC) $(CFLAGS) -c -o $(@) ../hal/spi/spi_drv_$(SPI_TARGET).c -DNONSECURE_APP
605+
599606
%.o:%.c
600607
@echo "\t[CC-$(ARCH)] $@"
601608
$(Q)$(CC) $(CFLAGS) -c $(OUTPUT_FLAG) $@ $^

0 commit comments

Comments
 (0)