Skip to content

Add support for the STM32F429ZI target #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ This is a simple example to show how to write a uVisor-secured threaded applicat

Supported devices:

| Target | Toolchain | Baud rate |
|--------|-----------|-----------|
| `K64F` | `GCC_ARM` | 9600 |
| Target | Toolchain | Baud rate |
|-------------------|-----------|-----------|
| `K64F` | `GCC_ARM` | 9600 |
| `DISCO_F429ZI` | `GCC_ARM` | 9600 |
| `EFM32GG_STK3700` | `GCC_ARM` | 9600 |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mention fixing #33 in the commit message to auto-close the issue.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


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).

Expand Down
2 changes: 1 addition & 1 deletion mbed-os.lib
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://github.com/ARMmbed/mbed-os/#fc1836545dcc2fc86f03b01292b62bf2089f67c3
https://github.com/ARMmbed/mbed-os/#92fbf2a9b3988d430482fc25a6077f2462e2a634
4 changes: 2 additions & 2 deletions source/led1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static void led1_main(const void *);
* We do not need large stacks in either the main nor the interrupt thread, as
* we do not do anything special in them. */
UVISOR_BOX_NAMESPACE(NULL);
UVISOR_BOX_HEAPSIZE(3 * 1024);
UVISOR_BOX_HEAPSIZE(2 * 1024);
UVISOR_BOX_MAIN(led1_main, osPriorityNormal, 512);
UVISOR_BOX_CONFIG(box_led1, acl, 512, box_context);

Expand All @@ -39,6 +39,6 @@ static void led1_main(const void *)
led1 = !led1;
++uvisor_ctx->heartbeat;
alloc_fill_wait_verify_free(size, seed, 211);
specific_alloc_fill_wait_verify_free(alloc, 5 * kB, seed, 107);
specific_alloc_fill_wait_verify_free(alloc, 1 * kB, seed, 107);
}
}
12 changes: 6 additions & 6 deletions source/led2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static void led2_main(const void *);
* We do not need large stacks in either the main nor the interrupt thread, as
* we do not do anything special in them. */
UVISOR_BOX_NAMESPACE(NULL);
UVISOR_BOX_HEAPSIZE(3 * 1024);
UVISOR_BOX_HEAPSIZE(2 * 1024);
UVISOR_BOX_MAIN(led2_main, osPriorityNormal, 512);
UVISOR_BOX_CONFIG(box_led2, acl, 512, box_context);

Expand All @@ -38,13 +38,13 @@ static void led2_main(const void *)
* page heap!
*/
/* Allocate one page. */
alloc = secure_allocator_create_with_pages(4 * kB, 1 * kB);
alloc = secure_allocator_create_with_pages(2 * kB, 1 * kB);
/* Allocate another page. */
SecureAllocator alloc2 = secure_allocator_create_with_pages(4 * kB, 1 * kB);
SecureAllocator alloc2 = secure_allocator_create_with_pages(8 * kB, 1 * kB);
/* Deallocate alloc1 page, creating a hole. */
secure_allocator_destroy(alloc);
/* Allocate two pages. */
alloc = secure_allocator_create_with_pages(uvisor_get_page_size() + 3 * kB, 6 * kB);
alloc = secure_allocator_create_with_pages(4 * kB, 1 * kB);
/* Deallocate alloc2 page, creating another hole. */
secure_allocator_destroy(alloc2);

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

/* Allocate in first page */
specific_alloc_fill_wait_verify_free(alloc, 6 * kB, seed, 0);
specific_alloc_fill_wait_verify_free(alloc, 1 * kB, seed, 0);

/* Allocate in second page */
specific_alloc_fill_wait_verify_free(alloc, 6 * kB, seed, 101);
specific_alloc_fill_wait_verify_free(alloc, 1 * kB, seed, 101);
}
}
9 changes: 1 addition & 8 deletions source/led3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static void led3_main(const void *);
* We need at least 1kB in the main thread as we use printf in it. The interrupt
* stack size can be smaller as we do not do anything special in them. */
UVISOR_BOX_NAMESPACE(NULL);
UVISOR_BOX_HEAPSIZE(3 * 1024);
UVISOR_BOX_HEAPSIZE(2 * 1024);
UVISOR_BOX_MAIN(led3_main, osPriorityNormal, 1024);
UVISOR_BOX_CONFIG(box_led3, acl, 512, box_context);

Expand Down Expand Up @@ -59,13 +59,6 @@ static void led3_main(const void *)
uvisor_error(USER_NOT_ALLOWED);
}

Thread thread2(osPriorityNormal, 512, NULL);
status = thread2.start(run_3);
if (status != osOK) {
printf("Could not start box_led3 thread2.\r\n");
uvisor_error(USER_NOT_ALLOWED);
}

/* Create page-backed allocator. */
const uint32_t kB = 1024;
SecureAllocator alloc = secure_allocator_create_with_pages(4 * kB, 1 * kB);
Expand Down
34 changes: 32 additions & 2 deletions source/main-hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
{SPI0, sizeof(*SPI0), UVISOR_TACLDEF_PERIPH}, \
}

#elif defined (TARGET_EFM32GG_STK3700)
#elif defined(TARGET_EFM32GG_STK3700)

#define MAIN_LED LED1
#define SECURE_LED LED2
#define LED_ON true
#define LED_OFF false
#define SECURE_SWITCH SW2
#define SECURE_SWITCH SW0
#define SECURE_SWITCH_PULL PullUp

#define MAIN_ACL(acl_list_name) \
Expand All @@ -65,6 +65,36 @@
{(void *) 0x42000000, 0x2000000, UVISOR_TACLDEF_PERIPH}, \
}

#elif defined(TARGET_DISCO_F429ZI)

#define MAIN_LED LED1
#define SECURE_LED LED2
#define LED_ON true
#define LED_OFF false
#define SECURE_SWITCH USER_BUTTON
#define SECURE_SWITCH_PULL PullDown

#define MAIN_ACL(acl_list_name) \
static const UvisorBoxAclItem acl_list_name[] = { \
{GPIOA, sizeof(*GPIOA), UVISOR_TACLDEF_PERIPH}, \
{GPIOB, sizeof(*GPIOB), UVISOR_TACLDEF_PERIPH}, \
{GPIOC, sizeof(*GPIOC), UVISOR_TACLDEF_PERIPH}, \
{GPIOD, sizeof(*GPIOD), UVISOR_TACLDEF_PERIPH}, \
{GPIOE, sizeof(*GPIOE), UVISOR_TACLDEF_PERIPH}, \
{RTC, sizeof(*RTC), UVISOR_TACLDEF_PERIPH}, \
{TIM5, sizeof(*TIM5), UVISOR_TACLDEF_PERIPH}, \
{USART1, sizeof(*USART1), UVISOR_TACLDEF_PERIPH}, \
{I2C1, sizeof(*I2C1), UVISOR_TACLDEF_PERIPH}, \
{SPI1, sizeof(*SPI1), UVISOR_TACLDEF_PERIPH}, \
{RCC, sizeof(*RCC), UVISOR_TACLDEF_PERIPH}, \
{FLASH, sizeof(*FLASH), UVISOR_TACLDEF_PERIPH}, \
{PWR, sizeof(*PWR), UVISOR_TACLDEF_PERIPH}, \
{EXTI, sizeof(*EXTI), UVISOR_TACLDEF_PERIPH}, \
{GPIOG, sizeof(*GPIOG), UVISOR_TACLDEF_PERIPH}, \
{SYSCFG, sizeof(*SYSCFG), UVISOR_TACLDEF_PERIPH}, \
{(void *) 0x42000000, 0x01000000, UVISOR_TACLDEF_PERIPH}, \
}

#else /* Target-specific settings */

#error "Unsupported target. Checkout the README.md file for the list of supported targets for this app."
Expand Down
10 changes: 8 additions & 2 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ MAIN_ACL(g_main_acl);

/* Enable uVisor. */
UVISOR_SET_MODE_ACL(UVISOR_ENABLED, g_main_acl);
UVISOR_SET_PAGE_HEAP(8 * 1024, 5);
UVISOR_SET_PAGE_HEAP(2 * 1024, 8);

/* Targets with an ARMv7-M MPU needs this space adjustment to prevent a runtime
* memory overflow error. The code below has been output directly by uVisor. */
#if defined(TARGET_EFM32GG_STK3700) || defined(TARGET_DISCO_F429ZI)
uint8_t __attribute__((section(".keep.uvisor.bss.boxes"), aligned(32))) __boxes_overhead[32640];
#endif

static void main_alloc(void)
{
Expand All @@ -35,7 +41,7 @@ static void main_alloc(void)

while (1) {
alloc_fill_wait_verify_free(50, seed, 577);
specific_alloc_fill_wait_verify_free(alloc, 5 * kB, seed, 97);
specific_alloc_fill_wait_verify_free(alloc, 1 * kB, seed, 97);
seed++;
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/filters.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"blacklist" : [ {
"platforms" : ["DISCO_F429ZI"]
"platforms" : []
}
]
}