1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #18045 from benpicco/suit/transport-vfs

suit/transport/vfs: add VFS as source for firmware updates
This commit is contained in:
Francisco 2022-06-07 08:32:15 +02:00 committed by GitHub
commit f6d5a54c3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 426 additions and 252 deletions

View File

@ -41,6 +41,10 @@ QUIET ?= 1
USEMODULE += suit suit_transport_coap
# enable VFS transport (only works on boards with external storage)
USEMODULE += suit_transport_vfs
USEMODULE += vfs_default
# Display a progress bar during firmware download
USEMODULE += progress_bar

View File

@ -846,6 +846,7 @@ endif
ifneq (,$(filter suit_transport_%, $(USEMODULE)))
USEMODULE += suit_transport
USEMODULE += suit_transport_worker
endif
ifneq (,$(filter suit_transport_coap, $(USEMODULE)))
@ -854,6 +855,10 @@ ifneq (,$(filter suit_transport_coap, $(USEMODULE)))
USEMODULE += sock_util
endif
ifneq (,$(filter suit_transport_vfs, $(USEMODULE)))
USEMODULE += vfs_util
endif
ifneq (,$(filter suit_storage_%, $(USEMODULE)))
USEMODULE += suit_storage
endif

View File

@ -325,22 +325,6 @@ static inline bool suit_component_check_flag(suit_component_t *component,
int suit_component_name_to_string(const suit_manifest_t *manifest,
const suit_component_t *component,
char separator, char *buf, size_t buf_len);
/**
* @brief Helper function for writing bytes on flash a specified offset
*
* @param[in] arg ptr to the SUIT manifest
* @param[in] offset offset to write to on flash
* @param[in] buf bytes to write
* @param[in] len length of bytes to write
* @param[in] more whether more data is coming
*
* @return 0 on success
* @return <0 on error
*/
int suit_storage_helper(void *arg, size_t offset, uint8_t *buf, size_t len,
int more);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2022 ML!PA Consulting GmbH
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup sys_suit_transport_vfs SUIT secure firmware OTA VFS transport
* @ingroup sys_suit
* @brief SUIT firmware VFS transport
*
* Allows to load firmware updates from the filesystem.
* URL scheme: file://<path>/<to>/manifest.suit
*
* e.g. set `SUIT_COAP_ROOT` to `file:///sd0/fw` and place the
* update files to the folder fw/ on the first SD card.
* @{
*
* @brief VFS transport backend definitions for SUIT manifests
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com>
*
*/
#ifndef SUIT_TRANSPORT_VFS_H
#define SUIT_TRANSPORT_VFS_H
#include "net/nanocoap.h"
#include "suit.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief fetch a payload from the filesystem
*
* @param[in] manifest suit manifest context
* @param[in] cb filesystem block callback
* @param[in] ctx callback context
*
* @returns SUIT_OK if valid
* @returns negative otherwise
*/
int suit_transport_vfs_fetch(const suit_manifest_t *manifest, coap_blockwise_cb_t cb, void *ctx);
#ifdef __cplusplus
}
#endif
#endif /* SUIT_TRANSPORT_VFS_H */
/** @} */

View File

@ -134,7 +134,7 @@ ifneq (,$(filter nimble_statconn,$(USEMODULE)))
SRC += sc_nimble_statconn.c
endif
ifneq (,$(filter suit_transport_coap,$(USEMODULE)))
ifneq (,$(filter suit_transport_worker,$(USEMODULE)))
SRC += sc_suit.c
endif

View File

@ -203,7 +203,7 @@ extern int _nimble_netif_handler(int argc, char **argv);
extern int _nimble_statconn_handler(int argc, char **argv);
#endif
#ifdef MODULE_SUIT_TRANSPORT_COAP
#ifdef MODULE_SUIT_TRANSPORT_WORKER
extern int _suit_handler(int argc, char **argv);
#endif
@ -382,7 +382,7 @@ const shell_command_t _shell_command_list[] = {
#ifdef MODULE_NIMBLE_STATCONN
{ "statconn", "NimBLE netif statconn", _nimble_statconn_handler},
#endif
#ifdef MODULE_SUIT_TRANSPORT_COAP
#ifdef MODULE_SUIT_TRANSPORT_WORKER
{ "suit", "Trigger a SUIT firmware update", _suit_handler },
#endif
#ifdef MODULE_CRYPTOAUTHLIB

View File

@ -39,10 +39,20 @@
#include "suit/transport/coap.h"
#include "net/nanocoap_sock.h"
#endif
#ifdef MODULE_SUIT_TRANSPORT_VFS
#include "suit/transport/vfs.h"
#endif
#include "suit/transport/mock.h"
#if defined(MODULE_PROGRESS_BAR)
#include "progress_bar.h"
#endif
#include "log.h"
#define ENABLE_DEBUG 0
#include "debug.h"
static int _get_component_size(suit_manifest_t *manifest,
suit_component_t *comp,
uint32_t *img_size)
@ -312,6 +322,74 @@ static int _start_storage(suit_manifest_t *manifest, suit_component_t *comp)
return suit_storage_start(comp->storage_backend, manifest, img_size);
}
static inline void _print_download_progress(suit_manifest_t *manifest,
size_t offset, size_t len,
size_t image_size)
{
(void)manifest;
(void)offset;
(void)len;
DEBUG("_suit_flashwrite(): writing %u bytes at pos %u\n", len, offset);
#if defined(MODULE_PROGRESS_BAR)
if (image_size != 0) {
char _suffix[7] = { 0 };
uint8_t _progress = 100 * (offset + len) / image_size;
sprintf(_suffix, " %3d%%", _progress);
progress_bar_print("Fetching firmware ", _suffix, _progress);
if (_progress == 100) {
puts("");
}
}
#else
(void) image_size;
#endif
}
#if defined(MODULE_SUIT_TRANSPORT_COAP) || defined(MODULE_SUIT_TRANSPORT_VFS)
static int _storage_helper(void *arg, size_t offset, uint8_t *buf, size_t len,
int more)
{
suit_manifest_t *manifest = (suit_manifest_t *)arg;
uint32_t image_size;
nanocbor_value_t param_size;
size_t total = offset + len;
suit_component_t *comp = &manifest->components[manifest->component_current];
suit_param_ref_t *ref_size = &comp->param_size;
/* Grab the total image size from the manifest */
if ((suit_param_ref_to_cbor(manifest, ref_size, &param_size) == 0) ||
(nanocbor_get_uint32(&param_size, &image_size) < 0)) {
/* Early exit if the total image size can't be determined */
return -1;
}
if (image_size < offset + len) {
/* Extra newline at the start to compensate for the progress bar */
LOG_ERROR(
"\n_suit_coap(): Image beyond size, offset + len=%u, "
"image_size=%u\n", (unsigned)(total), (unsigned)image_size);
return -1;
}
if (!more && image_size != total) {
LOG_INFO("Incorrect size received, got %u, expected %u\n",
(unsigned)total, (unsigned)image_size);
return -1;
}
_print_download_progress(manifest, offset, len, image_size);
int res = suit_storage_write(comp->storage_backend, manifest, buf, offset, len);
if (!more) {
LOG_INFO("Finalizing payload store\n");
/* Finalize the write if no more data available */
res = suit_storage_finish(comp->storage_backend, manifest);
}
return res;
}
#endif
static int _dtv_fetch(suit_manifest_t *manifest, int key,
nanocbor_value_t *_it)
{
@ -343,6 +421,8 @@ static int _dtv_fetch(suit_manifest_t *manifest, int key,
LOG_DEBUG("URL parsing failed\n)");
return err;
}
assert(manifest->urlbuf && url_len < manifest->urlbuf_len);
memcpy(manifest->urlbuf, url, url_len);
manifest->urlbuf[url_len] = '\0';
@ -360,7 +440,7 @@ static int _dtv_fetch(suit_manifest_t *manifest, int key,
#ifdef MODULE_SUIT_TRANSPORT_COAP
else if (strncmp(manifest->urlbuf, "coap://", 7) == 0) {
res = nanocoap_get_blockwise_url(manifest->urlbuf, CONFIG_SUIT_COAP_BLOCKSIZE,
suit_storage_helper,
_storage_helper,
manifest);
}
#endif
@ -368,6 +448,11 @@ static int _dtv_fetch(suit_manifest_t *manifest, int key,
else if (strncmp(manifest->urlbuf, "test://", 7) == 0) {
res = suit_transport_mock_fetch(manifest);
}
#endif
#ifdef MODULE_SUIT_TRANSPORT_VFS
else if (strncmp(manifest->urlbuf, "file://", 7) == 0) {
res = suit_transport_vfs_fetch(manifest, _storage_helper, manifest);
}
#endif
else {
LOG_WARNING("suit: unsupported URL scheme!\n)");

View File

@ -22,209 +22,16 @@
* @}
*/
#include <assert.h>
#include <inttypes.h>
#include <string.h>
#include "msg.h"
#include "log.h"
#include "suit.h"
#include "net/nanocoap.h"
#include "net/nanocoap_sock.h"
#include "thread.h"
#include "periph/pm.h"
#include "ztimer.h"
#include "suit/transport/coap.h"
#include "net/sock/util.h"
#include "kernel_defines.h"
#ifdef MODULE_RIOTBOOT_SLOT
#include "riotboot/slot.h"
#endif
#ifdef MODULE_SUIT
#include "suit.h"
#include "suit/handlers.h"
#include "suit/storage.h"
#endif
#if defined(MODULE_PROGRESS_BAR)
#include "progress_bar.h"
#endif
#define ENABLE_DEBUG 0
#include "debug.h"
#ifndef SUIT_COAP_STACKSIZE
/* allocate stack needed to do manifest validation */
#define SUIT_COAP_STACKSIZE (3 * THREAD_STACKSIZE_LARGE)
#endif
#ifndef SUIT_COAP_PRIO
#define SUIT_COAP_PRIO THREAD_PRIORITY_MAIN - 1
#endif
#ifndef SUIT_URL_MAX
#define SUIT_URL_MAX 128
#endif
#ifndef SUIT_MANIFEST_BUFSIZE
#define SUIT_MANIFEST_BUFSIZE 640
#endif
#define SUIT_MSG_TRIGGER 0x12345
static char _stack[SUIT_COAP_STACKSIZE];
static char _url[SUIT_URL_MAX];
static uint8_t _manifest_buf[SUIT_MANIFEST_BUFSIZE];
#ifdef MODULE_SUIT
static inline void _print_download_progress(suit_manifest_t *manifest,
size_t offset, size_t len,
size_t image_size)
{
(void)manifest;
(void)offset;
(void)len;
DEBUG("_suit_flashwrite(): writing %u bytes at pos %u\n", len, offset);
#if defined(MODULE_PROGRESS_BAR)
if (image_size != 0) {
char _suffix[7] = { 0 };
uint8_t _progress = 100 * (offset + len) / image_size;
sprintf(_suffix, " %3d%%", _progress);
progress_bar_print("Fetching firmware ", _suffix, _progress);
if (_progress == 100) {
puts("");
}
}
#else
(void) image_size;
#endif
}
#endif
static kernel_pid_t _suit_coap_pid;
static void _suit_handle_url(const char *url, coap_blksize_t blksize)
{
LOG_INFO("suit_coap: downloading \"%s\"\n", url);
ssize_t size = nanocoap_get_blockwise_url_to_buf(url, blksize,
_manifest_buf,
SUIT_MANIFEST_BUFSIZE);
if (size >= 0) {
LOG_INFO("suit_coap: got manifest with size %u\n", (unsigned)size);
#ifdef MODULE_SUIT
suit_manifest_t manifest;
memset(&manifest, 0, sizeof(manifest));
manifest.urlbuf = _url;
manifest.urlbuf_len = SUIT_URL_MAX;
int res;
if ((res = suit_parse(&manifest, _manifest_buf, size)) != SUIT_OK) {
LOG_INFO("suit_parse() failed. res=%i\n", res);
return;
}
#endif
#ifdef MODULE_SUIT_STORAGE_FLASHWRITE
if (res == 0) {
const riotboot_hdr_t *hdr = riotboot_slot_get_hdr(
riotboot_slot_other());
riotboot_hdr_print(hdr);
ztimer_sleep(ZTIMER_MSEC, 1 * MS_PER_SEC);
if (riotboot_hdr_validate(hdr) == 0) {
LOG_INFO("suit_coap: rebooting...\n");
pm_reboot();
}
else {
LOG_INFO("suit_coap: update failed, hdr invalid\n ");
}
}
#endif
}
else {
LOG_INFO("suit_coap: error getting manifest\n");
}
}
int suit_storage_helper(void *arg, size_t offset, uint8_t *buf, size_t len,
int more)
{
suit_manifest_t *manifest = (suit_manifest_t *)arg;
uint32_t image_size;
nanocbor_value_t param_size;
size_t total = offset + len;
suit_component_t *comp = &manifest->components[manifest->component_current];
suit_param_ref_t *ref_size = &comp->param_size;
/* Grab the total image size from the manifest */
if ((suit_param_ref_to_cbor(manifest, ref_size, &param_size) == 0) ||
(nanocbor_get_uint32(&param_size, &image_size) < 0)) {
/* Early exit if the total image size can't be determined */
return -1;
}
if (image_size < offset + len) {
/* Extra newline at the start to compensate for the progress bar */
LOG_ERROR(
"\n_suit_coap(): Image beyond size, offset + len=%u, "
"image_size=%u\n", (unsigned)(total), (unsigned)image_size);
return -1;
}
if (!more && image_size != total) {
LOG_INFO("Incorrect size received, got %u, expected %u\n",
(unsigned)total, (unsigned)image_size);
return -1;
}
_print_download_progress(manifest, offset, len, image_size);
int res = suit_storage_write(comp->storage_backend, manifest, buf, offset, len);
if (!more) {
LOG_INFO("Finalizing payload store\n");
/* Finalize the write if no more data available */
res = suit_storage_finish(comp->storage_backend, manifest);
}
return res;
}
static void *_suit_coap_thread(void *arg)
{
(void)arg;
LOG_INFO("suit_coap: started.\n");
msg_t msg_queue[4];
msg_init_queue(msg_queue, 4);
_suit_coap_pid = thread_getpid();
msg_t m;
while (true) {
msg_receive(&m);
DEBUG("suit_coap: got msg with type %" PRIu32 "\n", m.content.value);
switch (m.content.value) {
case SUIT_MSG_TRIGGER:
LOG_INFO("suit_coap: trigger received\n");
_suit_handle_url(_url, CONFIG_SUIT_COAP_BLOCKSIZE);
break;
default:
LOG_WARNING("suit_coap: warning: unhandled msg\n");
}
}
return NULL;
}
void suit_coap_run(void)
{
thread_create(_stack, SUIT_COAP_STACKSIZE, SUIT_COAP_PRIO,
THREAD_CREATE_STACKTEST,
_suit_coap_thread, NULL, "suit_coap");
}
static ssize_t _version_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len,
void *context)
{
@ -233,6 +40,30 @@ static ssize_t _version_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len,
COAP_FORMAT_TEXT, (uint8_t *)"NONE", 4);
}
static ssize_t _trigger_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len,
void *context)
{
(void)context;
unsigned code;
size_t payload_len = pkt->payload_len;
if (payload_len) {
if (payload_len >= CONFIG_SOCK_URLPATH_MAXLEN) {
code = COAP_CODE_REQUEST_ENTITY_TOO_LARGE;
}
else {
code = COAP_CODE_CREATED;
LOG_INFO("suit: received URL: \"%s\"\n", (char *)pkt->payload);
suit_coap_trigger(pkt->payload, payload_len);
}
}
else {
code = COAP_CODE_REQUEST_ENTITY_INCOMPLETE;
}
return coap_reply_simple(pkt, code, buf, len,
COAP_FORMAT_NONE, NULL, 0);
}
#ifdef MODULE_RIOTBOOT_SLOT
static ssize_t _slot_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len,
void *context)
@ -252,45 +83,12 @@ static ssize_t _slot_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len,
}
#endif
static ssize_t _trigger_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len,
void *context)
{
(void)context;
unsigned code;
size_t payload_len = pkt->payload_len;
if (payload_len) {
if (payload_len >= SUIT_URL_MAX) {
code = COAP_CODE_REQUEST_ENTITY_TOO_LARGE;
}
else {
code = COAP_CODE_CREATED;
LOG_INFO("suit: received URL: \"%s\"\n", (char *)pkt->payload);
suit_coap_trigger(pkt->payload, payload_len);
}
}
else {
code = COAP_CODE_REQUEST_ENTITY_INCOMPLETE;
}
return coap_reply_simple(pkt, code, buf, len,
COAP_FORMAT_NONE, NULL, 0);
}
void suit_coap_trigger(const uint8_t *url, size_t len)
{
memcpy(_url, url, len);
_url[len] = '\0';
msg_t m = { .content.value = SUIT_MSG_TRIGGER };
msg_send(&m, _suit_coap_pid);
}
static const coap_resource_t _subtree[] = {
#ifdef MODULE_RIOTBOOT_SLOT
{ "/suit/slot/active", COAP_METHOD_GET, _slot_handler, NULL },
{ "/suit/slot/inactive", COAP_METHOD_GET, _slot_handler, (void *)0x1 },
#endif
{ "/suit/trigger", COAP_METHOD_PUT | COAP_METHOD_POST, _trigger_handler,
NULL },
{ "/suit/trigger", COAP_METHOD_PUT | COAP_METHOD_POST, _trigger_handler, NULL },
{ "/suit/version", COAP_METHOD_GET, _version_handler, NULL },
};

61
sys/suit/transport/vfs.c Normal file
View File

@ -0,0 +1,61 @@
/*
* Copyright (C) 2022 ML!PA Consulting GmbH
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup sys_suit_transport_vfs
* @{
*
* @fil
* @brief SUIT VFS
*
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com>
* @}
*/
#include <fcntl.h>
#include <string.h>
#include "suit/transport/vfs.h"
#include "log.h"
#include "vfs.h"
int suit_transport_vfs_fetch(const suit_manifest_t *manifest, coap_blockwise_cb_t cb, void *ctx)
{
const char *file = &manifest->urlbuf[7];
size_t offset = 0;
int res, fd;
LOG_DEBUG("suit_vfs: read firmware from %s\n", file);
fd = vfs_open(file, O_RDONLY, 0);
if (fd < 0) {
return fd;
}
void *buf = manifest->urlbuf;
size_t max_len = manifest->urlbuf_len;
while ((res = vfs_read(fd, buf, max_len)) > 0) {
size_t len = res;
res = cb(ctx, offset, buf, len, 1);
if (res < 0) {
LOG_ERROR("suit_vfs: write failed with %d\n", res);
break;
}
offset += len;
}
if (res < 0) {
LOG_ERROR("suit_vfs: read failed with %d\n", res);
} else {
res = cb(ctx, offset, buf, 0, 0);
}
vfs_close(fd);
return res;
}

186
sys/suit/transport/worker.c Normal file
View File

@ -0,0 +1,186 @@
/*
* Copyright (C) 2019 Freie Universität Berlin
* 2019 Inria
* 2019 Kaspar Schleiser <kaspar@schleiser.de>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup sys_suit
* @{
*
* @file
* @brief SUIT transport worker thread
*
* @author Koen Zandberg <koen@bergzand.net>
* @author Kaspar Schleiser <kaspar@schleiser.de>
* @author Francisco Molina <francois-xavier.molina@inria.fr>
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
* @}
*/
#include <assert.h>
#include <inttypes.h>
#include <string.h>
#include <sys/types.h>
#include "msg.h"
#include "log.h"
#include "thread.h"
#include "time_units.h"
#include "periph/pm.h"
#include "ztimer.h"
#ifdef MODULE_SUIT_TRANSPORT_COAP
#include "net/nanocoap_sock.h"
#include "suit/transport/coap.h"
#include "net/sock/util.h"
#endif
#ifdef MODULE_SUIT_TRANSPORT_VFS
#include "vfs_util.h"
#endif
#ifdef MODULE_RIOTBOOT_SLOT
#include "riotboot/slot.h"
#endif
#ifdef MODULE_SUIT
#include "suit.h"
#include "suit/handlers.h"
#include "suit/storage.h"
#endif
#if defined(MODULE_PROGRESS_BAR)
#include "progress_bar.h"
#endif
#define ENABLE_DEBUG 0
#include "debug.h"
#ifndef SUIT_WORKER_STACKSIZE
/* allocate stack needed to do manifest validation */
#define SUIT_WORKER_STACKSIZE (3 * THREAD_STACKSIZE_LARGE)
#endif
#ifndef SUIT_COAP_WORKER_PRIO
#define SUIT_COAP_WORKER_PRIO THREAD_PRIORITY_MAIN - 1
#endif
#ifndef SUIT_MANIFEST_BUFSIZE
#define SUIT_MANIFEST_BUFSIZE 640
#endif
#define SUIT_MSG_TRIGGER 0x12345
static char _stack[SUIT_WORKER_STACKSIZE];
static char _url[CONFIG_SOCK_URLPATH_MAXLEN];
static uint8_t _manifest_buf[SUIT_MANIFEST_BUFSIZE];
static kernel_pid_t _suit_worker_pid;
static void _suit_handle_url(const char *url)
{
ssize_t size;
LOG_INFO("suit_worker: downloading \"%s\"\n", url);
if (0) {}
#ifdef MODULE_SUIT_TRANSPORT_COAP
else if (strncmp(url, "coap://", 7) == 0) {
size = nanocoap_get_blockwise_url_to_buf(url,
CONFIG_SUIT_COAP_BLOCKSIZE,
_manifest_buf,
sizeof(_manifest_buf));
}
#endif
#ifdef MODULE_SUIT_TRANSPORT_VFS
else if (strncmp(url, "file://", 7) == 0) {
size = vfs_file_to_buffer(&url[7], _manifest_buf, sizeof(_manifest_buf));
}
#endif
else {
LOG_WARNING("suit_worker: unsupported URL scheme!\n)");
return;
}
if (size >= 0) {
LOG_INFO("suit_worker: got manifest with size %u\n", (unsigned)size);
#ifdef MODULE_SUIT
suit_manifest_t manifest;
memset(&manifest, 0, sizeof(manifest));
manifest.urlbuf = _url;
manifest.urlbuf_len = CONFIG_SOCK_URLPATH_MAXLEN;
int res;
if ((res = suit_parse(&manifest, _manifest_buf, size)) != SUIT_OK) {
LOG_INFO("suit_worker: suit_parse() failed. res=%i\n", res);
return;
}
#endif
#ifdef MODULE_SUIT_STORAGE_FLASHWRITE
if (res == 0) {
const riotboot_hdr_t *hdr = riotboot_slot_get_hdr(
riotboot_slot_other());
riotboot_hdr_print(hdr);
ztimer_sleep(ZTIMER_MSEC, 1 * MS_PER_SEC);
if (riotboot_hdr_validate(hdr) == 0) {
LOG_INFO("suit_worker: rebooting...\n");
pm_reboot();
}
else {
LOG_INFO("suit_worker: update failed, hdr invalid\n ");
}
}
#endif
}
else {
LOG_INFO("suit_worker: error getting manifest\n");
}
}
static void *_suit_worker_thread(void *arg)
{
(void)arg;
LOG_INFO("suit_worker: started.\n");
msg_t msg_queue[4];
msg_init_queue(msg_queue, 4);
_suit_worker_pid = thread_getpid();
msg_t m;
while (true) {
msg_receive(&m);
DEBUG("suit_worker: got msg with type %" PRIu32 "\n", m.content.value);
switch (m.content.value) {
case SUIT_MSG_TRIGGER:
LOG_INFO("suit_worker: trigger received\n");
_suit_handle_url(_url);
break;
default:
LOG_WARNING("suit_worker: warning: unhandled msg\n");
}
}
return NULL;
}
void suit_coap_run(void)
{
thread_create(_stack, SUIT_WORKER_STACKSIZE, SUIT_COAP_WORKER_PRIO,
THREAD_CREATE_STACKTEST,
_suit_worker_thread, NULL, "suit worker");
}
void suit_coap_trigger(const uint8_t *url, size_t len)
{
memcpy(_url, url, len);
_url[len] = '\0';
msg_t m = { .content.value = SUIT_MSG_TRIGGER };
msg_send(&m, _suit_worker_pid);
}

View File

@ -38,7 +38,6 @@
#include TEST_MANIFEST_INCLUDE(file1.bin.h)
#include TEST_MANIFEST_INCLUDE(file2.bin.h)
#define SUIT_URL_MAX 128
typedef struct {
const unsigned char *data;
@ -73,13 +72,13 @@ const size_t num_payloads = ARRAY_SIZE(payloads);
static int test_suit_manifest(const unsigned char *manifest_bin,
size_t manifest_bin_len)
{
char _url[SUIT_URL_MAX];
char _url[CONFIG_SOCK_URLPATH_MAXLEN];
suit_manifest_t manifest;
memset(&manifest, 0, sizeof(manifest));
manifest.urlbuf = _url;
manifest.urlbuf_len = SUIT_URL_MAX;
manifest.urlbuf_len = CONFIG_SOCK_URLPATH_MAXLEN;
int res;
if ((res =