Skip to content

Update mbed OS to 5.3.0 #10

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 3 commits into from
Dec 16, 2016
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
58 changes: 44 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,70 @@
# Threaded RPC with uVisor Example
# Threaded RPC with uVisor example

This is a simple example to show how to use several uVisor APIs to build a box that securely stores a number.
This number can only be written by one box, but read by all boxes.

- Create and run secure boxes.
- Secure static and dynamic memory inside secure boxes.
- Run threads inside secure boxes.
- Issue RPC requests to other secure boxes and wait for their completion.
- Receive and process incoming RPC requests from other secure boxes.
- Get box id and namespace of the RPC caller.
* Create and run secure boxes.
* Secure static and dynamic memory inside secure boxes.
* Run threads inside secure boxes.
* Issue RPC requests to other secure boxes and wait for their completion.
* Receive and process incoming RPC requests from other secure boxes.
* Get box id and namespace of the RPC caller.

This demo contains three secure boxes:

1. The secure number vault. This box stores one number that can only be written to by client A, but read by everyone.
2. Client A, which attempts to write (and succeeds) and read the secure number.
3. Client B, which attempts to write (but fails) and read the secure number.
1. Client A, which attempts to write (and succeeds) and read the secure number.
1. Client B, which attempts to write (but fails) and read the secure number.

The insecure box 0 also attempts to write (but fails) and read the secure number.

## Building
Supported devices:

The example currently only works on K64F with the GCC_ARM toolchain.
| Target | Toolchain | Baud rate |
|--------|-----------|-----------|
| `K64F` | `GCC_ARM` | 9600 |

### Release
Latest release: [mbed-os-5.3.0](https://github.com/ARMmbed/mbed-os-example-uvisor/releases/tag/mbed-os-5.3.0). Tested with [mbed-cli v1.0.0](https://github.com/ARMmbed/mbed-cli/releases/tag/1.0.0).

## Quickstart

For a release build, please enter:

```bash
$ mbed compile -m K64F -t GCC_ARM
$ mbed compile -m K64F -t GCC_ARM -c
```

You will find the resulting binary in `BUILD/K64F/GCC_ARM/mbed-os-example-uvisor-number-store.bin`. You can drag and drop it onto your board USB drive.

Press the reset button. The `box_number_store` secure box will use 3 LEDs on your target to signal the execution of the `get_caller_id`, `get_number` and `set_number` APIs. You can observe the example output on the serial port:

```bash
$ screen /dev/tty.usbmodem1422 9600
```

You will see an output similar to the following one:

```
**** uVisor secure number store example *****
Trusted client a has box id 2
2: Wrote '0xfffffed4'
1: Read '0xfffffed4'
1: Permission denied. This client cannot write the secure number '0xfffffe0c'
0: Read '0xfffffed4'
0: Permission denied. This client cannot write the secure number '0x00000019'
2: Read '0xfffffed4'
2: Wrote '0xfffffda8'
2: Read '0xfffffda8'
1: Permission denied. This client cannot write the secure number '0xfffffc18'
2: Wrote '0xfffffc7c'
...
```

> **Note**: If your target does not have 3 different LEDs or LED colours, you will see the same LED blink multiple times. The example use the general mbed OS naming structure `LED1`, `LED2`, `LED3`.

### Debug

When a debugger is connected, you can observe debug output from uVisor. Please note that these messages are sent through semihosting, which halts the program execution if a debugger is not connected. For more information please read the [Debugging uVisor on mbed OS](https://github.com/ARMmbed/uvisor/blob/master/docs/api/DEBUGGING.md) guide. To build a debug version of the program:
When a debugger is connected, you can observe debug output from uVisor. Please note that these messages are sent through semihosting, which halts the program execution if a debugger is not connected. For more information please read the [Debugging uVisor on mbed OS](https://github.com/ARMmbed/uvisor/blob/master/docs/api/DEBUGGING.md) guide. To build a debug version of this example, please enter:

```bash
$ mbed compile -m K64F -t GCC_ARM --profile mbed-os/tools/profiles/debug.json -c
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/#d5de476f74dd4de27012eb74ede078f6330dfc3f
https://github.com/ARMmbed/mbed-os/#c3b9436e12610acaab723f730ab15b48a539a5ac
6 changes: 5 additions & 1 deletion source/client_a.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ static void box_async_runner(const void *)
while (1) {
uint32_t ret;
int status = rpc_fncall_wait(result, UVISOR_WAIT_FOREVER, &ret);
uvisor_ctx->pc->printf("%c: %s '0x%08x'\r\n", (char) uvisor_box_id_self() + '0', (ret == 0) ? "Wrote" : "Failed to write", (unsigned int) number);
uvisor_ctx->pc->printf("%c: %s '0x%08x'\r\n",
(char) uvisor_box_id_self() + '0',
(ret == 0) ? "Wrote" :
"Permission denied. This client cannot write the secure number",
(unsigned int) number);
/* FIXME: Add better error handling. */
if (!status) {
break;
Expand Down
6 changes: 5 additions & 1 deletion source/client_b.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ static void client_b_main(const void *)
while (1) {
uint32_t ret;
int status = rpc_fncall_wait(result, UVISOR_WAIT_FOREVER, &ret);
uvisor_ctx->pc->printf("%c: %s '0x%08x'\r\n", (char) uvisor_box_id_self() + '0', (ret == 0) ? "Wrote" : "Failed to write", (unsigned int) number);
uvisor_ctx->pc->printf("%c: %s '0x%08x'\r\n",
(char) uvisor_box_id_self() + '0',
(ret == 0) ? "Wrote" :
"Permission denied. This client cannot write the secure number",
(unsigned int) number);
if (!status) {
break;
}
Expand Down
6 changes: 5 additions & 1 deletion source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ static void main_async_runner(const void *)
/* TODO typesafe return codes */
uint32_t ret;
status = rpc_fncall_wait(result, UVISOR_WAIT_FOREVER, &ret);
printf("%c: %s '0x%08x'\r\n", (char) uvisor_box_id_self() + '0', (ret == 0) ? "Wrote" : "Failed to write", (unsigned int) number);
printf("%c: %s '0x%08x'\r\n",
(char) uvisor_box_id_self() + '0',
(ret == 0) ? "Wrote" :
"Permission denied. This client cannot write the secure number",
(unsigned int) number);
if (!status) {
break;
}
Expand Down