From 2c716d3edeec03ba09138ef4c31ff79dc58acb90 Mon Sep 17 00:00:00 2001 From: chrysn Date: Wed, 25 Jan 2023 18:01:14 +0100 Subject: [PATCH 1/4] sys/suit: Ensure previous thread is stopped before reusing its stack Closes: https://github.com/RIOT-OS/RIOT/issues/19195 --- sys/suit/transport/worker.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sys/suit/transport/worker.c b/sys/suit/transport/worker.c index a54022fb28..a1659eaab5 100644 --- a/sys/suit/transport/worker.c +++ b/sys/suit/transport/worker.c @@ -79,6 +79,8 @@ static char _url[CONFIG_SOCK_URLPATH_MAXLEN]; static uint8_t _manifest_buf[SUIT_MANIFEST_BUFSIZE]; static mutex_t _worker_lock; +/* PID of the worker thread, guarded by */ +static kernel_pid_t _worker_pid = KERNEL_PID_UNDEF; int suit_handle_url(const char *url) { @@ -154,17 +156,27 @@ static void *_suit_worker_thread(void *arg) } mutex_unlock(&_worker_lock); + thread_zombify(); + /* Actually unreachable, given we're in a thread */ return NULL; } void suit_worker_trigger(const char *url, size_t len) { mutex_lock(&_worker_lock); + if (_worker_pid != KERNEL_PID_UNDEF) { + if (thread_kill_zombie(_worker_pid) != 1) { + /* This will only happen if the SUIT thread runs on a lower + * priority than the caller */ + LOG_WARNING("Ignoring SUIT trigger: worker is still busy.\n"); + return; + } + } memcpy(_url, url, len); _url[len] = '\0'; - thread_create(_stack, SUIT_WORKER_STACKSIZE, SUIT_COAP_WORKER_PRIO, + _worker_pid = thread_create(_stack, SUIT_WORKER_STACKSIZE, SUIT_COAP_WORKER_PRIO, THREAD_CREATE_STACKTEST, _suit_worker_thread, NULL, "suit worker"); } From acf2074369d4cefb7552a27ab303fea9c2e6a5ad Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 27 Jan 2023 18:01:00 +0100 Subject: [PATCH 2/4] examples/gnrc_border_router: static: use router from advertisements by default --- examples/gnrc_border_router/Makefile | 3 ++- sys/net/gnrc/network_layer/ipv6/static_addr/Kconfig | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gnrc_border_router/Makefile b/examples/gnrc_border_router/Makefile index b234885b76..a0e8d59f6d 100644 --- a/examples/gnrc_border_router/Makefile +++ b/examples/gnrc_border_router/Makefile @@ -64,7 +64,8 @@ else ifeq (auto_subnets,$(PREFIX_CONF)) USEMODULE += gnrc_ipv6_auto_subnets_simple else ifeq (static,$(PREFIX_CONF)) IPV6_ADDR ?= 2001:db8:1::1 - IPV6_DEFAULT_ROUTER ?= fe80::1 +# Only set this if the default router does not send router advertisements +# IPV6_DEFAULT_ROUTER ?= fe80::1 USEMODULE += gnrc_ipv6_static_addr endif diff --git a/sys/net/gnrc/network_layer/ipv6/static_addr/Kconfig b/sys/net/gnrc/network_layer/ipv6/static_addr/Kconfig index 450fca1652..539682dd25 100644 --- a/sys/net/gnrc/network_layer/ipv6/static_addr/Kconfig +++ b/sys/net/gnrc/network_layer/ipv6/static_addr/Kconfig @@ -30,6 +30,5 @@ config GNRC_IPV6_STATIC_ADDR_DOWNSTREAM config GNRC_IPV6_STATIC_DEFAULT_ROUTER string "Static IPv6 address of the default router" - default "2001:db8::1" endif # KCONFIG_USEMODULE_GNRC_IPV6_STATIC_ADDR From ff52d3558470f783bde927058206e9fb10015ce5 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 27 Jan 2023 19:10:20 +0100 Subject: [PATCH 3/4] gnrc_ipv6_nib: use static DNS server from auto_init_sock_dns if present --- examples/gnrc_border_router/Makefile | 5 +++++ sys/net/gnrc/network_layer/ipv6/nib/_nib-router.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/gnrc_border_router/Makefile b/examples/gnrc_border_router/Makefile index a0e8d59f6d..d9e3929e32 100644 --- a/examples/gnrc_border_router/Makefile +++ b/examples/gnrc_border_router/Makefile @@ -67,6 +67,11 @@ else ifeq (static,$(PREFIX_CONF)) # Only set this if the default router does not send router advertisements # IPV6_DEFAULT_ROUTER ?= fe80::1 USEMODULE += gnrc_ipv6_static_addr + + # configure static DNS server + ifneq (,$(filter sock_dns,$(USEMODULE))) + USEMODULE += auto_init_sock_dns + endif endif # Comment this out to disable code in RIOT that does safety checking diff --git a/sys/net/gnrc/network_layer/ipv6/nib/_nib-router.c b/sys/net/gnrc/network_layer/ipv6/nib/_nib-router.c index c7b15e5beb..4a61df12bd 100644 --- a/sys/net/gnrc/network_layer/ipv6/nib/_nib-router.c +++ b/sys/net/gnrc/network_layer/ipv6/nib/_nib-router.c @@ -155,7 +155,8 @@ static gnrc_pktsnip_t *_build_ext_opts(gnrc_netif_t *netif, uint32_t rdnss_ltime = _evtimer_lookup(&sock_dns_server, GNRC_IPV6_NIB_RDNSS_TIMEOUT); - if ((rdnss_ltime < UINT32_MAX) && + /* with auto_init_sock_dns we always have a valid (static) DNS server */ + if (((rdnss_ltime < UINT32_MAX) || IS_USED(MODULE_AUTO_INIT_SOCK_DNS)) && (!ipv6_addr_is_link_local((ipv6_addr_t *)sock_dns_server.addr.ipv6))) { gnrc_pktsnip_t *rdnsso = gnrc_ndp_opt_rdnss_build( rdnss_ltime * MS_PER_SEC, From 162d06a9bda0e36e5df34ce475a7943e020b14bd Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 27 Jan 2023 12:07:21 +0100 Subject: [PATCH 4/4] boards/common: add common timer config for GD32VF103 boards --- boards/common/gd32v/include/board_common.h | 40 ++++++++++++++++++++++ boards/seeedstudio-gd32/include/board.h | 2 ++ boards/sipeed-longan-nano/include/board.h | 2 ++ 3 files changed, 44 insertions(+) create mode 100644 boards/common/gd32v/include/board_common.h diff --git a/boards/common/gd32v/include/board_common.h b/boards/common/gd32v/include/board_common.h new file mode 100644 index 0000000000..412b9b5d91 --- /dev/null +++ b/boards/common/gd32v/include/board_common.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2020 Koen Zandberg + * 2023 Gunar Schorcht + * + * 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 boards_common_gd32v + * @{ + * + * @file + * @brief Common board definitions for GD32VF103 boards + * + * @author Koen Zandberg + * @author Gunar Schorcht + */ + +#ifndef BOARD_COMMON_H +#define BOARD_COMMON_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Xtimer configuration + * @{ + */ +#define XTIMER_WIDTH (16) +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* BOARD_COMMON_H */ +/** @} */ diff --git a/boards/seeedstudio-gd32/include/board.h b/boards/seeedstudio-gd32/include/board.h index ac87e0d25d..c48afec589 100644 --- a/boards/seeedstudio-gd32/include/board.h +++ b/boards/seeedstudio-gd32/include/board.h @@ -21,6 +21,8 @@ #ifndef BOARD_H #define BOARD_H +#include "board_common.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/boards/sipeed-longan-nano/include/board.h b/boards/sipeed-longan-nano/include/board.h index ee61783002..f72ca46cdb 100644 --- a/boards/sipeed-longan-nano/include/board.h +++ b/boards/sipeed-longan-nano/include/board.h @@ -20,6 +20,8 @@ #ifndef BOARD_H #define BOARD_H +#include "board_common.h" + #ifdef __cplusplus extern "C" { #endif