Skip to content
Open
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
83 changes: 44 additions & 39 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/laze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ subdirs:
- fake-sensor
- sandbox-no-bindings
- updatable-async
- suit-updatable
49 changes: 49 additions & 0 deletions examples/suit-updatable/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[package]
name = "suit-updatable"
license.workspace = true
edition.workspace = true
publish = false

[lints]
workspace = true

[dependencies]
ariel-os = { workspace = true, features = ["coap", "random", "i2c", "defmt"] }

ariel-os-bindings = { path = "../../src/ariel-os-bindings", features = [
"log",
"time",
"rng",
] }

embedded-nal-coap = "=0.1.0-alpha.5"
coap-handler-implementations = "0.6.1"
coap-handler = "0.2.0"
coap-message = "0.3.2"
coap-numbers = "0.2"
# error_title allows sending out messages; error_request_body_error_position
# would also be welcome, but so far I don't think wasmtime exports that (plus
# it probably take a lot of source map magic to make real use of it).
coap-message-utils = { version = "0.3.0", features = ["error_title"] }
coap-request = "0.2.0-alpha.2"
coap-request-implementations = "0.1.0-alpha.4"

cose-nostd = {git = "https://codeberg.org/COLORADIO-Project/cose-nostd.git", version = "0.1.0", features = ["sign1", "p-256", "verify"]}
dress-up = { git = "https://github.com/ariel-os/dress-up", branch = "async", features = ["async"] }
generic-array = {version = "1.4.1", default-features = false }
uuid = { version = "1.23.1", default-features = false, features = ["v5"] }
wasmtime = { workspace = true, default-features = false, features = [
"pulley",
"runtime",
"component-model",
"async"
] }

rand_core = { workspace = true }

once_cell = { version = "1.21.3", default-features = false, features = [
"critical-section",
] }

embassy-sync = { version = "0.7.2" }
embassy-futures = { version = "0.1.1", default-features = false }
69 changes: 69 additions & 0 deletions examples/suit-updatable/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# SUIT updatable Capsule

## About

This example shows how to update an async WebAssembly capsule over CoAP using a signed SUIT manifest.

The update is kept in memory only. It replaces the currently running capsule for the lifetime of the process, but it is not written to flash and does not survive a reboot.

For lower peak memory usage, the example drops the currently running capsule after the SUIT envelope has been authenticated, but before the new `payload.cwasm` is fetched and validated. If the fetch or validation fails, the runner will be left without a loaded capsule until another valid update is sent.

## Requirements

The commands in this example require:

- Arm's `suit-tool`: https://gitlab.arm.com/research/ietf-suit/suit-tool
- aiocoap's command-line tools: `aiocoap-fileserver`, `aiocoap-client`

## How to run

All commands below are intended to be run from the example root directory.

Run the ESP:

```sh
CONFIG_WIFI_NETWORK=... CONFIG_WIFI_PASSWORD=... laze build -b espressif-esp32-c6-devkitc-1 -s coap-server-config-unprotected run
```

Build the update payload:

```sh
cargo +nightly -Z script ../../precompile_wasm.rs --path ../../payloads/async-bindings/Cargo.toml --config ../../payloads/.cargo/config.toml -o payload.cwasm --fuel
```

Edit `suit/manifest.json` and set the `uri` field to the host serving `payload.cwasm`, for example:

```json
"uri": "coap://192.168.1.100:5683/payload.cwasm"
```

For local testing, the example accepts the same `manifest-sequence-number` more than once and logs a warning. Lower sequence numbers are rejected while the board is running.

Regenerate and sign the SUIT manifest:

```sh
suit-tool create -i suit/manifest.json -o suit/manifest.suit

suit-tool sign -m suit/manifest.suit -k suit/demo-private-key.pem -o suit/manifest.signed.suit
```

Ensure that the host firewall allows inbound UDP traffic on port 5683.
Then serve the update payload:

```sh
aiocoap-fileserver .
```

Send the signed manifest to the board:

```sh
aiocoap-client -m PUT --payload @suit/manifest.signed.suit coap://<board-address>/vm-control
```

The key pair in `suit/` is for this example only. Firmware verification uses `suit/demo-public-key-p256.bin`.

## Testing

This example has been tested on the following boards:

- ESP32-C6-DevKitC-1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
- ESP32-C6-DevKitC-1
- `espressif-esp32-c6-devkit-c1`
- `dfrobot-firebeetle2-esp32-c6`
- `rpi-pico2-w`

Putting the laze builders here make testing simpler by using the name of the boards that are known to Ariel OS.

1 change: 1 addition & 0 deletions examples/suit-updatable/client.cosekey
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{1: 2, -1: 1, -4: h'fb13adeb6518cee5f88417660841142e830a81fe334380a953406a1305e8706b'}
12 changes: 12 additions & 0 deletions examples/suit-updatable/client.diag
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"coap://*": {
"edhoc-oscore": {
"suite": 2,
"method": 3,
"own_cred_style": "by-key-id",
"own_cred": {14: {2: "42-50-31-FF-EF-37-32-39", 8: {1: {1: 2, 2: h'2b', -1: 1, -2: h'ac75e9ece3e50bfc8ed60399889522405c47bf16df96660a41298cb4307f7eb6', -3: h'6e5de611388a4b8a8211334ac7d37ecb52a387d257e6db3c2a93df21ff3affc8'}}}},
"private_key_file": "client.cosekey",
"peer_cred": {14: {8:{1:{1:2, 2:h'', -1:1, -2:h'7ca4b31a9f2add90b012efe4f5fdc46618568c98aa4e5f040d9a8306df6dd578'}}}},
}
},
}
18 changes: 18 additions & 0 deletions examples/suit-updatable/laze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apps:
- name: suit-updatable
context:
- espressif-esp32-c6-devkitc-1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
- espressif-esp32-c6-devkitc-1
- espressif-esp32-c6-devkitc-1
- dfrobot-firebeetle2-esp32-c6
- rpi-pico2-w

selects:
- coap-client
- coap-server
- ?coap-server-config-storage
- alloc
env:
global:
# Must be enough for two payloads, so requirements depend on the transmitted
# payloads' sizes.
heapsize_required:
- "200000"
RUSTFLAGS:
# Disable SIMD in Wasmtime's interpreter
- --cfg pulley_disable_interp_simd
Binary file added examples/suit-updatable/payload.cwasm
Binary file not shown.
Loading