Skip to content

Commit 27b89f0

Browse files
twcook86danielinux
authored andcommitted
Add trustzone example, rework a few things for tz support.
1 parent 9078ede commit 27b89f0

8 files changed

Lines changed: 251 additions & 52 deletions

File tree

config/examples/lpc55s69-tz.config

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
ARCH?=ARM
2+
TZEN?=1
3+
TARGET?=lpc55s69
4+
SIGN?=ECC384
5+
HASH?=SHA384
6+
MCUXSDK?=1
7+
MCUXPRESSO?=$(PWD)/../NXP/mcuxpresso-sdk/mcuxsdk
8+
MCUXPRESSO_CMSIS?=$(PWD)/../NXP/CMSIS_5/CMSIS
9+
MCUXPRESSO_CPU?=LPC55S69JBD100_cm33_core0
10+
MCUXPRESSO_DRIVERS?=$(MCUXPRESSO)/devices/LPC/LPC5500/LPC55S69
11+
MCUXPRESSO_PROJECT_TEMPLATE?=$(MCUXPRESSO)/examples/_boards/lpcxpresso55s69/project_template
12+
DEBUG?=0
13+
DEBUG_UART?=1
14+
VTOR?=1
15+
CORTEX_M0?=0
16+
CORTEX_M33?=1
17+
NO_ASM?=0
18+
NO_MPU=1
19+
EXT_FLASH?=0
20+
SPI_FLASH?=0
21+
ALLOW_DOWNGRADE?=0
22+
NVM_FLASH_WRITEONCE?=1
23+
NO_ARM_ASM=1
24+
WOLFBOOT_VERSION?=0
25+
V?=0
26+
SPMATH?=1
27+
RAM_CODE?=1
28+
DUALBANK_SWAP?=0
29+
PKA?=1
30+
FLASH_MULTI_SECTOR_ERASE?=1
31+
NO_DIRECT_READ_OF_ERASED_SECTOR?=1
32+
WOLFCRYPT_TZ?=1
33+
WOLFCRYPT_TZ_PKCS11?=1
34+
35+
# 512-byte pages erasable/writeable
36+
WOLFBOOT_SECTOR_SIZE?=0x200
37+
38+
# 200KB boot, 80KB keyvault, 8KB NSC, 56KB partitions, 512 swap
39+
WOLFBOOT_KEYVAULT_ADDRESS?=0x10032000
40+
WOLFBOOT_KEYVAULT_SIZE?=0x14000
41+
WOLFBOOT_NSC_ADDRESS?=0x10046000
42+
WOLFBOOT_NSC_SIZE?=0x2000
43+
WOLFBOOT_PARTITION_SIZE?=0xE000
44+
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x00048000
45+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x00056000
46+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x00064000

config/examples/lpc55s69.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ NO_DIRECT_READ_OF_ERASED_SECTOR?=1
3434
WOLFBOOT_SECTOR_SIZE?=0x200
3535

3636
# Default configuration
37-
# 32KB boot, 48KB partitions, 512 swap
37+
# 40KB boot, 44KB partitions, 512 swap
3838
WOLFBOOT_PARTITION_SIZE?=0xB000
3939
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0xA000
4040
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x15000

hal/lpc55s69-ns.ld

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
MEMORY
22
{
3-
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = @WOLFBOOT_PARTITION_BOOT_ADDRESS@
4-
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 256K
3+
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = @BOOTLOADER_PARTITION_SIZE@
4+
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K
55
}
66

77
SECTIONS

hal/lpc55s69.c

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ static void hal_sau_init(void)
4848
sau_init_region(0, WOLFBOOT_NSC_ADDRESS,
4949
WOLFBOOT_NSC_ADDRESS + WOLFBOOT_NSC_SIZE - 1, 1);
5050

51-
/* Non-secure: application flash area (boot partition) */
51+
/* Non-secure: application flash area (boot+update partition) */
5252
sau_init_region(1, WOLFBOOT_PARTITION_BOOT_ADDRESS,
53-
WOLFBOOT_PARTITION_BOOT_ADDRESS + WOLFBOOT_PARTITION_SIZE - 1,
53+
WOLFBOOT_PARTITION_BOOT_ADDRESS + (WOLFBOOT_PARTITION_SIZE * 2) - 1,
5454
0);
5555

5656
/* Non-secure RAM */
57-
sau_init_region(2, 0x20020000, 0x20025FFF, 0);
57+
sau_init_region(2, 0x20020000, 0x20027FFF, 0);
5858

5959
/* Peripherals */
60-
sau_init_region(3, 0x40000000, 0x4005FFFF, 0);
61-
sau_init_region(4, 0x40080000, 0x400DFFFF, 0);
62-
sau_init_region(5, 0x40100000, 0x4013FFFF, 0);
60+
sau_init_region(3, 0x40000000, 0x4003FFFF, 0);
61+
sau_init_region(4, 0x40080000, 0x400AFFFF, 0);
62+
sau_init_region(5, 0x40100000, 0x4010FFFF, 0);
6363

6464
/* Enable SAU */
6565
SAU_CTRL = SAU_INIT_CTRL_ENABLE;
@@ -70,13 +70,8 @@ static void hal_sau_init(void)
7070

7171
static void periph_unsecure(void)
7272
{
73-
// CLOCK_EnableClock(kCLOCK_Gpio0);
74-
// CLOCK_EnableClock(kCLOCK_Gpio1);
75-
// CLOCK_EnableClock(kCLOCK_Port0);
76-
// CLOCK_EnableClock(kCLOCK_Port1);
77-
78-
// GPIO_EnablePinControlNonSecure(GPIO0, (1UL << 10) | (1UL << 27));
79-
// GPIO_EnablePinControlNonSecure(GPIO1, (1UL << 2) | (1UL << 8) | (1UL << 9));
73+
CLOCK_EnableClock(kCLOCK_Iocon);
74+
CLOCK_EnableClock(kCLOCK_Gpio1);
8075
}
8176
#endif
8277

@@ -96,8 +91,6 @@ void hal_init(void)
9691
#if defined(__WOLFBOOT) || !defined(TZEN)
9792
memset(&pflash, 0, sizeof(pflash));
9893
FLASH_Init(&pflash);
99-
// FLASH_GetProperty(&pflash, kFLASH_PropertyPflashSectorSize,
100-
// &pflash_sector_size);
10194
#endif
10295

10396
#if defined(TZEN) && !defined(NONSECURE_APP)
@@ -153,8 +146,7 @@ int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
153146
address % pflash_page_size == 0 &&
154147
len % pflash_page_size == 0 &&
155148
FLASH_Erase(&pflash, address, len, kFLASH_ApiEraseKey)
156-
== kStatus_FLASH_Success &&
157-
FLASH_VerifyErase(&pflash, address, len) == kStatus_FLASH_Success
149+
== kStatus_FLASH_Success
158150
)
159151
{
160152
return 0;

hal/lpc55s69.ld

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
MEMORY
2+
{
3+
FLASH (rx) : ORIGIN = 0x10000000, LENGTH = @WOLFBOOT_KEYVAULT_ADDRESS@ - @ARCH_FLASH_OFFSET@
4+
RAM (rwx) : ORIGIN = 0x30000000, LENGTH = 0x10000 /* 64K */
5+
RAM_HEAP (rwx) : ORIGIN = 0x30010000, LENGTH = 0xC000 /* 48K */
6+
RAM_KV (rwx) : ORIGIN = 0x3001C000, LENGTH = 0x2000 /* 8K */
7+
FLASH_KEYVAULT (rw) : ORIGIN = @WOLFBOOT_KEYVAULT_ADDRESS@, LENGTH = @WOLFBOOT_KEYVAULT_SIZE@
8+
FLASH_NSC (rx) : ORIGIN = @WOLFBOOT_NSC_ADDRESS@, LENGTH = @WOLFBOOT_NSC_SIZE@
9+
}
10+
11+
SECTIONS
12+
{
13+
14+
.text :
15+
{
16+
_start_text = .;
17+
KEEP(*(.isr_vector))
18+
. = 0x200;
19+
*(.keystore*)
20+
*(.text*)
21+
*(.rodata*)
22+
*(.init*)
23+
*(.fini*)
24+
. = ALIGN(4);
25+
_end_text = .;
26+
} > FLASH
27+
28+
.edidx :
29+
{
30+
. = ALIGN(4);
31+
*(.ARM.exidx*)
32+
} > FLASH
33+
34+
.gnu.sgstubs :
35+
{
36+
. += 0x400;
37+
. = ALIGN(4);
38+
*(.gnu.sgstubs*) /* Secure Gateway Stubs */
39+
. = ALIGN(4);
40+
} > FLASH_NSC
41+
42+
_stored_data = .;
43+
44+
.data : AT (_stored_data)
45+
{
46+
_start_data = .;
47+
KEEP(*(.data*))
48+
. = ALIGN(4);
49+
_end_data = .;
50+
} > RAM
51+
52+
.bss (NOLOAD) :
53+
{
54+
_start_bss = .;
55+
__bss_start__ = .;
56+
*(.bss*)
57+
*(COMMON)
58+
. = ALIGN(4);
59+
_end_bss = .;
60+
__bss_end__ = .;
61+
_end = .;
62+
} > RAM
63+
. = ALIGN(4);
64+
}
65+
66+
END_STACK = ORIGIN(RAM) + LENGTH(RAM);
67+
68+
_keyvault_origin = ORIGIN(RAM_KV);
69+
_keyvault_size = LENGTH(RAM_KV);
70+
71+
_flash_keyvault = ORIGIN(FLASH_KEYVAULT);
72+
_flash_keyvault_size = LENGTH(FLASH_KEYVAULT);
73+
74+
_start_heap = ORIGIN(RAM_HEAP);
75+
_heap_size = LENGTH(RAM_HEAP);

test-app/ARM-lpc55s69-ns.ld

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
MEMORY
2+
{
3+
FLASH (rx) : ORIGIN = @WOLFBOOT_TEST_APP_ADDRESS@, LENGTH = @WOLFBOOT_TEST_APP_SIZE@
4+
RAM (rwx) : ORIGIN = 0x20020000, LENGTH = 32K
5+
}
6+
7+
SECTIONS
8+
{
9+
.text :
10+
{
11+
_start_text = .;
12+
KEEP(*(.isr_vector))
13+
*(.init)
14+
*(.fini)
15+
*(.text*)
16+
KEEP(*(.rodata*))
17+
. = ALIGN(4);
18+
_end_text = .;
19+
} > FLASH
20+
21+
.ARM :
22+
{
23+
__exidx_start = .;
24+
*(.ARM.exidx*)
25+
__exidx_end = .;
26+
} > FLASH
27+
28+
_stored_data = .;
29+
30+
.data : AT (_stored_data)
31+
{
32+
_start_data = .;
33+
KEEP(*(.data*))
34+
. = ALIGN(4);
35+
KEEP(*(.ramcode))
36+
. = ALIGN(4);
37+
_end_data = .;
38+
} > RAM
39+
40+
.bss :
41+
{
42+
_start_bss = .;
43+
*(.bss*)
44+
*(COMMON)
45+
. = ALIGN(4);
46+
_end_bss = .;
47+
_end = .;
48+
} > RAM
49+
}
50+
51+
_wolfboot_partition_boot_address = @WOLFBOOT_PARTITION_BOOT_ADDRESS@;
52+
_wolfboot_partition_size = @WOLFBOOT_PARTITION_SIZE@;
53+
_wolfboot_partition_update_address = @WOLFBOOT_PARTITION_UPDATE_ADDRESS@;
54+
_wolfboot_partition_swap_address = @WOLFBOOT_PARTITION_SWAP_ADDRESS@;
55+
56+
PROVIDE(_start_heap = _end);
57+
PROVIDE(end = _end);
58+
PROVIDE(_end_stack = ORIGIN(RAM) + LENGTH(RAM));

test-app/ARM-lpc55s69.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
MEMORY
22
{
33
FLASH (rx) : ORIGIN = @WOLFBOOT_TEST_APP_ADDRESS@, LENGTH = @WOLFBOOT_TEST_APP_SIZE@
4-
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 256K
4+
RAM (rwx) : ORIGIN = 0x20020000, LENGTH = 32K
55
}
66

77
SECTIONS

0 commit comments

Comments
 (0)