Skip to content

Commit 979b9f9

Browse files
authored
Merge pull request #52 from AlessandroA/stm32f4_support_rebased
Add support for the STM32F429ZI target
2 parents 31b96d2 + 8bd29b6 commit 979b9f9

File tree

8 files changed

+56
-25
lines changed

8 files changed

+56
-25
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ This is a simple example to show how to write a uVisor-secured threaded applicat
44

55
Supported devices:
66

7-
| Target | Toolchain | Baud rate |
8-
|--------|-----------|-----------|
9-
| `K64F` | `GCC_ARM` | 9600 |
7+
| Target | Toolchain | Baud rate |
8+
|-------------------|-----------|-----------|
9+
| `K64F` | `GCC_ARM` | 9600 |
10+
| `DISCO_F429ZI` | `GCC_ARM` | 9600 |
11+
| `EFM32GG_STK3700` | `GCC_ARM` | 9600 |
1012

1113
Latest release: [mbed-os-5.4.x](https://github.com/ARMmbed/mbed-os-example-uvisor/releases/latest). Tested with [mbed-cli v1.0.0](https://github.com/ARMmbed/mbed-cli/releases/tag/1.0.0).
1214

mbed-os.lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://github.com/ARMmbed/mbed-os/#fc1836545dcc2fc86f03b01292b62bf2089f67c3
1+
https://github.com/ARMmbed/mbed-os/#92fbf2a9b3988d430482fc25a6077f2462e2a634

source/led1.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static void led1_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(3 * 1024);
21+
UVISOR_BOX_HEAPSIZE(2 * 1024);
2222
UVISOR_BOX_MAIN(led1_main, osPriorityNormal, 512);
2323
UVISOR_BOX_CONFIG(box_led1, acl, 512, box_context);
2424

@@ -39,6 +39,6 @@ static void led1_main(const void *)
3939
led1 = !led1;
4040
++uvisor_ctx->heartbeat;
4141
alloc_fill_wait_verify_free(size, seed, 211);
42-
specific_alloc_fill_wait_verify_free(alloc, 5 * kB, seed, 107);
42+
specific_alloc_fill_wait_verify_free(alloc, 1 * kB, seed, 107);
4343
}
4444
}

source/led2.cpp

Lines changed: 6 additions & 6 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(3 * 1024);
21+
UVISOR_BOX_HEAPSIZE(2 * 1024);
2222
UVISOR_BOX_MAIN(led2_main, osPriorityNormal, 512);
2323
UVISOR_BOX_CONFIG(box_led2, acl, 512, box_context);
2424

@@ -38,13 +38,13 @@ static void led2_main(const void *)
3838
* page heap!
3939
*/
4040
/* Allocate one page. */
41-
alloc = secure_allocator_create_with_pages(4 * kB, 1 * kB);
41+
alloc = secure_allocator_create_with_pages(2 * kB, 1 * kB);
4242
/* Allocate another page. */
43-
SecureAllocator alloc2 = secure_allocator_create_with_pages(4 * kB, 1 * kB);
43+
SecureAllocator alloc2 = secure_allocator_create_with_pages(8 * kB, 1 * kB);
4444
/* Deallocate alloc1 page, creating a hole. */
4545
secure_allocator_destroy(alloc);
4646
/* Allocate two pages. */
47-
alloc = secure_allocator_create_with_pages(uvisor_get_page_size() + 3 * kB, 6 * kB);
47+
alloc = secure_allocator_create_with_pages(4 * kB, 1 * kB);
4848
/* Deallocate alloc2 page, creating another hole. */
4949
secure_allocator_destroy(alloc2);
5050

@@ -57,9 +57,9 @@ static void led2_main(const void *)
5757
alloc_fill_wait_verify_free(size, seed, 311);
5858

5959
/* Allocate in first page */
60-
specific_alloc_fill_wait_verify_free(alloc, 6 * kB, seed, 0);
60+
specific_alloc_fill_wait_verify_free(alloc, 1 * kB, seed, 0);
6161

6262
/* Allocate in second page */
63-
specific_alloc_fill_wait_verify_free(alloc, 6 * kB, seed, 101);
63+
specific_alloc_fill_wait_verify_free(alloc, 1 * kB, seed, 101);
6464
}
6565
}

source/led3.cpp

Lines changed: 1 addition & 8 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(3 * 1024);
21+
UVISOR_BOX_HEAPSIZE(2 * 1024);
2222
UVISOR_BOX_MAIN(led3_main, osPriorityNormal, 1024);
2323
UVISOR_BOX_CONFIG(box_led3, acl, 512, box_context);
2424

@@ -59,13 +59,6 @@ static void led3_main(const void *)
5959
uvisor_error(USER_NOT_ALLOWED);
6060
}
6161

62-
Thread thread2(osPriorityNormal, 512, NULL);
63-
status = thread2.start(run_3);
64-
if (status != osOK) {
65-
printf("Could not start box_led3 thread2.\r\n");
66-
uvisor_error(USER_NOT_ALLOWED);
67-
}
68-
6962
/* Create page-backed allocator. */
7063
const uint32_t kB = 1024;
7164
SecureAllocator alloc = secure_allocator_create_with_pages(4 * kB, 1 * kB);

source/main-hw.h

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@
4545
{SPI0, sizeof(*SPI0), UVISOR_TACLDEF_PERIPH}, \
4646
}
4747

48-
#elif defined (TARGET_EFM32GG_STK3700)
48+
#elif defined(TARGET_EFM32GG_STK3700)
4949

5050
#define MAIN_LED LED1
5151
#define SECURE_LED LED2
5252
#define LED_ON true
5353
#define LED_OFF false
54-
#define SECURE_SWITCH SW2
54+
#define SECURE_SWITCH SW0
5555
#define SECURE_SWITCH_PULL PullUp
5656

5757
#define MAIN_ACL(acl_list_name) \
@@ -65,6 +65,36 @@
6565
{(void *) 0x42000000, 0x2000000, UVISOR_TACLDEF_PERIPH}, \
6666
}
6767

68+
#elif defined(TARGET_DISCO_F429ZI)
69+
70+
#define MAIN_LED LED1
71+
#define SECURE_LED LED2
72+
#define LED_ON true
73+
#define LED_OFF false
74+
#define SECURE_SWITCH USER_BUTTON
75+
#define SECURE_SWITCH_PULL PullDown
76+
77+
#define MAIN_ACL(acl_list_name) \
78+
static const UvisorBoxAclItem acl_list_name[] = { \
79+
{GPIOA, sizeof(*GPIOA), UVISOR_TACLDEF_PERIPH}, \
80+
{GPIOB, sizeof(*GPIOB), UVISOR_TACLDEF_PERIPH}, \
81+
{GPIOC, sizeof(*GPIOC), UVISOR_TACLDEF_PERIPH}, \
82+
{GPIOD, sizeof(*GPIOD), UVISOR_TACLDEF_PERIPH}, \
83+
{GPIOE, sizeof(*GPIOE), UVISOR_TACLDEF_PERIPH}, \
84+
{RTC, sizeof(*RTC), UVISOR_TACLDEF_PERIPH}, \
85+
{TIM5, sizeof(*TIM5), UVISOR_TACLDEF_PERIPH}, \
86+
{USART1, sizeof(*USART1), UVISOR_TACLDEF_PERIPH}, \
87+
{I2C1, sizeof(*I2C1), UVISOR_TACLDEF_PERIPH}, \
88+
{SPI1, sizeof(*SPI1), UVISOR_TACLDEF_PERIPH}, \
89+
{RCC, sizeof(*RCC), UVISOR_TACLDEF_PERIPH}, \
90+
{FLASH, sizeof(*FLASH), UVISOR_TACLDEF_PERIPH}, \
91+
{PWR, sizeof(*PWR), UVISOR_TACLDEF_PERIPH}, \
92+
{EXTI, sizeof(*EXTI), UVISOR_TACLDEF_PERIPH}, \
93+
{GPIOG, sizeof(*GPIOG), UVISOR_TACLDEF_PERIPH}, \
94+
{SYSCFG, sizeof(*SYSCFG), UVISOR_TACLDEF_PERIPH}, \
95+
{(void *) 0x42000000, 0x01000000, UVISOR_TACLDEF_PERIPH}, \
96+
}
97+
6898
#else /* Target-specific settings */
6999

70100
#error "Unsupported target. Checkout the README.md file for the list of supported targets for this app."

source/main.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ MAIN_ACL(g_main_acl);
2525

2626
/* Enable uVisor. */
2727
UVISOR_SET_MODE_ACL(UVISOR_ENABLED, g_main_acl);
28-
UVISOR_SET_PAGE_HEAP(8 * 1024, 5);
28+
UVISOR_SET_PAGE_HEAP(2 * 1024, 8);
29+
30+
/* Targets with an ARMv7-M MPU needs this space adjustment to prevent a runtime
31+
* memory overflow error. The code below has been output directly by uVisor. */
32+
#if defined(TARGET_EFM32GG_STK3700) || defined(TARGET_DISCO_F429ZI)
33+
uint8_t __attribute__((section(".keep.uvisor.bss.boxes"), aligned(32))) __boxes_overhead[32640];
34+
#endif
2935

3036
static void main_alloc(void)
3137
{
@@ -35,7 +41,7 @@ static void main_alloc(void)
3541

3642
while (1) {
3743
alloc_fill_wait_verify_free(50, seed, 577);
38-
specific_alloc_fill_wait_verify_free(alloc, 5 * kB, seed, 97);
44+
specific_alloc_fill_wait_verify_free(alloc, 1 * kB, seed, 97);
3945
seed++;
4046
}
4147
}

test/filters.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"blacklist" : [ {
3-
"platforms" : ["DISCO_F429ZI"]
3+
"platforms" : []
44
}
55
]
66
}

0 commit comments

Comments
 (0)