Skip to content

Commit

Permalink
fixup! examples/suit_update: add vfs storage for native
Browse files Browse the repository at this point in the history
  • Loading branch information
fjmolinas committed Jun 1, 2022
1 parent 5da7eea commit b72093f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
39 changes: 32 additions & 7 deletions examples/suit_update/README.native.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ $ dist/tools/suit/suit-manifest-generator/bin/suit-tool sign -k keys/default.pem

5. Pull the manifest from the native instance:
```
> suit coap://[2001:db8::1]/suit_manifest.signed
> suit fetch coap://[2001:db8::1]/suit_manifest.signed
```

6. Verify the content of the storage location
Expand Down Expand Up @@ -172,14 +172,18 @@ the payloads.
lsstorage
RAM slot 0: ".ram.0"
RAM slot 1: ".ram.1"
VFS 0: "/nvm0/SLOT0.txt"
VFS 1: "/nvm0/SLOT1.txt"
```

As shown above, two storage locations are available, `.ram.0` and `.ram.1`.
While two slots are available, in this example only the content of the `.ram.0`
slot will be updated.
As shown above, four storage locations are available, RAM based storage: `.ram.0` and `.ram.1`
as well as VFS based storage: `/nvm0/SLOT0.TXT` and `/nvm0/SLOT1.TXT`.
While multiple slots are available, in this example only the content of the `.ram.0`
slot will be updated, but the procedure is the same for any other slot, just replace
`.ram.0

- The `storage_content` command can be used to display a hex dump command of one
of the storage locations. It requires a location string, an offset and a
of the RAM storage locations. It requires a location string, an offset and a
number of bytes to print:

```console
Expand All @@ -188,6 +192,13 @@ slot will be updated.
```
As the storage location is empty on boot, nothing is printed.

For VFS based storage the `vfs` command can be used instead:
```console
> vfs r /nvm0/SLOT0.txt
Error opening file "/nvm0/SLOT0.txt": -ENOENT
```
But as the file does not initially exist, nothing is printed.

### Generating the payload and manifest
[generating-the-payload-and-manifest]: #generating-the-payload-and-manifest

Expand All @@ -208,6 +219,12 @@ acts as a template for the real SUIT manifest. Within RIOT, the script
$ dist/tools/suit/gen_manifest.py --urlroot coap://[2001:db8::1]/ --seqnr 1 -o suit.tmp coaproot/payload.bin:0:ram:0
```

or for vfs storage:

```console
$ dist/tools/suit/gen_manifest.py --urlroot coap://[2001:db8::1]/ --seqnr 1 -o suit.tmp coaproot/payload.bin:0:/nvm0/SLOT0.txt
```

This generates a suit manifest template with the sequence number set to `1`, a
payload that should be stored at slot offset zero in slot `.ram.0`. The url for
the payload starts with `coap://[fe80::4049:bfff:fe60:db09]/`. Make sure to
Expand Down Expand Up @@ -294,7 +311,7 @@ command sequences in the manifest and download the payload when instructed to.
The URL for the manifest can be supplied to the instance via the command line.

```console
> suit coap://[2001:db8::1]/suit_manifest.signed
> suit fetch coap://[2001:db8::1]/suit_manifest.signed
```

The payload is the full URL to the signed manifest. The native instance should
Expand Down Expand Up @@ -338,6 +355,14 @@ same payload as suggested above was used, it should look like this:
41414242434344440A
```

The process can be done multiple times with both slot `.ram.0` and `.ram.1` and
Or for vfs storage:

```
> vfs r /nvm0/SLOT0.txt
vfs r /nvm0/SLOT0.txt
00000000: 4141 4242 4343 4444 0a AABBCCDD.
-- EOF --
```
The process can be done multiple times for any of the slots and
different payloads. Keep in mind that the sequence number is a strict
monotonically number and must be increased after every update.
6 changes: 3 additions & 3 deletions examples/suit_update/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];
/* add handled storages */
#if IS_USED(MODULE_SUIT_STORAGE_VFS)
XFA_USE(char*, suit_storage_files_reg);
#endif
#ifdef BOARD_NATIVE
XFA(suit_storage_files_reg, 0) char* _manifest = VFS_DEFAULT_DATA "/SLOT0.TXT";
XFA(suit_storage_files_reg, 1) char* _firmware = VFS_DEFAULT_DATA "/SLOT1.TXT";
XFA(suit_storage_files_reg, 0) char* _slot0 = VFS_DEFAULT_DATA "/SLOT0.txt";
XFA(suit_storage_files_reg, 1) char* _slot1 = VFS_DEFAULT_DATA "/SLOT1.txt";
#endif
#endif

static void *_nanocoap_server_thread(void *arg)
Expand Down

0 comments on commit b72093f

Please sign in to comment.