2020-02-26 14:48:24 +01:00
|
|
|
#
|
|
|
|
# This file contains stuff related to SUIT manifest generation.
|
|
|
|
# It depends on SUIT key generation, which can be found in
|
2020-02-26 14:49:35 +01:00
|
|
|
# makefiles/suit.base.inc.mk
|
2020-02-26 14:48:24 +01:00
|
|
|
#
|
|
|
|
#
|
2022-04-14 13:45:44 +02:00
|
|
|
|
|
|
|
# Mandatory APP_VER, set to epoch by default
|
|
|
|
EPOCH = $(call memoized,EPOCH,$(shell date +%s))
|
|
|
|
APP_VER ?= $(EPOCH)
|
|
|
|
|
|
|
|
SUIT_VENDOR ?= "riot-os.org"
|
|
|
|
SUIT_SEQNR ?= $(APP_VER)
|
|
|
|
SUIT_CLASS ?= $(BOARD)
|
|
|
|
|
2021-09-16 15:46:44 +02:00
|
|
|
SUIT_COAP_BASEPATH ?= fw/$(APPLICATION)/$(BOARD)
|
2020-02-26 14:48:24 +01:00
|
|
|
SUIT_COAP_SERVER ?= localhost
|
|
|
|
SUIT_COAP_ROOT ?= coap://$(SUIT_COAP_SERVER)/$(SUIT_COAP_BASEPATH)
|
|
|
|
SUIT_COAP_FSROOT ?= $(RIOTBASE)/coaproot
|
|
|
|
|
2021-09-16 15:46:44 +02:00
|
|
|
BINDIR_SUIT = $(BINDIR)/suit_files
|
|
|
|
$(BINDIR_SUIT): $(CLEAN)
|
|
|
|
$(Q)mkdir -p $(BINDIR_SUIT)
|
|
|
|
|
2020-02-26 14:48:24 +01:00
|
|
|
#
|
2021-07-27 11:42:30 +02:00
|
|
|
SUIT_MANIFEST_BASENAME ?= riot.suit
|
2022-04-14 13:45:44 +02:00
|
|
|
SUIT_MANIFEST ?= $(BINDIR_SUIT)/$(SUIT_MANIFEST_BASENAME)_unsigned.$(SUIT_SEQNR).bin
|
2021-09-16 15:46:44 +02:00
|
|
|
SUIT_MANIFEST_LATEST ?= $(BINDIR_SUIT)/$(SUIT_MANIFEST_BASENAME)_unsigned.latest.bin
|
2022-04-14 13:45:44 +02:00
|
|
|
SUIT_MANIFEST_SIGNED ?= $(BINDIR_SUIT)/$(SUIT_MANIFEST_BASENAME).$(SUIT_SEQNR).bin
|
2021-09-16 15:46:44 +02:00
|
|
|
SUIT_MANIFEST_SIGNED_LATEST ?= $(BINDIR_SUIT)/$(SUIT_MANIFEST_BASENAME).latest.bin
|
2020-02-26 14:48:24 +01:00
|
|
|
|
|
|
|
SUIT_NOTIFY_VERSION ?= latest
|
2021-09-16 15:46:44 +02:00
|
|
|
SUIT_NOTIFY_MANIFEST ?= $(SUIT_MANIFEST_BASENAME).$(SUIT_NOTIFY_VERSION).bin
|
2020-02-26 14:48:24 +01:00
|
|
|
|
|
|
|
# Long manifest names require more buffer space when parsing
|
|
|
|
export CFLAGS += -DCONFIG_SOCK_URLPATH_MAXLEN=128
|
2022-06-01 13:18:00 +02:00
|
|
|
export CFLAGS += -DSUIT_VENDOR_DOMAIN="\"$(SUIT_VENDOR)\""
|
2020-02-26 14:48:24 +01:00
|
|
|
|
2021-09-16 15:46:44 +02:00
|
|
|
SUIT_MANIFEST_PAYLOADS ?= $(SLOT0_RIOT_BIN) $(SLOT1_RIOT_BIN)
|
|
|
|
SUIT_MANIFEST_SLOTFILES ?= $(SLOT0_RIOT_BIN):$(SLOT0_OFFSET) \
|
|
|
|
$(SLOT1_RIOT_BIN):$(SLOT1_OFFSET)
|
2021-07-27 11:42:30 +02:00
|
|
|
|
2021-09-16 15:46:44 +02:00
|
|
|
$(SUIT_MANIFEST): $(SUIT_MANIFEST_PAYLOADS) $(BINDIR_SUIT)
|
2021-08-16 11:23:50 +02:00
|
|
|
$(Q)$(RIOTBASE)/dist/tools/suit/gen_manifest.py \
|
2020-02-26 14:48:24 +01:00
|
|
|
--urlroot $(SUIT_COAP_ROOT) \
|
|
|
|
--seqnr $(SUIT_SEQNR) \
|
|
|
|
--uuid-vendor $(SUIT_VENDOR) \
|
|
|
|
--uuid-class $(SUIT_CLASS) \
|
|
|
|
-o $@.tmp \
|
2021-07-27 11:42:30 +02:00
|
|
|
$(SUIT_MANIFEST_SLOTFILES)
|
2020-02-26 14:48:24 +01:00
|
|
|
|
2021-08-16 11:23:50 +02:00
|
|
|
$(Q)$(SUIT_TOOL) create -f suit -i $@.tmp -o $@
|
2020-02-26 14:48:24 +01:00
|
|
|
|
2021-08-16 11:23:50 +02:00
|
|
|
$(Q)rm -f $@.tmp
|
2020-02-26 14:48:24 +01:00
|
|
|
|
|
|
|
$(SUIT_MANIFEST_SIGNED): $(SUIT_MANIFEST) $(SUIT_SEC)
|
2022-05-24 01:13:02 +02:00
|
|
|
$(Q)$(SUIT_TOOL) sign $(SUIT_TOOL_ARGS) -k $(SUIT_SEC) -m $(SUIT_MANIFEST) -o $@
|
2020-02-26 14:48:24 +01:00
|
|
|
|
|
|
|
$(SUIT_MANIFEST_LATEST): $(SUIT_MANIFEST)
|
2021-08-16 11:23:50 +02:00
|
|
|
$(Q)ln -f -s $< $@
|
2020-02-26 14:48:24 +01:00
|
|
|
|
|
|
|
$(SUIT_MANIFEST_SIGNED_LATEST): $(SUIT_MANIFEST_SIGNED)
|
2021-08-16 11:23:50 +02:00
|
|
|
$(Q)ln -f -s $< $@
|
2020-02-26 14:48:24 +01:00
|
|
|
|
2021-09-16 15:46:44 +02:00
|
|
|
SUIT_MANIFESTS := $(SUIT_MANIFEST_SIGNED) \
|
2020-02-26 14:48:24 +01:00
|
|
|
$(SUIT_MANIFEST_SIGNED_LATEST)
|
|
|
|
|
|
|
|
suit/manifest: $(SUIT_MANIFESTS)
|
|
|
|
|
2021-07-27 11:42:30 +02:00
|
|
|
suit/publish: $(SUIT_MANIFESTS) $(SUIT_MANIFEST_PAYLOADS)
|
2021-08-16 11:23:50 +02:00
|
|
|
$(Q)mkdir -p $(SUIT_COAP_FSROOT)/$(SUIT_COAP_BASEPATH)
|
|
|
|
$(Q)cp $^ $(SUIT_COAP_FSROOT)/$(SUIT_COAP_BASEPATH)
|
|
|
|
$(Q)for file in $^; do \
|
2020-02-26 14:48:24 +01:00
|
|
|
echo "published \"$$file\""; \
|
|
|
|
echo " as \"$(SUIT_COAP_ROOT)/$$(basename $$file)\""; \
|
|
|
|
done
|
|
|
|
|
|
|
|
suit/notify: | $(filter suit/publish, $(MAKECMDGOALS))
|
2021-08-16 11:23:50 +02:00
|
|
|
$(Q)test -n "$(SUIT_CLIENT)" || { echo "error: SUIT_CLIENT unset!"; false; }
|
2020-02-26 14:48:24 +01:00
|
|
|
aiocoap-client -m POST "coap://$(SUIT_CLIENT)/suit/trigger" \
|
|
|
|
--payload "$(SUIT_COAP_ROOT)/$(SUIT_NOTIFY_MANIFEST)" && \
|
|
|
|
echo "Triggered $(SUIT_CLIENT) to update."
|