diff --git a/.murdock b/.murdock index bf31b8f2ffeb..a838296640b4 100755 --- a/.murdock +++ b/.murdock @@ -4,6 +4,7 @@ : ${TEST_BOARDS_LLVM_COMPILE:="iotlab-m3 native nrf52dk mulle nucleo-f401re samr21-xpro slstk3402a"} # we can't use '-' in the variable names, convert them to '_' to add new boards : ${TEST_KCONFIG_samr21_xpro:="examples/hello-world tests/periph_*"} +: ${TEST_KCONFIG_native:="examples/hello-world tests/periph_*"} export RIOT_CI_BUILD=1 export CC_NOCOLOR=1 @@ -39,6 +40,9 @@ get_kconfig_test_apps() { case "$1" in "samr21_xpro") echo "${TEST_KCONFIG_samr21_xpro}" ;; esac + case "$1" in + "native") echo "${TEST_KCONFIG_native}" ;; + esac } check_label() { diff --git a/boards/native/Kconfig b/boards/native/Kconfig index 977cba18b988..87331ba3985b 100644 --- a/boards/native/Kconfig +++ b/boards/native/Kconfig @@ -24,3 +24,5 @@ config BOARD_NATIVE # Various other features (if any) select HAS_ETHERNET select HAS_MOTOR_DRIVER + +rsource "drivers/Kconfig" diff --git a/boards/native/Makefile.dep b/boards/native/Makefile.dep index e1f2fac5a9d6..c3248cd5a996 100644 --- a/boards/native/Makefile.dep +++ b/boards/native/Makefile.dep @@ -19,4 +19,4 @@ ifneq (,$(filter socket_zep,$(USEMODULE))) USEMODULE += random endif -USEMODULE += native-drivers +USEMODULE += native_drivers diff --git a/boards/native/drivers/Kconfig b/boards/native/drivers/Kconfig new file mode 100644 index 000000000000..1fe03b86ef28 --- /dev/null +++ b/boards/native/drivers/Kconfig @@ -0,0 +1,14 @@ +# Copyright (c) 2020 HAW Hamburg +# +# 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_NATIVE_DRIVERS + bool + depends on BOARD_NATIVE + depends on TEST_KCONFIG + default y + help + Drivers for Native board. diff --git a/boards/native/drivers/Makefile b/boards/native/drivers/Makefile index e717c6fd8e75..eee00d77a447 100644 --- a/boards/native/drivers/Makefile +++ b/boards/native/drivers/Makefile @@ -1,3 +1,3 @@ -MODULE = native-drivers +MODULE = native_drivers include $(RIOTBASE)/Makefile.base diff --git a/cpu/native/Kconfig b/cpu/native/Kconfig index fbe5a23e2b1e..423a7b4c0000 100644 --- a/cpu/native/Kconfig +++ b/cpu/native/Kconfig @@ -19,6 +19,9 @@ config CPU_ARCH_NATIVE select HAS_PERIPH_PWM select HAS_SSP + # needed modules + select MODULE_PERIPH if TEST_KCONFIG + config CPU_CORE_NATIVE bool select CPU_ARCH_NATIVE @@ -74,3 +77,12 @@ config CPU_MODEL config CPU default "native" if CPU_MODEL_NATIVE + +menu "Native modules" + depends on CPU_ARCH_NATIVE + +rsource "backtrace/Kconfig" + +endmenu # Native modules + +rsource "periph/Kconfig" diff --git a/cpu/native/Makefile.features b/cpu/native/Makefile.features index 023c7e56df22..a2e82ccce3b4 100644 --- a/cpu/native/Makefile.features +++ b/cpu/native/Makefile.features @@ -25,3 +25,9 @@ ifeq ($(OS),Linux) # CAN is only supported on Linux through socketCAN FEATURES_PROVIDED += periph_can endif + +# This configuration enables modules that are only available when using Kconfig +# module modelling +ifeq (1, $(TEST_KCONFIG)) + KCONFIG_ADD_CONFIG += $(RIOTCPU)/native/native.config +endif diff --git a/cpu/native/backtrace/Kconfig b/cpu/native/backtrace/Kconfig new file mode 100644 index 000000000000..339720f3f0bc --- /dev/null +++ b/cpu/native/backtrace/Kconfig @@ -0,0 +1,11 @@ +# Copyright (c) 2020 HAW Hamburg +# +# 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_BACKTRACE + bool "Stack backtrace" + depends on CPU_ARCH_NATIVE + depends on TEST_KCONFIG diff --git a/cpu/native/native.config b/cpu/native/native.config new file mode 100644 index 000000000000..92d9ea6d2c70 --- /dev/null +++ b/cpu/native/native.config @@ -0,0 +1,2 @@ +# UART is needed by startup.c +CONFIG_MODULE_PERIPH_UART=y diff --git a/cpu/native/periph/Kconfig b/cpu/native/periph/Kconfig new file mode 100644 index 000000000000..52440c0ff7dd --- /dev/null +++ b/cpu/native/periph/Kconfig @@ -0,0 +1,16 @@ +# Copyright (c) 2020 HAW Hamburg +# +# 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_PERIPH_SPIDEV_LINUX + bool + default y if MODULE_PERIPH_SPI + depends on NATIVE_OS_LINUX + +config MODULE_PERIPH_INIT_SPIDEV_LINUX + bool + default y + depends on MODULE_PERIPH_SPIDEV_LINUX diff --git a/cpu/native/periph/Kconfig.gpio b/cpu/native/periph/Kconfig.gpio new file mode 100644 index 000000000000..315d7ed60dba --- /dev/null +++ b/cpu/native/periph/Kconfig.gpio @@ -0,0 +1,36 @@ +# Copyright (c) 2020 HAW Hamburg +# +# 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. +# + +choice NATIVE_GPIO_IMPLEMENTATION + bool "Native GPIO peripheral implementation" + depends on MODULE_PERIPH_GPIO + depends on CPU_ARCH_NATIVE + depends on TEST_KCONFIG + default MODULE_PERIPH_GPIO_LINUX if NATIVE_OS_LINUX + +config MODULE_PERIPH_GPIO_LINUX + bool "Linux GPIO" + depends on NATIVE_OS_LINUX + +config MODULE_PERIPH_GPIO_MOCK + bool "Mock" + +endchoice + +# TODO: these modules are actually just artifacts from the way periph_init_% +# modules are handled in Makefile. We need to define them to keep the list the +# same for now. We should be able to remove them later on. + +config MODULE_PERIPH_INIT_GPIO_LINUX + bool + default y if MODULE_PERIPH_INIT + depends on MODULE_PERIPH_GPIO_LINUX + +config MODULE_PERIPH_INIT_GPIO_MOCK + bool + default y if MODULE_PERIPH_INIT + depends on MODULE_PERIPH_GPIO_MOCK diff --git a/cpu/native/periph/Kconfig.rtc b/cpu/native/periph/Kconfig.rtc new file mode 100644 index 000000000000..d55a7de808ca --- /dev/null +++ b/cpu/native/periph/Kconfig.rtc @@ -0,0 +1,10 @@ +# Copyright (c) 2020 HAW Hamburg +# +# 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_PERIPH_RTC + select MODULE_XTIMER if CPU_ARCH_NATIVE + depends on HAS_PERIPH_RTC diff --git a/drivers/periph_common/Kconfig b/drivers/periph_common/Kconfig index f9ea06b6e27c..6fb385016634 100644 --- a/drivers/periph_common/Kconfig +++ b/drivers/periph_common/Kconfig @@ -115,15 +115,7 @@ config MODULE_PERIPH_INIT_QDEC default y if MODULE_PERIPH_INIT depends on MODULE_PERIPH_QDEC -config MODULE_PERIPH_RTC - bool "RTC peripheral driver" - depends on HAS_PERIPH_RTC - select MODULE_PERIPH_COMMON - -config MODULE_PERIPH_INIT_RTC - bool "Auto initialize RTC peripheral" - default y if MODULE_PERIPH_INIT - depends on MODULE_PERIPH_RTC +rsource "Kconfig.rtc" config MODULE_PERIPH_RTT bool "RTT peripheral driver" diff --git a/drivers/periph_common/Kconfig.gpio b/drivers/periph_common/Kconfig.gpio index 59f5cd089f9a..8c7aa4cbfe56 100644 --- a/drivers/periph_common/Kconfig.gpio +++ b/drivers/periph_common/Kconfig.gpio @@ -44,3 +44,5 @@ config MODULE_PERIPH_INIT_GPIO_FAST_READ depends on MODULE_PERIPH_GPIO_FAST_READ endif # MODULE_PERIPH_GPIO + +osource "$(RIOTCPU)/$(CPU)/periph/Kconfig.gpio" diff --git a/drivers/periph_common/Kconfig.rtc b/drivers/periph_common/Kconfig.rtc new file mode 100644 index 000000000000..45bd98fe3bf4 --- /dev/null +++ b/drivers/periph_common/Kconfig.rtc @@ -0,0 +1,19 @@ +# Copyright (c) 2020 HAW Hamburg +# +# 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_PERIPH_RTC + bool "RTC peripheral driver" + depends on HAS_PERIPH_RTC + select MODULE_PERIPH_COMMON + +config MODULE_PERIPH_INIT_RTC + bool "Auto initialize RTC peripheral" + default y if MODULE_PERIPH_INIT + depends on MODULE_PERIPH_RTC + +# Include CPU specific configurations +osource "$(RIOTCPU)/$(CPU)/periph/Kconfig.rtc" diff --git a/sys/Kconfig.stdio b/sys/Kconfig.stdio index a41da22354a7..363d17a22e30 100644 --- a/sys/Kconfig.stdio +++ b/sys/Kconfig.stdio @@ -10,10 +10,11 @@ menu "Standard Input/Output (STDIO)" choice bool "STDIO implementation" + default MODULE_STDIO_NATIVE if CPU_ARCH_NATIVE default MODULE_STDIO_UART # TODO: Add MODULE_STDIO_CDC_ACM, MODULE_STDIO_RTT, MODULE_SLIPDEV_STDIO, -# MODULE_STDIO_NATIVE and MODULE_STDIO_ETHOS +# and MODULE_STDIO_ETHOS config MODULE_STDIO_NULL bool "Null" @@ -25,6 +26,10 @@ config MODULE_STDIO_UART depends on HAS_PERIPH_UART select MODULE_PERIPH_UART +config MODULE_STDIO_NATIVE + bool "Native" + depends on CPU_ARCH_NATIVE + endchoice config MODULE_STDIN diff --git a/tests/periph_gpio/Makefile b/tests/periph_gpio/Makefile index 10b85c91c476..90e4fb42f497 100644 --- a/tests/periph_gpio/Makefile +++ b/tests/periph_gpio/Makefile @@ -12,6 +12,10 @@ USEMODULE += benchmark # disable native GPIOs for automatic test ifeq (native,$(BOARD)) USEMODULE += periph_gpio_mock + # the same for Kconfig + ifeq (1,$(TEST_KCONFIG)) + KCONFIG_ADD_CONFIG += $(APPDIR)/app.config.test.native + endif endif BOARDS_BENCH_PORT_1 = \ diff --git a/tests/periph_gpio/app.config.test.native b/tests/periph_gpio/app.config.test.native new file mode 100644 index 000000000000..05fab9dc7ed7 --- /dev/null +++ b/tests/periph_gpio/app.config.test.native @@ -0,0 +1,2 @@ +# disable native GPIOs for automatic test +CONFIG_MODULE_PERIPH_GPIO_MOCK=y