-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Add SUIT-verified update example #17
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
Open
jhirschler
wants to merge
3
commits into
ariel-os:main
Choose a base branch
from
COLORADIO-Project:suit-updatable
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,3 +12,4 @@ subdirs: | |
| - fake-sensor | ||
| - sandbox-no-bindings | ||
| - updatable-async | ||
| - suit-updatable | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {1: 2, -1: 1, -4: h'fb13adeb6518cee5f88417660841142e830a81fe334380a953406a1305e8706b'} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'}}}}, | ||
| } | ||
| }, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,18 @@ | ||||||||||
| apps: | ||||||||||
| - name: suit-updatable | ||||||||||
| context: | ||||||||||
| - espressif-esp32-c6-devkitc-1 | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| 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 not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting the
lazebuilders here make testing simpler by using the name of the boards that are known to Ariel OS.