Skip to content

Commit

Permalink
examples/suit_update: add vfs storage for native
Browse files Browse the repository at this point in the history
  • Loading branch information
fjmolinas committed Apr 22, 2022
1 parent f0f8dcc commit 00f973b
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
3 changes: 3 additions & 0 deletions examples/suit_update/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ TESTRUNNER_RESET_AFTER_TERM ?= 1
# with ed25519 support.
TEST_ON_CI_BLACKLIST = all

# Add custom SUIT targets
include $(CURDIR)/Makefile.suit.custom

include $(RIOTBASE)/Makefile.include

# allow to use large blocks to utilize large MTUs (802.15.4g, Ethernet, WiFi)
Expand Down
8 changes: 8 additions & 0 deletions examples/suit_update/Makefile.board.dep
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
ifeq ($(BOARD),native)
USEMODULE += suit_storage_ram
USEMODULE += netdev_default
# Use VFS storage for native
USEMODULE += suit_storage_vfs
## Use VFS
USEMODULE += vfs
## Use default storage
USEMODULE += vfs_default
## Auto-format on mount
USEMODULE += vfs_auto_format
else
USEMODULE += suit_storage_flashwrite
endif
30 changes: 30 additions & 0 deletions examples/suit_update/Makefile.suit.custom
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Required variables defined in riotboot.inc.mk or Makefile.include
BINDIR_APP = $(CURDIR)/bin/$(BOARD)/$(APPLICATION)
$(BINDIR_APP): $(CLEAN)
$(Q)mkdir -p $(BINDIR_APP)

# Include to be able to use memoized
include $(RIOTBASE)/makefiles/utils/variables.mk
EPOCH = $(call memoized,EPOCH,$(shell date +%s))
APP_VER ?= $(EPOCH)

# Default addressing if following README.native.md
ifeq ($(BOARD),native)
SUIT_CLIENT ?= [2001:db8::2]
SUIT_COAP_SERVER ?= [2001:db8::1]
endif

ifeq ($(BOARD),native)
# Set settings for publishing fake fw payloads to native
SUIT_NATIVE_PAYLOAD ?= "AABBCCDD"
SUIT_NATIVE_PAYLOAD_BIN ?= $(BINDIR_APP)/fw.$(APP_VER).bin
# Make sure it is built
BUILD_FILES += $(SUIT_NATIVE_PAYLOAD_BIN)

$(SUIT_NATIVE_PAYLOAD_BIN): $(BINDIR_APP)
$(Q)echo $(SUIT_NATIVE_PAYLOAD) > $@

SUIT_FW_STORAGE ?= /nvm0/SLOT0.TXT
SUIT_MANIFEST_PAYLOADS ?= $(SUIT_NATIVE_PAYLOAD_BIN)
SUIT_MANIFEST_SLOTFILES ?= $(SUIT_NATIVE_PAYLOAD_BIN):0:$(SUIT_FW_STORAGE)
endif
15 changes: 14 additions & 1 deletion examples/suit_update/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@

#include "suit/storage.h"
#include "suit/storage/ram.h"
#ifdef BOARD_NATIVE
#include "suit/storage/vfs.h"
#include "xfa.h"
#include "vfs_default.h"
#endif

#ifdef MODULE_PERIPH_GPIO
#include "periph/gpio.h"
Expand All @@ -48,6 +53,13 @@ static msg_t _nanocoap_server_msg_queue[NANOCOAP_SERVER_QUEUE_SIZE];
#define MAIN_QUEUE_SIZE (8)
static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];

#ifdef BOARD_NATIVE
/* add handled storages */
XFA_USE(char*, suit_storage_files_reg);
XFA(suit_storage_files_reg, 0) char* _manifest = VFS_DEFAULT_DATA "/SLOT0.TXT";
XFA(suit_storage_files_reg, 0) char* _firmware = VFS_DEFAULT_DATA "/SLOT1.TXT";
#endif

static void *_nanocoap_server_thread(void *arg)
{
(void)arg;
Expand Down Expand Up @@ -189,7 +201,8 @@ int main(void)
cmd_print_current_slot(0, NULL);
cmd_print_riotboot_hdr(0, NULL);
#endif

/* initialize suit storage */
suit_storage_init_all();
/* start suit coap updater thread */
suit_coap_run();

Expand Down

0 comments on commit 00f973b

Please sign in to comment.