Skip to content

Commit 9270211

Browse files
committed
Remove some debug stuff and fix secure fault triggers
1 parent f43b9eb commit 9270211

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

trustzone/hello_trustzone/nonsecure.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@ bool repeating_timer_callback(__unused struct repeating_timer *t) {
1111
}
1212

1313
int main() {
14-
// Check no user IRQs are available
15-
int irq = user_irq_claim_unused(false);
16-
if (irq != -1) {
17-
goto done;
18-
}
19-
// Request user IRQs from secure, which stdio_usb will use
14+
// Request user IRQ from secure, which stdio_usb will use
2015
user_irq_request_unused_from_secure(1);
2116

2217
stdio_usb_init();
@@ -25,19 +20,15 @@ int main() {
2520
struct repeating_timer timer;
2621
add_repeating_timer_ms(1000, repeating_timer_callback, NULL, &timer);
2722

28-
printf("My clock speed is %dHz\n", clock_get_hz(clk_sys));
29-
3023
for (int i=0; i < 10; i++) {
3124
printf("Hello, world, from non-secure!\n");
3225
rom_secure_call(1, 2, 3, i, SECURE_CALL_PRINT_VALUES);
3326
sleep_ms(1000);
3427
}
3528

36-
done:
29+
// Demonstrate triggering a secure fault, by reading secure memory at start of SRAM
3730
printf("Triggering secure fault by reading secure memory\n");
38-
// Secure memory is the rest of SRAM after the heap limit
39-
extern uint32_t __HeapLimit;
40-
volatile uint32_t thing = *(uint32_t*)__HeapLimit;
31+
volatile uint32_t thing = *(uint32_t*)SRAM_BASE;
4132
printf("Some secure memory is %08x\n", thing);
4233

4334
return 0;

trustzone/wifi_tls_verify/nonsecure.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,10 @@ int main() {
147147
printf("Test failed\n");
148148
}
149149

150-
done:
150+
done:
151151
printf("Triggering secure fault by reading secure memory\n");
152-
// Secure memory is the rest of SRAM after the heap limit
153-
extern uint32_t __HeapLimit;
154-
volatile uint32_t thing = *(uint32_t*)__HeapLimit;
152+
// Secure memory is the start of SRAM
153+
volatile uint32_t thing = *(uint32_t*)SRAM_BASE;
155154
printf("Some secure memory is %08x\n", thing);
156155

157156
return 0;

0 commit comments

Comments
 (0)