Skip to content

Commit 39cc1d4

Browse files
committed
Add support for the DISCO_F429ZI target
This commit includes: * Reduce stack and heap size for all boxes, where necessary and possible (printf used in threads is a constraint). * Use new Thread APIs. * Add ACLs and configurations for the DISCO_F429ZI target.
1 parent a2c37ad commit 39cc1d4

File tree

5 files changed

+45
-15
lines changed

5 files changed

+45
-15
lines changed

source/led1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static void led1_main(const void *)
3131
SecureAllocator alloc = secure_allocator_create_with_pages(4 * kB, 1 * kB);
3232

3333
while (1) {
34-
static const size_t size = 500;
34+
static const size_t size = 50;
3535
uint16_t seed = (size << 8) | (uvisor_ctx->heartbeat & 0xFF);
3636

3737
led1 = !led1;

source/led2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static void led2_main(const void *);
1818
* We do not need large stacks in either the main nor the interrupt thread, as
1919
* we do not do anything special in them. */
2020
UVISOR_BOX_NAMESPACE(NULL);
21-
UVISOR_BOX_HEAPSIZE(8 * 1024);
21+
UVISOR_BOX_HEAPSIZE(3 * 1024);
2222
UVISOR_BOX_MAIN(led2_main, osPriorityNormal, 512);
2323
UVISOR_BOX_CONFIG(box_led2, acl, 512, box_context);
2424

@@ -47,7 +47,7 @@ static void led2_main(const void *)
4747
secure_allocator_destroy(alloc2);
4848

4949
while (1) {
50-
static const size_t size = 300;
50+
static const size_t size = 30;
5151
uint16_t seed = (size << 8) | (uvisor_ctx->heartbeat & 0xFF);
5252

5353
led2 = !led2;

source/led3.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static void led3_main(const void *);
1818
* We need at least 1kB in the main thread as we use printf in it. The interrupt
1919
* stack size can be smaller as we do not do anything special in them. */
2020
UVISOR_BOX_NAMESPACE(NULL);
21-
UVISOR_BOX_HEAPSIZE(8 * 1024);
21+
UVISOR_BOX_HEAPSIZE(3 * 1024);
2222
UVISOR_BOX_MAIN(led3_main, osPriorityNormal, 1024);
2323
UVISOR_BOX_CONFIG(box_led3, acl, 512, box_context);
2424

@@ -59,7 +59,7 @@ static void led3_main(const void *)
5959
SecureAllocator alloc = secure_allocator_create_with_pages(4 * kB, 1 * kB);
6060
/* Prepare the thread definition structure. */
6161
osThreadDef_t thread_def;
62-
thread_def.stacksize = DEFAULT_STACK_SIZE;
62+
thread_def.stacksize = 512;
6363
/* Allocate the stack inside the page allocator! */
6464
thread_def.stack_pointer = (uint32_t *) secure_malloc(alloc, DEFAULT_STACK_SIZE);
6565
thread_def.tpriority = osPriorityNormal;

source/main-hw.h

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,15 @@
1717
#ifndef __UVISOR_HELLOWORLD_MAIN_HW_H__
1818
#define __UVISOR_HELLOWORLD_MAIN_HW_H__
1919

20-
/* The vector containing the challenge is shared with the push-button ISR, so
21-
* that it can attempt to access it from an IRQ context. */
2220

23-
#define LED_ON true
24-
#define LED_OFF false
21+
#if defined(TARGET_K64F)
2522

26-
#define MAIN_LED LED_BLUE
27-
#define HALT_LED LED_RED
28-
29-
#define MAIN_BTN SW2
30-
#define MAIN_BTN_PUPD PullUp
23+
#define MAIN_LED LED1
24+
#define SECURE_LED LED2
25+
#define LED_ON false
26+
#define LED_OFF true
27+
#define SECURE_SWITCH SW2
28+
#define SECURE_SWITCH_PULL PullUp
3129

3230
#define MAIN_ACL(acl_list_name) \
3331
static const UvisorBoxAclItem acl_list_name[] = { \
@@ -48,4 +46,36 @@
4846
{SPI0, sizeof(*SPI0), UVISOR_TACLDEF_PERIPH}, \
4947
}
5048

49+
#elif defined(TARGET_DISCO_F429ZI)
50+
51+
#define MAIN_LED LED1
52+
#define SECURE_LED LED2
53+
#define LED_ON false
54+
#define LED_OFF true
55+
#define SECURE_SWITCH USER_BUTTON
56+
#define SECURE_SWITCH_PULL PullDown
57+
58+
#define MAIN_ACL(acl_list_name) \
59+
static const UvisorBoxAclItem acl_list_name[] = { \
60+
{GPIOA, sizeof(*GPIOA), UVISOR_TACLDEF_PERIPH}, \
61+
{GPIOB, sizeof(*GPIOB), UVISOR_TACLDEF_PERIPH}, \
62+
{GPIOC, sizeof(*GPIOC), UVISOR_TACLDEF_PERIPH}, \
63+
{GPIOD, sizeof(*GPIOD), UVISOR_TACLDEF_PERIPH}, \
64+
{GPIOE, sizeof(*GPIOE), UVISOR_TACLDEF_PERIPH}, \
65+
{RTC, sizeof(*RTC), UVISOR_TACLDEF_PERIPH}, \
66+
{TIM5, sizeof(*TIM5), UVISOR_TACLDEF_PERIPH}, \
67+
{USART1, sizeof(*USART1), UVISOR_TACLDEF_PERIPH}, \
68+
{I2C1, sizeof(*I2C1), UVISOR_TACLDEF_PERIPH}, \
69+
{SPI1, sizeof(*SPI1), UVISOR_TACLDEF_PERIPH}, \
70+
{RCC, sizeof(*RCC), UVISOR_TACLDEF_PERIPH}, \
71+
{FLASH, sizeof(*FLASH), UVISOR_TACLDEF_PERIPH}, \
72+
{PWR, sizeof(*PWR), UVISOR_TACLDEF_PERIPH}, \
73+
{EXTI, sizeof(*EXTI), UVISOR_TACLDEF_PERIPH}, \
74+
{GPIOG, sizeof(*GPIOG), UVISOR_TACLDEF_PERIPH}, \
75+
{SYSCFG, sizeof(*SYSCFG), UVISOR_TACLDEF_PERIPH}, \
76+
{(void *) 0x42000000, 0x01000000, UVISOR_TACLDEF_PERIPH}, /* FIXME */ \
77+
}
78+
79+
#endif /* Target-specific settings */
80+
5181
#endif /* __UVISOR_HELLOWORLD_MAIN_HW_H__ */

source/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static void main_alloc(void)
3434
SecureAllocator alloc = secure_allocator_create_with_pages(4 * kB, 1 * kB);
3535

3636
while (1) {
37-
alloc_fill_wait_verify_free(500, seed, 577);
37+
alloc_fill_wait_verify_free(50, seed, 577);
3838
specific_alloc_fill_wait_verify_free(alloc, 5 * kB, seed, 97);
3939
seed++;
4040
}

0 commit comments

Comments
 (0)