[riot-notifications] [RIOT-OS/RIOT] makefiles: allow to override suit manifest payloads (#16771)

Francisco notifications at github.com
Mon Aug 23 16:36:22 CEST 2021


### Contribution description

This adds:

* SUIT_MANIFEST_PAYLOADS: firmware payloads to be published with the
manifest.
* SUIT_MANIFEST_SLOTFILES: firmware payloads referenced by the manifest
in the form 'filename:[offset]:[comp_name]' as expected by
gen_manifest.py.

With this the same recipes suit/publish suit/notify can be used with
non slotfiles payloads.

### Testing procedure

`examples/suit_update` still passes.

`suit/publish suit/notify` can work out of the box with for example a patch like this:

```diff
diff --git a/examples/suit_update/Makefile b/examples/suit_update/Makefile
index ac0d3c8bae..eefc6098f0 100644
--- a/examples/suit_update/Makefile
+++ b/examples/suit_update/Makefile
@@ -58,6 +58,8 @@ ifeq ($(BOARD),native)
   USE_ETHOS ?= 0
   # Configure two RAM regions with 2K each
   CFLAGS += -DCONFIG_SUIT_STORAGE_RAM_REGIONS=2 -DCONFIG_SUIT_STORAGE_RAM_SIZE=2048
+  #
+  include $(CURDIR)/Makefile.suit.native
 endif

 # Change this to 0 to not use ethos
diff --git a/examples/suit_update/Makefile.suit.native b/examples/suit_update/Makefile.suit.native
new file mode 100644
index 0000000000..73e58dd4d6
--- /dev/null
+++ b/examples/suit_update/Makefile.suit.native
@@ -0,0 +1,20 @@
+# Required variables defined in riotboot.inc.mk or Makefile.include
+BINDIR_APP = $(CURDIR)/bin/$(BOARD)/$(APPLICATION)
+EPOCH := $(shell date +%s)
+APP_VER ?= $(EPOCH)
+
+# Recipe to generate dummy payload
+SUIT_NATIVE_PAYLOAD ?= "AABBCCDD"
+SUIT_NATIVE_PAYLOAD_BIN ?= $(BINDIR_APP).$(APP_VER).bin
+$(SUIT_NATIVE_PAYLOAD_BIN):
+       @$(Q)echo $(SUIT_NATIVE_PAYLOAD) > $@
+
+# Only a single RAM secotor is being updated, so change accordingly
+SUIT_MANIFEST_PAYLOADS ?= $(SUIT_NATIVE_PAYLOAD_BIN)
+SUIT_MANIFEST_SLOTFILES ?= $(SUIT_NATIVE_PAYLOAD_BIN):0:ram:0
+# Make sure it is built
+BUILD_FILES += $(SUIT_NATIVE_PAYLOAD_BIN)
+
+#
+SUIT_COAP_SERVER ?= [2001:db8::1]
+SUIT_CLIENT ?= [2001:db8::2]
diff --git a/examples/suit_update/main.c b/examples/suit_update/main.c
index 27ff9a9cdd..13fd7f5773 100644
--- a/examples/suit_update/main.c
+++ b/examples/suit_update/main.c
@@ -192,6 +192,11 @@ int main(void)
     cmd_print_riotboot_hdr(0, NULL);
 #endif

+    ipv6_addr_t addr;
+    const char addr_str[] = "2001:db8::2";
+    ipv6_addr_from_str(&addr, addr_str);
+    gnrc_netif_ipv6_addr_add(gnrc_netif_iter(NULL), &addr, 64, 0);
+
     /* start suit coap updater thread */
     suit_coap_run();
```

```
```bash
$ sudo ip tuntap add tap0 mode tap user $USER
$ sudo ip link set tap0 up
$ sudo ip address add 2001:db8::1/64 dev tap0
$ BOARD=native make -C examples/suit_update flash term`
$ BOARD=native make -C examples/suit_update/ suit/publish
$ BOARD=native make -C examples/suit_update/ suit/notify
```

```
main(): This is RIOT! (Version: 2021.10-devel-282-g0caae-pr_suit_override_manifest_payloads)
RIOT SUIT update example application
suit_coap: started.
Starting the shell
> suit: received URL: "coap://[2001:db8::1]/fw/native/suit_update-riot.suit_signed.latest.bin"
suit_coap: trigger received
suit_coap: downloading "coap://[2001:db8::1]/fw/native/suit_update-riot.suit_signed.latest.bin"
suit_coap: got manifest with size 305
suit: verifying manifest signature
suit: validated manifest version
)Retrieved sequence number: 0
Manifest seq_no: 1629729120, highest available: 0
suit: validated sequence number
)Formatted component name: .ram.0
validating vendor ID
Comparing 547d0d74-6d3a-5a92-9662-4881afd9407b to 547d0d74-6d3a-5a92-9662-4881afd9407b from manifest
validating vendor ID: OK
validating class id
Comparing bcc90984-fe7d-562b-b4c9-a24f26a3a9cd to bcc90984-fe7d-562b-b4c9-a24f26a3a9cd from manifest
validating class id: OK
SUIT policy check OK.
Formatted component name: .ram.0
Fetching firmware |█████████████████████████| 100%
Finalizing payload store
Verifying image digest
Starting digest verification against image
Install correct payload
Verifying image digest
Starting digest verification against image
Install correct payload
```



### Issues/PRs references


You can view, comment on, or merge this pull request online at:

  https://github.com/RIOT-OS/RIOT/pull/16771

-- Commit Summary --

  * makefiles: allow to override suit manifest payloads

-- File Changes --

    M Makefile.include (5)
    M makefiles/boot/riotboot.mk (5)
    M makefiles/suit.inc.mk (14)

-- Patch Links --

https://github.com/RIOT-OS/RIOT/pull/16771.patch
https://github.com/RIOT-OS/RIOT/pull/16771.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/16771
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210823/2eb9e824/attachment-0001.htm>


More information about the notifications mailing list