Skip to content

Commit f7d5260

Browse files
dgarskedanielinux
authored andcommitted
Fixes to resolve STM32H5 TrustZone example. Thank you @danielinux
1 parent 5d27ada commit f7d5260

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

hal/stm32_tz.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ void hal_tz_sau_init(void)
291291
/* SAU is set up before staging. Set up all areas as secure. */
292292

293293
/* Non-secure callable: NSC functions area */
294-
sau_init_region(0, 0x0C038000, 0x0C040000, 1);
294+
sau_init_region(0, 0x0C040000, 0x0C05FFFF, 1);
295295

296296
/* Secure: application flash area (first bank) */
297297
sau_init_region(1, WOLFBOOT_PARTITION_BOOT_ADDRESS, FLASH_BANK2_BASE - 1, 0);

hal/stm32h5.ld

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
MEMORY
22
{
33
/* If FLASH_KEYVAULT or FLASH_NSC length is adjusted FLASH length needs adjusted too */
4-
FLASH (rx) : ORIGIN = @WOLFBOOT_ORIGIN@, LENGTH = @BOOTLOADER_PARTITION_SIZE@ - 0x1E000 - 0x2000
4+
FLASH (rx) : ORIGIN = @WOLFBOOT_ORIGIN@, LENGTH = @BOOTLOADER_PARTITION_SIZE@ - 0x20000
55
RAM (rwx) : ORIGIN = 0x30000000, LENGTH = 0x20000
66
RAM_KV (rw): ORIGIN = 0x30020000, LENGTH = 0x10000
77
RAM_HEAP (rw): ORIGIN = 0x30030000, LENGTH = 0x10000 /* 64KB Heap for wolfcrypt/PKCS11 */
8-
FLASH_KEYVAULT(rw): ORIGIN = @WOLFBOOT_ORIGIN@ + LENGTH(FLASH), LENGTH = 0x1E000
9-
FLASH_NSC(rx): ORIGIN = @WOLFBOOT_ORIGIN@ + LENGTH(FLASH) + LENGTH(FLASH_KEYVAULT), LENGTH = 0x2000
8+
FLASH_KEYVAULT(rw): ORIGIN = @WOLFBOOT_ORIGIN@ + LENGTH(FLASH), LENGTH = 0x1C000
9+
FLASH_NSC(rx): ORIGIN = @WOLFBOOT_ORIGIN@ + LENGTH(FLASH) + LENGTH(FLASH_KEYVAULT), LENGTH = 0x4000
1010
}
1111

1212
SECTIONS

src/pkcs11_store.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@
6060
extern uint32_t _flash_keyvault;
6161
extern uint32_t _flash_keyvault_size;
6262

63-
static uint8_t *vault_base = (uint8_t*)&_flash_keyvault;
64-
static uint32_t vault_size = (uint32_t)&_flash_keyvault_size;
63+
#define vault_base ((uint8_t*)&_flash_keyvault)
64+
#define vault_size ((uint32_t)&_flash_keyvault_size)
65+
6566

6667
/* Back-end for malloc, used by wolfPKCS11 */
6768
extern unsigned int _start_heap; /* From linker script: heap memory */

test-app/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
TARGET?=none
77
ARCH?=ARM
88
MCUXPRESSO_CMSIS?=$(MCUXPRESSO)/CMSIS
9-
CFLAGS+=-I. -I..
109
ifeq ($(TZEN),1)
1110
# wcs directory contains a user_settings.h, which will conflict with
1211
# the one in the include directory if the test app needs it (e.g. wolfHSM)
1312
CFLAGS+=-I./wcs
1413
endif
14+
CFLAGS+=-I. -I..
1515
DEBUG?=1
1616
DELTA_DATA_SIZE?=2000
1717
USE_GCC?=1

test-app/wcs/user_settings.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,13 @@ extern int tolower(int c);
136136
#define BENCH_EMBEDDED
137137

138138
#ifdef SECURE_PKCS11
139-
#define CUSTOM_RAND_GENERATE_BLOCK wcs_get_random
139+
140+
static inline int wcs_cmse_get_random(unsigned char* output, int sz)
141+
{
142+
return wcs_get_random(output, sz);
143+
}
144+
145+
#define CUSTOM_RAND_GENERATE_BLOCK wcs_cmse_get_random
140146
#endif
141147

142148
/* Disable VLAs */

0 commit comments

Comments
 (0)