Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys/*timer: rework dependencies to ease backend switch, prefer ztimer_xtimer_compat over xtimer_on_ztimer #17811

Merged
merged 7 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cpu/efm32/periph/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
fjmolinas marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
4 changes: 1 addition & 3 deletions cpu/qn908x/periph/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 1 addition & 3 deletions drivers/ccs811/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions makefiles/boards/ztimer_only.dep.mk
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions makefiles/default_modules.deps.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions makefiles/pseudomodules.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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_%
Expand Down
3 changes: 1 addition & 2 deletions pkg/u8g2/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions pkg/ucglib/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 1 addition & 14 deletions sys/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
5 changes: 3 additions & 2 deletions sys/shell/commands/sc_gnrc_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions sys/trace/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 10 additions & 5 deletions sys/xtimer/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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

fjmolinas marked this conversation as resolved.
Show resolved Hide resolved
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
31 changes: 31 additions & 0 deletions sys/xtimer/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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)))
leandrolanzieri marked this conversation as resolved.
Show resolved Hide resolved
ifeq (,$(filter xtimer_on_ztimer,$(USEMODULE)))
USEMODULE += ztimer_xtimer_compat
endif
else
ifneq (,$(filter ztimer,$(USEMODULE)))
ifeq (,$(filter xtimer_on_ztimer,$(USEMODULE)))
USEMODULE += ztimer_xtimer_compat
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
16 changes: 6 additions & 10 deletions sys/ztimer/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +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
Expand Down
12 changes: 0 additions & 12 deletions sys/ztimer/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
16 changes: 16 additions & 0 deletions tests/xtimer_now32_overflow/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
include ../Makefile.tests_common

USEMODULE += xtimer
USEMODULE += xtimer_no_ztimer_default

fjmolinas marked this conversation as resolved.
Show resolved Hide resolved
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 \
fjmolinas marked this conversation as resolved.
Show resolved Hide resolved
weact-f401ce \
weact-f411ce \
#

include $(RIOTBASE)/Makefile.include
1 change: 1 addition & 0 deletions tests/xtimer_now32_overflow/app.config.test
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions tests/xtimer_now64_continuity/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,23 @@ include ../Makefile.tests_common

USEMODULE += fmt
USEMODULE += xtimer
USEMODULE += xtimer_no_ztimer_default

fjmolinas marked this conversation as resolved.
Show resolved Hide resolved
# 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 \
fjmolinas marked this conversation as resolved.
Show resolved Hide resolved
weact-f401ce \
weact-f411ce \
#

include $(RIOTBASE)/Makefile.include
1 change: 1 addition & 0 deletions tests/xtimer_now64_continuity/app.config.test
Original file line number Diff line number Diff line change
@@ -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