diff --git a/makefiles/pseudomodules.inc.mk b/makefiles/pseudomodules.inc.mk index e71195bf85..c26a8776cd 100644 --- a/makefiles/pseudomodules.inc.mk +++ b/makefiles/pseudomodules.inc.mk @@ -64,7 +64,6 @@ PSEUDOMODULES += event_% PSEUDOMODULES += event_timeout PSEUDOMODULES += event_timeout_ztimer PSEUDOMODULES += evtimer_mbox -PSEUDOMODULES += evtimer_on_ztimer PSEUDOMODULES += fatfs_vfs_format PSEUDOMODULES += fmt_% PSEUDOMODULES += gcoap_forward_proxy diff --git a/sys/Kconfig b/sys/Kconfig index 6a505b70e9..fc11536036 100644 --- a/sys/Kconfig +++ b/sys/Kconfig @@ -74,6 +74,8 @@ choice LOG endchoice rsource "coding/Kconfig" +rsource "ecc/Kconfig" +rsource "evtimer/Kconfig" rsource "log_color/Kconfig" rsource "log_printfnoformat/Kconfig" rsource "luid/Kconfig" @@ -85,6 +87,7 @@ rsource "net/Kconfig" rsource "od/Kconfig" rsource "oneway-malloc/Kconfig" rsource "phydat/Kconfig" +rsource "pipe/Kconfig" rsource "pm_layered/Kconfig" rsource "posix/Kconfig" rsource "preprocessor/Kconfig" @@ -100,6 +103,7 @@ rsource "sema_inv/Kconfig" rsource "senml/Kconfig" rsource "seq/Kconfig" rsource "shell/Kconfig" +rsource "shell_lock/Kconfig" rsource "ssp/Kconfig" rsource "test_utils/Kconfig" rsource "timex/Kconfig" diff --git a/sys/Makefile.dep b/sys/Makefile.dep index b8a0dd8b11..b27127765e 100644 --- a/sys/Makefile.dep +++ b/sys/Makefile.dep @@ -998,14 +998,7 @@ ifneq (,$(filter ztimer64%,$(USEMODULE))) endif ifneq (,$(filter evtimer,$(USEMODULE))) - ifneq (,$(filter evtimer_on_ztimer,$(USEMODULE))) - USEMODULE += ztimer_msec - else - USEMODULE += xtimer - ifneq (,$(filter ztimer_xtimer_compat,$(USEMODULE))) - USEMODULE += evtimer_on_ztimer - endif - endif + USEMODULE += ztimer_msec endif # handle xtimer's deps. Needs to be done *after* ztimer diff --git a/sys/ecc/Kconfig b/sys/ecc/Kconfig new file mode 100644 index 0000000000..3e257fa863 --- /dev/null +++ b/sys/ecc/Kconfig @@ -0,0 +1,35 @@ +# Copyright (c) 2023 Inria +# +# 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. +# + +menuconfig MODULE_ECC + bool "Error Correction Code (ECC) algorithms" + depends on TEST_KCONFIG + help + Provides Golay1412, Hamming256 and Repetition algorithms. + +if MODULE_ECC + +menu "ECC algorithms" + +config MODULE_ECC_GOLAY1412 + bool "Golay1412 Error Correction Code (ECC) algorithm" + help + Provides Golay1412 ECC algorithm. + +config MODULE_ECC_HAMMING256 + bool "Hamming256 Error Correction Code (ECC) algorithm" + help + Provides Hamming256 ECC algorithm. + +config MODULE_ECC_REPETITION + bool "Repetition Error Correction Code (ECC) algorithm" + help + Provides Repetition ECC algorithm. + +endmenu # ECC algorithms + +endif diff --git a/sys/evtimer/Kconfig b/sys/evtimer/Kconfig new file mode 100644 index 0000000000..8cbe1cea3b --- /dev/null +++ b/sys/evtimer/Kconfig @@ -0,0 +1,19 @@ +# Copyright (c) 2023 Inria +# +# 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. +# + +config MODULE_EVTIMER + bool "Event timer module" + depends on TEST_KCONFIG + select MODULE_ZTIMER + select MODULE_ZTIMER_MSEC + +config MODULE_EVTIMER_MBOX + bool "Use message box" + select MODULE_CORE_MBOX + select MODULE_EVTIMER + help + Use message box to implement event timer. diff --git a/sys/evtimer/evtimer.c b/sys/evtimer/evtimer.c index 4821336d37..a8f8132446 100644 --- a/sys/evtimer/evtimer.c +++ b/sys/evtimer/evtimer.c @@ -93,19 +93,9 @@ static void _del_event_from_list(evtimer_t *evtimer, evtimer_event_t *event) static void _set_timer(evtimer_t *evtimer) { evtimer_event_t *next_event = evtimer->events; - -#if IS_USED(MODULE_EVTIMER_ON_ZTIMER) evtimer->base = ztimer_set(ZTIMER_MSEC, &evtimer->timer, next_event->offset); DEBUG("evtimer: now=%" PRIu32 " ms setting ztimer to %" PRIu32 " ms\n", evtimer->base, next_event->offset); -#else - uint64_t offset_us = (uint64_t)next_event->offset * US_PER_MS; - - DEBUG("evtimer: now=%" PRIu32 " us setting xtimer to %" PRIu32 ":%" PRIu32 " us\n", - xtimer_now_usec(), (uint32_t)(offset_us >> 32), (uint32_t)(offset_us)); - - xtimer_set64(&evtimer->timer, offset_us); -#endif } static void _update_timer(evtimer_t *evtimer) @@ -114,15 +104,10 @@ static void _update_timer(evtimer_t *evtimer) _set_timer(evtimer); } else { -#if IS_USED(MODULE_EVTIMER_ON_ZTIMER) ztimer_remove(ZTIMER_MSEC, &evtimer->timer); -#else - xtimer_remove(&evtimer->timer); -#endif } } -#if IS_USED(MODULE_EVTIMER_ON_ZTIMER) static void _update_head_offset(evtimer_t *evtimer) { if (evtimer->events) { @@ -137,23 +122,6 @@ static void _update_head_offset(evtimer_t *evtimer) evtimer->base = now; } } -#else /* IS_USED(MODULE_EVTIMER_ON_ZTIMER) */ -static uint32_t _get_offset(xtimer_t *timer) -{ - uint64_t left = xtimer_left_usec(timer); - /* add half of 125 so integer division rounds to nearest */ - return div_u64_by_125((left >> 3) + 62); -} - -static void _update_head_offset(evtimer_t *evtimer) -{ - if (evtimer->events) { - evtimer_event_t *event = evtimer->events; - event->offset = _get_offset(&evtimer->timer); - DEBUG("evtimer: _update_head_offset(): new head offset %" PRIu32 "\n", event->offset); - } -} -#endif /* !IS_USED(MODULE_EVTIMER_ON_ZTIMER) */ void evtimer_add(evtimer_t *evtimer, evtimer_event_t *event) { diff --git a/sys/include/evtimer.h b/sys/include/evtimer.h index 66ff0a5d4b..28844200c2 100644 --- a/sys/include/evtimer.h +++ b/sys/include/evtimer.h @@ -15,24 +15,20 @@ * * @note Experimental and likely to replaced with unified timer API * - * RIOT's main timer subsystem is @ref sys_xtimer "xtimer", but for many - * applications @ref sys_xtimer "xtimer's" 64-bit absolute time values are - * wasteful or clumsy to use. - * - * Compared to @ref sys_xtimer "xtimer", evtimer offers: + * RIOT's main timer subsystem is @ref sys_ztimer "ztimer" but compared to + * @ref sys_ztimer "ztimer", evtimer offers: * * - only relative 32-bit millisecond timer values * Events can be scheduled with a relative offset of up to ~49.7 days in the * future. - * **For time-critical stuff, use @ref sys_xtimer "xtimer"!** + * **For time-critical stuff, use @ref sys_ztimer "ztimer"!** * - more flexible, "intrusive" timer type @ref evtimer_event_t only contains * the necessary fields, which can be extended as needed, and handlers define * actions taken on timer triggers. Check out @ref evtimer_msg_event_t as * example. - * - uses @ref sys_xtimer "xtimer" as backend by default. Alternatively, with - * the pseudomodule "evtimer_on_ztimer" compiled in, evtimer is backend by - * @ref sys_ztimer "ZTIMER_MSEC". - * + * - when a number of timeouts with the same callback function need to be + * scheduled, evtimer is using less RAM (due to storing the callback function + * only once), while each ztimer has a function pointer for the callback. * @{ * * @file @@ -48,13 +44,7 @@ #include #include "modules.h" -#if IS_USED(MODULE_EVTIMER_ON_ZTIMER) #include "ztimer.h" -#else -#include "xtimer.h" -#endif - -#include "timex.h" #ifdef __cplusplus extern "C" { @@ -77,12 +67,8 @@ typedef void(*evtimer_callback_t)(evtimer_event_t* event); * @brief Event timer */ typedef struct { -#if IS_USED(MODULE_EVTIMER_ON_ZTIMER) ztimer_t timer; /**< Timer */ uint32_t base; /**< Absolute time the first event is built on */ -#else - xtimer_t timer; /**< Timer */ -#endif evtimer_callback_t callback; /**< Handler function for this evtimer's event type */ evtimer_event_t *events; /**< Event queue */ @@ -128,11 +114,7 @@ void evtimer_print(const evtimer_t *evtimer); */ static inline uint32_t evtimer_now_msec(void) { -#if IS_USED(MODULE_EVTIMER_ON_ZTIMER) return ztimer_now(ZTIMER_MSEC); -#else - return xtimer_now_usec64() / US_PER_MS; -#endif } #ifdef __cplusplus diff --git a/sys/include/net/gnrc/ipv6/nib/abr.h b/sys/include/net/gnrc/ipv6/nib/abr.h index 32747c89ac..fbba10b4ea 100644 --- a/sys/include/net/gnrc/ipv6/nib/abr.h +++ b/sys/include/net/gnrc/ipv6/nib/abr.h @@ -26,6 +26,7 @@ /* prevent cascading include error to xtimer if it is not compiled in or not * supported by board */ #if IS_USED(MODULE_EVTIMER) +#include "timex.h" #include "evtimer.h" #endif #include "net/ipv6/addr.h" diff --git a/sys/include/shell.h b/sys/include/shell.h index 3ef67822a5..ac8c808d38 100644 --- a/sys/include/shell.h +++ b/sys/include/shell.h @@ -50,7 +50,7 @@ extern "C" { * Instead terminate RIOT, which is also the behavior a user would * expect from a CLI application. */ -# if defined(CPU_NATIVE) && !IS_ACTIVE(KCONFIG_USEMODULE_SHELL) +# if defined(CPU_NATIVE) # define CONFIG_SHELL_SHUTDOWN_ON_EXIT 1 # else # define CONFIG_SHELL_SHUTDOWN_ON_EXIT 0 diff --git a/sys/pipe/Kconfig b/sys/pipe/Kconfig new file mode 100644 index 0000000000..3cde3abf76 --- /dev/null +++ b/sys/pipe/Kconfig @@ -0,0 +1,12 @@ +# Copyright (c) 2023 Inria +# +# 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. +# + +config MODULE_PIPE + bool "Statically allocated pipes" + depends on TEST_KCONFIG + help + Implementation for statically allocated pipes. diff --git a/sys/shell_lock/Kconfig b/sys/shell_lock/Kconfig new file mode 100644 index 0000000000..db54920df8 --- /dev/null +++ b/sys/shell_lock/Kconfig @@ -0,0 +1,29 @@ +# Copyright (c) 2023 Inria +# +# 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. +# + +menuconfig MODULE_SHELL_LOCK + bool "Shell Locking module" + depends on TEST_KCONFIG + select MODULE_ZTIMER + select MODULE_ZTIMER_MSEC + +if MODULE_SHELL_LOCK + +config SHELL_LOCK_PASSWORD + string "Lock password" + default "password" + +config SHELL_LOCK_AUTO_LOCK_TIMEOUT_MS + int "Timeout in ms before automatic locking" + default 7000 + +endif # MODULE_SHELL_LOCK + +config MODULE_SHELL_LOCK_AUTO_LOCKING + bool "Automatic locking of the shell" + depends on TEST_KCONFIG + select MODULE_SHELL_LOCK diff --git a/sys/ztimer/Makefile.dep b/sys/ztimer/Makefile.dep index eec51b70b0..e20ba7e2a7 100644 --- a/sys/ztimer/Makefile.dep +++ b/sys/ztimer/Makefile.dep @@ -11,13 +11,6 @@ ifneq (,$(filter ztimer,$(USEMODULE))) DEFAULT_MODULE += ztimer_init endif -# unless ztimer_xtimer_compat is used, make xtimer use ztimer_usec as backend. -ifneq (,$(filter ztimer,$(USEMODULE))) - ifneq (,$(filter evtimer,$(USEMODULE))) - USEMODULE += evtimer_on_ztimer - endif -endif - ifneq (,$(filter ztimer_xtimer_compat,$(USEMODULE))) USEMODULE += ztimer_usec endif @@ -27,11 +20,6 @@ ifneq (,$(filter ztimer64_xtimer_compat,$(USEMODULE))) USEMODULE += ztimer_xtimer_compat endif -# make evtimer use ztimer_msec as low level timer -ifneq (,$(filter evtimer_on_ztimer,$(USEMODULE))) - USEMODULE += ztimer_msec -endif - ifneq (,$(filter ztimer_%,$(USEMODULE))) USEMODULE += ztimer_core USEMODULE += ztimer_extend diff --git a/tests/net/gnrc_mac_timeout/Makefile b/tests/net/gnrc_mac_timeout/Makefile index 6a78094e52..9675b41cf2 100644 --- a/tests/net/gnrc_mac_timeout/Makefile +++ b/tests/net/gnrc_mac_timeout/Makefile @@ -1,5 +1,6 @@ include ../Makefile.net_common +USEMODULE += ztimer_msec USEMODULE += gnrc_mac include $(RIOTBASE)/Makefile.include diff --git a/tests/net/gnrc_mac_timeout/main.c b/tests/net/gnrc_mac_timeout/main.c index cd00eed78f..78e895a0fd 100644 --- a/tests/net/gnrc_mac_timeout/main.c +++ b/tests/net/gnrc_mac_timeout/main.c @@ -23,7 +23,7 @@ #include "net/gnrc/mac/timeout.h" #include "thread.h" #include "msg.h" -#include "xtimer.h" +#include "ztimer.h" #define TIMEOUT_COUNT 3 #define TIMEOUT_1_DURATION 1000 @@ -34,7 +34,7 @@ static gnrc_mac_timeout_event_t test_timeouts[TIMEOUT_COUNT]; static gnrc_mac_timeout_type_t timeout_1; static gnrc_mac_timeout_type_t timeout_2; static gnrc_mac_timeout_type_t timeout_3; -static uint32_t start_time; +static ztimer_now_t start_time; static char worker_stack[THREAD_STACKSIZE_MAIN]; @@ -47,10 +47,10 @@ void *worker_thread(void *arg) while (1) { msg_t m; - uint32_t now; + ztimer_now_t now; msg_receive(&m); - now = xtimer_now_usec() / US_PER_MS; + now = ztimer_now(ZTIMER_MSEC); if (gnrc_mac_timeout_is_expired(&mac_timeout, timeout_1)) { printf("At %6" PRIu32 " ms received msg %i: timeout_1 (set at %" PRIu32 " ms) expired, " @@ -102,7 +102,7 @@ int main(void) timeout_2 = -2; timeout_3 = -3; - start_time = xtimer_now_usec() / US_PER_MS; + start_time = ztimer_now(ZTIMER_MSEC); gnrc_mac_init_timeouts(&mac_timeout, test_timeouts, TIMEOUT_COUNT); gnrc_mac_set_timeout(&mac_timeout, timeout_1, TIMEOUT_1_DURATION, pid); gnrc_mac_set_timeout(&mac_timeout, timeout_2, TIMEOUT_2_DURATION, pid); diff --git a/tests/net/gnrc_netif/main.c b/tests/net/gnrc_netif/main.c index 34fff1e905..caf86553e1 100644 --- a/tests/net/gnrc_netif/main.c +++ b/tests/net/gnrc_netif/main.c @@ -38,7 +38,6 @@ #include "net/netif.h" #include "test_utils/expect.h" #include "utlist.h" -#include "xtimer.h" #define ETHERNET_STACKSIZE (THREAD_STACKSIZE_MAIN) #define IEEE802154_STACKSIZE (THREAD_STACKSIZE_MAIN) diff --git a/tests/sys/evtimer_mbox/app.config.test b/tests/sys/evtimer_mbox/app.config.test new file mode 100644 index 0000000000..4f02c158e2 --- /dev/null +++ b/tests/sys/evtimer_mbox/app.config.test @@ -0,0 +1 @@ +CONFIG_MODULE_EVTIMER_MBOX=y diff --git a/tests/sys/evtimer_msg/Makefile b/tests/sys/evtimer_msg/Makefile index aacc3125a5..007687a90c 100644 --- a/tests/sys/evtimer_msg/Makefile +++ b/tests/sys/evtimer_msg/Makefile @@ -1,7 +1,7 @@ include ../Makefile.sys_common USEMODULE += evtimer -USEMODULE += xtimer +USEMODULE += ztimer_msec # This test randomly fails on `native` so disable it from CI TEST_ON_CI_BLACKLIST += native diff --git a/tests/sys/evtimer_msg/app.config.test b/tests/sys/evtimer_msg/app.config.test new file mode 100644 index 0000000000..77160ead67 --- /dev/null +++ b/tests/sys/evtimer_msg/app.config.test @@ -0,0 +1 @@ +CONFIG_MODULE_EVTIMER=y diff --git a/tests/sys/evtimer_msg/main.c b/tests/sys/evtimer_msg/main.c index 961e2f5c8e..59e4f6de14 100644 --- a/tests/sys/evtimer_msg/main.c +++ b/tests/sys/evtimer_msg/main.c @@ -23,7 +23,7 @@ #include "evtimer_msg.h" #include "thread.h" #include "msg.h" -#include "xtimer.h" +#include "ztimer.h" static char worker_stack[THREAD_STACKSIZE_MAIN]; static evtimer_t evtimer; @@ -111,7 +111,7 @@ int main(void) NEVENTS); /* The last offset is the largest, wait for it and a tiny bit more */ - xtimer_msleep((offsets[3] + 10)); + ztimer_sleep(ZTIMER_MSEC, (offsets[3] + 10)); puts("By now all msgs should have been received"); puts("If yes, the tests were successful"); } diff --git a/tests/sys/evtimer_underflow/Makefile b/tests/sys/evtimer_underflow/Makefile index 485222d0a7..071591b0b1 100644 --- a/tests/sys/evtimer_underflow/Makefile +++ b/tests/sys/evtimer_underflow/Makefile @@ -1,7 +1,7 @@ include ../Makefile.sys_common USEMODULE += evtimer -USEMODULE += xtimer +USEMODULE += ztimer_msec # microbit qemu lacks rtt TEST_ON_CI_BLACKLIST += microbit diff --git a/tests/sys/evtimer_underflow/app.config.test b/tests/sys/evtimer_underflow/app.config.test new file mode 100644 index 0000000000..77160ead67 --- /dev/null +++ b/tests/sys/evtimer_underflow/app.config.test @@ -0,0 +1 @@ +CONFIG_MODULE_EVTIMER=y diff --git a/tests/sys/evtimer_underflow/main.c b/tests/sys/evtimer_underflow/main.c index 89768ee4ec..43ecfb2122 100644 --- a/tests/sys/evtimer_underflow/main.c +++ b/tests/sys/evtimer_underflow/main.c @@ -23,7 +23,7 @@ #include "evtimer_msg.h" #include "thread.h" #include "msg.h" -#include "xtimer.h" +#include "ztimer.h" #define WORKER_MSG_QUEUE_SIZE (8) @@ -61,7 +61,7 @@ void *worker_thread(void *arg) void sleep_msec(uint16_t t) { - xtimer_msleep(t); + ztimer_sleep(ZTIMER_MSEC, t); } int main(void) diff --git a/tests/sys/pipe/app.config.test b/tests/sys/pipe/app.config.test new file mode 100644 index 0000000000..18cf9c2314 --- /dev/null +++ b/tests/sys/pipe/app.config.test @@ -0,0 +1 @@ +CONFIG_MODULE_PIPE=y diff --git a/tests/sys/shell_lock/Makefile b/tests/sys/shell_lock/Makefile index 6b67361fde..a9da2d0033 100644 --- a/tests/sys/shell_lock/Makefile +++ b/tests/sys/shell_lock/Makefile @@ -7,8 +7,10 @@ USEMODULE += shell_cmds_default USEMODULE += shell_lock USEMODULE += shell_lock_auto_locking +ifneq (1,$(TEST_KCONFIG)) CFLAGS += -DCONFIG_SHELL_LOCK_PASSWORD=\"password\" CFLAGS += -DCONFIG_SHELL_LOCK_AUTO_LOCK_TIMEOUT_MS=7000 +endif # This config defaults to 1 on native, such that pm_off() would be called as soon as # shell_run_once is terminated in shell_run_forever. We do not want this behavior for this test. diff --git a/tests/sys/shell_lock/app.config.test b/tests/sys/shell_lock/app.config.test new file mode 100644 index 0000000000..c11575af5a --- /dev/null +++ b/tests/sys/shell_lock/app.config.test @@ -0,0 +1,6 @@ +CONFIG_MODULE_SHELL=y +CONFIG_MODULE_SHELL_CMDS_DEFAULT=y +CONFIG_MODULE_SHELL_LOCK=y +CONFIG_MODULE_SHELL_LOCK_AUTO_LOCKING=y +CONFIG_MODULE_TEST_UTILS_INTERACTIVE_SYNC_SHELL=n +CONFIG_SHELL_SHUTDOWN_ON_EXIT=n