From 2cc5af664e7a9ffd5f649c91a45c5983592766b1 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Wed, 16 Mar 2022 12:53:45 +0100 Subject: [PATCH 1/7] treewide: make all modules use Kconfig ZTIMER_USEC indirection --- cpu/qn908x/periph/Kconfig | 4 +--- drivers/ccs811/Kconfig | 4 +--- pkg/u8g2/Kconfig | 3 +-- pkg/ucglib/Kconfig | 3 +-- sys/trace/Kconfig | 4 +--- 5 files changed, 5 insertions(+), 13 deletions(-) diff --git a/cpu/qn908x/periph/Kconfig b/cpu/qn908x/periph/Kconfig index a6cde8579087..84d2249a34e3 100644 --- a/cpu/qn908x/periph/Kconfig +++ b/cpu/qn908x/periph/Kconfig @@ -21,6 +21,4 @@ config MODULE_PERIPH_GPIO_MUX config MODULE_PERIPH_ADC bool "ADC peripheral driver" depends on HAS_PERIPH_ADC - select MODULE_ZTIMER - select MODULE_ZTIMER_USEC - select MODULE_ZTIMER_PERIPH_TIMER + select ZTIMER_USEC diff --git a/drivers/ccs811/Kconfig b/drivers/ccs811/Kconfig index 0a6fecb79f8f..a70f787c673f 100644 --- a/drivers/ccs811/Kconfig +++ b/drivers/ccs811/Kconfig @@ -14,9 +14,7 @@ menuconfig MODULE_CCS811 depends on TEST_KCONFIG select MODULE_PERIPH_GPIO select MODULE_PERIPH_I2C - select MODULE_ZTIMER - select MODULE_ZTIMER_USEC - select MODULE_ZTIMER_PERIPH_TIMER + select ZTIMER_USEC config MODULE_CCS811_FULL bool "Full functionalities" diff --git a/pkg/u8g2/Kconfig b/pkg/u8g2/Kconfig index 80ab54d0a4de..9f5db5ee775d 100644 --- a/pkg/u8g2/Kconfig +++ b/pkg/u8g2/Kconfig @@ -10,8 +10,7 @@ config PACKAGE_U8G2 depends on TEST_KCONFIG depends on HAS_PERIPH_GPIO select MODULE_PERIPH_GPIO - select MODULE_ZTIMER - select MODULE_ZTIMER_USEC + select ZTIMER_USEC select MODULE_U8G2_RIOT select MODULE_U8G2_CSRC diff --git a/pkg/ucglib/Kconfig b/pkg/ucglib/Kconfig index 5e40bcbe9b50..9d181b1d124a 100644 --- a/pkg/ucglib/Kconfig +++ b/pkg/ucglib/Kconfig @@ -10,8 +10,7 @@ config PACKAGE_UCGLIB depends on TEST_KCONFIG depends on HAS_PERIPH_GPIO select MODULE_PERIPH_GPIO - select MODULE_ZTIMER - select MODULE_ZTIMER_USEC + select ZTIMER_USEC select MODULE_UCGLIB_RIOT select MODULE_UCGLIB_CSRC diff --git a/sys/trace/Kconfig b/sys/trace/Kconfig index e9f7edcc3cc0..db3ebce9be76 100644 --- a/sys/trace/Kconfig +++ b/sys/trace/Kconfig @@ -8,6 +8,4 @@ config MODULE_TRACE bool "Trace program flows" depends on TEST_KCONFIG - select MODULE_ZTIMER - select MODULE_ZTIMER_USEC - select MODULE_ZTIMER_PERIPH_TIMER + select ZTIMER_USEC From d86828c53b12017d39a7138e3c43b9081be77636 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Wed, 16 Mar 2022 12:53:12 +0100 Subject: [PATCH 2/7] cpu/efm32: periph_rtt_series0/1 are not modules --- cpu/efm32/periph/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpu/efm32/periph/Kconfig b/cpu/efm32/periph/Kconfig index 1e9b41564278..5f8217d5feed 100644 --- a/cpu/efm32/periph/Kconfig +++ b/cpu/efm32/periph/Kconfig @@ -39,14 +39,14 @@ config MODULE_PERIPH_RTC_SERIES1 help RTC driver implementation for EFM32 series 1. -config MODULE_PERIPH_RTT_SERIES0 +config PERIPH_RTT_SERIES0 bool depends on CPU_EFM32_SERIES0 default MODULE_PERIPH_RTT help RTT driver implementation for EFM32 series 0. -config MODULE_PERIPH_RTT_SERIES1 +config PERIPH_RTT_SERIES1 bool depends on CPU_EFM32_SERIES1 default MODULE_PERIPH_RTT From be6a76a3c04972484293cfa5001d11b1201215df Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Tue, 15 Mar 2022 22:21:53 +0100 Subject: [PATCH 3/7] sys/sc_gnrc_udp: fix *timer include --- sys/shell/commands/sc_gnrc_udp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/shell/commands/sc_gnrc_udp.c b/sys/shell/commands/sc_gnrc_udp.c index 4da0576e4556..db9cb2cef32c 100644 --- a/sys/shell/commands/sc_gnrc_udp.c +++ b/sys/shell/commands/sc_gnrc_udp.c @@ -31,9 +31,10 @@ #include "net/utils.h" #include "timex.h" #include "utlist.h" -#if IS_USED(MODULE_ZTIMER) +#if IS_USED(MODULE_ZTIMER_USEC) || IS_USED(MODULE_ZTIMER_MSEC) #include "ztimer.h" -#else +#endif +#if IS_USED(MODULE_XTIMER) #include "xtimer.h" #endif From 7227d1bb7774c3511fc0043e6905672b162bb047 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Tue, 1 Mar 2022 11:59:29 +0100 Subject: [PATCH 4/7] sys/xtimer: move dependencies to xtimer/Makefile.dep --- sys/Makefile.dep | 15 +-------------- sys/xtimer/Makefile.dep | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 14 deletions(-) create mode 100644 sys/xtimer/Makefile.dep diff --git a/sys/Makefile.dep b/sys/Makefile.dep index bade0af71982..beee33facf46 100644 --- a/sys/Makefile.dep +++ b/sys/Makefile.dep @@ -857,20 +857,7 @@ endif # handle xtimer's deps. Needs to be done *after* ztimer ifneq (,$(filter xtimer,$(USEMODULE))) - ifeq (,$(filter ztimer_xtimer_compat,$(USEMODULE))) - # xtimer is used, ztimer xtimer wrapper is not - DEFAULT_MODULE += auto_init_xtimer - USEMODULE += div - ifeq (,$(filter xtimer_on_ztimer,$(USEMODULE))) - # ztimer is not used, so use *periph_timer as low-level timer*. - FEATURES_REQUIRED += periph_timer - else - # will use *ztimer_usec as low-level timer* - endif - else - # ztimer_xtimer_compat is used, all of *xtimer's API will be mapped on ztimer - # or ztimer64 * - endif + include $(RIOTBASE)/sys/xtimer/Makefile.dep endif ifneq (,$(filter devfs_hwrng,$(USEMODULE))) diff --git a/sys/xtimer/Makefile.dep b/sys/xtimer/Makefile.dep new file mode 100644 index 000000000000..2fe9bdc0bfc1 --- /dev/null +++ b/sys/xtimer/Makefile.dep @@ -0,0 +1,14 @@ +ifeq (,$(filter ztimer_xtimer_compat,$(USEMODULE))) + # xtimer is used, ztimer xtimer wrapper is not + DEFAULT_MODULE += auto_init_xtimer + USEMODULE += div + ifeq (,$(filter xtimer_on_ztimer,$(USEMODULE))) + # ztimer is not used, so use *periph_timer as low-level timer*. + FEATURES_REQUIRED += periph_timer + else + # will use *ztimer_usec as low-level timer* + endif +else + # ztimer_xtimer_compat is used, all of *xtimer's API will be mapped on ztimer + # or ztimer64 * +endif From 0b1453667e1274b55760d89db34a7cca7128c3b2 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Wed, 16 Mar 2022 08:57:56 +0100 Subject: [PATCH 5/7] sys/xtimer-ztimer: rework dependecies to ease backend switch This adds a xtimer_no_ztimer_default that is currently always selected in Makefile, but that can be switched off in Kconfig. Removing its inclusion will allow switching the default xtimer backend to ztimer, while allowing for an easy way back. --- makefiles/default_modules.deps.mk | 6 +++++ makefiles/pseudomodules.inc.mk | 1 + sys/xtimer/Kconfig | 15 ++++++++---- sys/xtimer/Makefile.dep | 39 ++++++++++++++++++++++--------- sys/ztimer/Kconfig | 1 + sys/ztimer/Makefile.dep | 12 ---------- 6 files changed, 46 insertions(+), 28 deletions(-) diff --git a/makefiles/default_modules.deps.mk b/makefiles/default_modules.deps.mk index fa98d2c0ae87..b128a73292be 100644 --- a/makefiles/default_modules.deps.mk +++ b/makefiles/default_modules.deps.mk @@ -13,3 +13,9 @@ endif ifneq (,$(filter auto_init_saul,$(USEMODULE))) USEMODULE += saul_init_devs endif + +ifneq (,$(filter xtimer,$(USEMODULE))) + ifeq (,$(filter ztimer_xtimer_compat,$(USEMODULE))) + USEMODULE += div + endif +endif diff --git a/makefiles/pseudomodules.inc.mk b/makefiles/pseudomodules.inc.mk index 67a54b314cf2..fe812ef5c995 100644 --- a/makefiles/pseudomodules.inc.mk +++ b/makefiles/pseudomodules.inc.mk @@ -257,6 +257,7 @@ PSEUDOMODULES += vfs_default PSEUDOMODULES += wakaama_objects_% PSEUDOMODULES += wifi_enterprise PSEUDOMODULES += xtimer_on_ztimer +PSEUDOMODULES += xtimer_no_ztimer_default PSEUDOMODULES += zptr PSEUDOMODULES += ztimer PSEUDOMODULES += ztimer_% diff --git a/sys/xtimer/Kconfig b/sys/xtimer/Kconfig index fdfeebb5b724..b4de1eb6e582 100644 --- a/sys/xtimer/Kconfig +++ b/sys/xtimer/Kconfig @@ -8,17 +8,22 @@ menuconfig MODULE_XTIMER bool "xtimer" depends on HAS_PERIPH_TIMER - depends on TEST_KCONFIG - # use timer peripheral unless ztimer compatibility module is used - select MODULE_PERIPH_TIMER if HAS_PERIPH_TIMER && !MODULE_XTIMER_ON_ZTIMER && !MODULE_ZTIMER_XTIMER_COMPAT && !MODULE_ZTIMER64_XTIMER_COMPAT - + select MODULE_PERIPH_TIMER select MODULE_DIV if !MODULE_ZTIMER_XTIMER_COMPAT + select ZTIMER_USEC if !MODULE_XTIMER_NO_ZTIMER_DEFAULT help Include xtimer module. xtimer requires a low-level timer implementation that can be provided either by a peripheral timer or the ztimer module when MODULE_XTIMER_ON_ZTIMER is enabled. +if MODULE_XTIMER + +config MODULE_XTIMER_NO_ZTIMER_DEFAULT + bool "xtimer does not select ztimer" + default y + config MODULE_AUTO_INIT_XTIMER bool "Auto-init xtimer" default y if MODULE_AUTO_INIT && !MODULE_ZTIMER_XTIMER_COMPAT - depends on MODULE_XTIMER + +endif # MODULE_XTIMER diff --git a/sys/xtimer/Makefile.dep b/sys/xtimer/Makefile.dep index 2fe9bdc0bfc1..0525f3fd8294 100644 --- a/sys/xtimer/Makefile.dep +++ b/sys/xtimer/Makefile.dep @@ -1,14 +1,31 @@ -ifeq (,$(filter ztimer_xtimer_compat,$(USEMODULE))) - # xtimer is used, ztimer xtimer wrapper is not - DEFAULT_MODULE += auto_init_xtimer - USEMODULE += div - ifeq (,$(filter xtimer_on_ztimer,$(USEMODULE))) - # ztimer is not used, so use *periph_timer as low-level timer*. - FEATURES_REQUIRED += periph_timer - else - # will use *ztimer_usec as low-level timer* +DEFAULT_MODULE += auto_init_xtimer +# In whatever combination of backends periph_timer will be required +# - xtimer (only) -> periph_timer +# - xtimer_on_ztimer -> ztimer_usec -> ztimer_periph_timer -> periph_timer +# - ztimer_xtimer_compat -> ztimer_usec -> ztimer_periph_timer -> periph_timer +# But requesting it here avoid an ifeq dependency that would be subject to +# dependency inclusion order issues +FEATURES_REQUIRED += periph_timer + +USEMODULE += xtimer_no_ztimer_default +ifeq (,$(filter xtimer_no_ztimer_default,$(USEMODULE))) + ifeq (,$(filter ztimer_xtimer_compat,$(USEMODULE))) + USEMODULE += xtimer_on_ztimer endif else - # ztimer_xtimer_compat is used, all of *xtimer's API will be mapped on ztimer - # or ztimer64 * + ifneq (,$(filter ztimer,$(USEMODULE))) + ifeq (,$(filter ztimer_xtimer_compat,$(USEMODULE))) + USEMODULE += xtimer_on_ztimer + endif + endif +endif + +ifneq (,$(filter ztimer_xtimer_compat,$(USEMODULE))) + DISABLE_MODULE += auto_init_xtimer + USEMODULE += div +endif + +# make xtimer use ztimer_usec as low level timer +ifneq (,$(filter xtimer_on_ztimer,$(USEMODULE))) + USEMODULE += ztimer_usec endif diff --git a/sys/ztimer/Kconfig b/sys/ztimer/Kconfig index c68a070378a8..2269a86dac76 100644 --- a/sys/ztimer/Kconfig +++ b/sys/ztimer/Kconfig @@ -152,6 +152,7 @@ config MODULE_ZTIMER_XTIMER_COMPAT bool "map xtimer calls to ztimer" select MODULE_DIV select MODULE_ZTIMER_USEC + select MODULE_ZTIMER_PERIPH_TIMER help This is a wrapper of xtimer API on ztimer_usec and is currently incomplete. Unless doing testing, use xtimer on ztimer. diff --git a/sys/ztimer/Makefile.dep b/sys/ztimer/Makefile.dep index fdbfc39799d6..de64c76c1e95 100644 --- a/sys/ztimer/Makefile.dep +++ b/sys/ztimer/Makefile.dep @@ -13,13 +13,6 @@ endif # unless ztimer_xtimer_compat is used, make xtimer use ztimer_usec as backend. ifneq (,$(filter ztimer,$(USEMODULE))) - ifneq (,$(filter xtimer,$(USEMODULE))) - ifeq (,$(filter ztimer_xtimer_compat ztimer64_xtimer_compat,$(USEMODULE))) - USEMODULE += xtimer_on_ztimer - else - USEMODULE += div - endif - endif ifneq (,$(filter evtimer,$(USEMODULE))) USEMODULE += evtimer_on_ztimer endif @@ -34,11 +27,6 @@ ifneq (,$(filter ztimer64_xtimer_compat,$(USEMODULE))) USEMODULE += ztimer_xtimer_compat endif -# make xtimer use ztimer_usec as low level timer -ifneq (,$(filter xtimer_on_ztimer,$(USEMODULE))) - USEMODULE += ztimer_usec -endif - # make evtimer use ztimer_msec as low level timer ifneq (,$(filter evtimer_on_ztimer,$(USEMODULE))) USEMODULE += ztimer_msec From 9260cfb4f06ef654a8c5328d8e72810e9d82199c Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Wed, 16 Mar 2022 09:34:25 +0100 Subject: [PATCH 6/7] sys/xtimer: prefer ztimer_xtimer_compat --- makefiles/boards/ztimer_only.dep.mk | 8 ++++---- sys/xtimer/Makefile.dep | 8 ++++---- sys/ztimer/Kconfig | 15 +++++---------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/makefiles/boards/ztimer_only.dep.mk b/makefiles/boards/ztimer_only.dep.mk index f50810a051bd..e6e5e86b19f4 100644 --- a/makefiles/boards/ztimer_only.dep.mk +++ b/makefiles/boards/ztimer_only.dep.mk @@ -1,11 +1,11 @@ # Include this for boards whose timer periph cannot generate a clock frequency # suitable for xtimer with the available clock sources and dividers. # This will use ztimer to perform the required frequency conversion. -# By default, xtimer is still used with ztimer as backed, unless -# ztimer_xtimer_compat is used. +# By default, ztimer_xtimer_compat is used unless xtimer_on_ztimer is +# selected. ifneq (,$(filter xtimer,$(USEMODULE))) - ifeq (,$(filter ztimer_xtimer_compat ztimer64_xtimer_compat,$(USEMODULE))) - USEMODULE += xtimer_on_ztimer + ifeq (,$(filter xtimer_on_ztimer,$(USEMODULE))) + USEMODULE += ztimer_xtimer_compat endif endif diff --git a/sys/xtimer/Makefile.dep b/sys/xtimer/Makefile.dep index 0525f3fd8294..4d141a49aadf 100644 --- a/sys/xtimer/Makefile.dep +++ b/sys/xtimer/Makefile.dep @@ -9,13 +9,13 @@ FEATURES_REQUIRED += periph_timer USEMODULE += xtimer_no_ztimer_default ifeq (,$(filter xtimer_no_ztimer_default,$(USEMODULE))) - ifeq (,$(filter ztimer_xtimer_compat,$(USEMODULE))) - USEMODULE += xtimer_on_ztimer + ifeq (,$(filter xtimer_on_ztimer,$(USEMODULE))) + USEMODULE += ztimer_xtimer_compat endif else ifneq (,$(filter ztimer,$(USEMODULE))) - ifeq (,$(filter ztimer_xtimer_compat,$(USEMODULE))) - USEMODULE += xtimer_on_ztimer + ifeq (,$(filter xtimer_on_ztimer,$(USEMODULE))) + USEMODULE += ztimer_xtimer_compat endif endif endif diff --git a/sys/ztimer/Kconfig b/sys/ztimer/Kconfig index 2269a86dac76..f1ab66248ee9 100644 --- a/sys/ztimer/Kconfig +++ b/sys/ztimer/Kconfig @@ -143,23 +143,18 @@ choice bool "xtimer compatibility" depends on MODULE_XTIMER && MODULE_ZTIMER -config MODULE_XTIMER_ON_ZTIMER - bool "ztimer_usec as timer backend for xtimer" - select MODULE_ZTIMER_USEC - select MODULE_ZTIMER_PERIPH_TIMER - config MODULE_ZTIMER_XTIMER_COMPAT bool "map xtimer calls to ztimer" select MODULE_DIV select MODULE_ZTIMER_USEC select MODULE_ZTIMER_PERIPH_TIMER help - This is a wrapper of xtimer API on ztimer_usec and is currently - incomplete. Unless doing testing, use xtimer on ztimer. - -comment "The ztimer xtimer compatibility module is incomplete, consider using MODULE_ZTIMER64_XTIMER_COMPAT instead." - depends on MODULE_ZTIMER_XTIMER_COMPAT + This is a wrapper of xtimer API on ztimer_usec. +config MODULE_XTIMER_ON_ZTIMER + bool "ztimer_usec as timer backend for xtimer" + select MODULE_ZTIMER_USEC + select MODULE_ZTIMER_PERIPH_TIMER endchoice config MODULE_ZTIMER64_XTIMER_COMPAT From 46ae29502858dba6859e0cceb779afe39d4f3842 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Wed, 9 Mar 2022 08:44:23 +0100 Subject: [PATCH 7/7] tests/xtimer*: select xtimer_no_ztimer_default for tests requiring it These tests need to be tested on xtimer, and if using ztimer_xtimer_compat the full api will not be provided, therefore also blacklist BOARDs that will en up selecting ztimer by default. --- tests/xtimer_now32_overflow/Makefile | 16 ++++++++++++++++ tests/xtimer_now32_overflow/app.config.test | 1 + tests/xtimer_now64_continuity/Makefile | 15 +++++++++++++++ tests/xtimer_now64_continuity/app.config.test | 1 + 4 files changed, 33 insertions(+) diff --git a/tests/xtimer_now32_overflow/Makefile b/tests/xtimer_now32_overflow/Makefile index 7f8b991ddf94..a1079e38f2bd 100644 --- a/tests/xtimer_now32_overflow/Makefile +++ b/tests/xtimer_now32_overflow/Makefile @@ -1,7 +1,23 @@ include ../Makefile.tests_common USEMODULE += xtimer +USEMODULE += xtimer_no_ztimer_default DISABLE_MODULE += auto_init_xtimer +# Boards that can't run only on xtimer or that always select ztimer +BOARD_BLACKLIST += \ + feather-nrf52840 \ + hamilton \ + mulle \ + pinetime \ + ruuvitag \ + stm32f429i-disco \ + thingy52 \ + waspmote-pro \ + weact-f401cc \ + weact-f401ce \ + weact-f411ce \ + # + include $(RIOTBASE)/Makefile.include diff --git a/tests/xtimer_now32_overflow/app.config.test b/tests/xtimer_now32_overflow/app.config.test index 396443c12fe8..9fc59457d0ba 100644 --- a/tests/xtimer_now32_overflow/app.config.test +++ b/tests/xtimer_now32_overflow/app.config.test @@ -1,4 +1,5 @@ # this file enables modules defined in Kconfig. Do not use this file for # application configuration. This is only needed during migration. CONFIG_MODULE_XTIMER=y +CONFIG_MODULE_XTIMER_NO_ZTIMER_DEFAULT=y CONFIG_MODULE_AUTO_INIT_XTIMER=n diff --git a/tests/xtimer_now64_continuity/Makefile b/tests/xtimer_now64_continuity/Makefile index 6c3bc23fa14a..d1a7cfc56d5e 100644 --- a/tests/xtimer_now64_continuity/Makefile +++ b/tests/xtimer_now64_continuity/Makefile @@ -2,8 +2,23 @@ include ../Makefile.tests_common USEMODULE += fmt USEMODULE += xtimer +USEMODULE += xtimer_no_ztimer_default # This test randomly fails on `native` so disable it from CI TEST_ON_CI_BLACKLIST += native +# Boards that can't run only on xtimer or that always select ztimer +BOARD_BLACKLIST += \ + feather-nrf52840 \ + hamilton \ + mulle \ + pinetime \ + ruuvitag \ + stm32f429i-disco \ + thingy52 \ + waspmote-pro \ + weact-f401cc \ + weact-f401ce \ + weact-f411ce \ + # include $(RIOTBASE)/Makefile.include diff --git a/tests/xtimer_now64_continuity/app.config.test b/tests/xtimer_now64_continuity/app.config.test index 8f28e0ef2eb3..c0c51bf4c546 100644 --- a/tests/xtimer_now64_continuity/app.config.test +++ b/tests/xtimer_now64_continuity/app.config.test @@ -1,4 +1,5 @@ # this file enables modules defined in Kconfig. Do not use this file for # application configuration. This is only needed during migration. CONFIG_MODULE_XTIMER=y +CONFIG_MODULE_XTIMER_NO_ZTIMER_DEFAULT=y CONFIG_MODULE_FMT=y