Skip to content

Commit 9e1c709

Browse files
committed
Add hello_trustzone_no_flash example
1 parent baec217 commit 9e1c709

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

trustzone/hello_trustzone/CMakeLists.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,42 @@ pico_set_security_ram_split(hello_trustzone_s hello_trustzone_ns SIMPLE 64k 2k)
3131

3232
# Create combined UF2 (ns first)
3333
pico_concatenate_uf2_outputs(hello_trustzone hello_trustzone_ns hello_trustzone_s)
34+
35+
36+
37+
# no_flash example
38+
# Add secure executable
39+
add_executable(hello_trustzone_no_flash_s secure.c)
40+
target_link_libraries(hello_trustzone_no_flash_s
41+
pico_stdlib
42+
hardware_watchdog
43+
pico_secure
44+
)
45+
46+
pico_set_binary_type(hello_trustzone_no_flash_s no_flash)
47+
pico_add_extra_outputs(hello_trustzone_no_flash_s)
48+
49+
# Add non-secure executable
50+
add_executable(hello_trustzone_no_flash_ns nonsecure.c)
51+
pico_set_uf2_family(hello_trustzone_no_flash_ns "rp2350-arm-ns")
52+
target_link_libraries(hello_trustzone_no_flash_ns
53+
pico_stdlib
54+
)
55+
pico_enable_stdio_uart(hello_trustzone_no_flash_ns 0)
56+
pico_enable_stdio_usb(hello_trustzone_no_flash_ns 1)
57+
58+
pico_set_binary_type(hello_trustzone_no_flash_ns no_flash)
59+
pico_add_extra_outputs(hello_trustzone_no_flash_ns)
60+
61+
# Set security options
62+
pico_set_security_options(hello_trustzone_no_flash_s hello_trustzone_no_flash_ns
63+
USER_IRQ USB
64+
NONSECURE_TIMER 1
65+
)
66+
67+
# Set security ram split (with NO_FLASH)
68+
pico_set_security_ram_split(hello_trustzone_no_flash_s hello_trustzone_no_flash_ns SIMPLE 64k 2k NO_FLASH)
69+
70+
# Create combined CMake target
71+
add_custom_target(hello_trustzone_no_flash ALL
72+
DEPENDS hello_trustzone_no_flash_s hello_trustzone_no_flash_ns)

trustzone/hello_trustzone/secure.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ int main()
5454
// Create user callback
5555
rom_secure_call_add_user_callback(secure_call_user_callback, SECURE_CALL_CALLBACKS_MASK);
5656

57+
#if !PICO_SECURITY_SPLIT_NO_FLASH
5758
// Get boot partition
5859
boot_info_t info;
5960
rom_get_boot_info(&info);
@@ -64,6 +65,7 @@ int main()
6465
printf("Matching Non-Secure partition: %d\n", ns_partition);
6566
int rc = rom_roll_qmi_to_partition(ns_partition);
6667
printf("Rolled QMI to Non-Secure partition, rc=%d\n", rc);
68+
#endif
6769

6870
// Configure SAU regions
6971
secure_sau_configure_split();

0 commit comments

Comments
 (0)