From 5a87053fa492a5054045d7f06ac098bb57deaac8 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Thu, 23 Jul 2020 08:29:34 +0200 Subject: [PATCH 01/12] sys/stdio: add stdio_native module to Kconfig --- sys/Kconfig.stdio | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/Kconfig.stdio b/sys/Kconfig.stdio index a41da22354..363d17a22e 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 From 402efc47504b054229f6e02abafe6c18793dade9 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Thu, 23 Jul 2020 08:31:18 +0200 Subject: [PATCH 02/12] boards/native: rename native-drivers module to native_drivers --- boards/native/Makefile.dep | 2 +- boards/native/drivers/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/boards/native/Makefile.dep b/boards/native/Makefile.dep index e1f2fac5a9..c3248cd5a9 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/Makefile b/boards/native/drivers/Makefile index e717c6fd8e..eee00d77a4 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 From 8b0e0d2f526fd931546b9f0d1471696c58aa3b7f Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Thu, 23 Jul 2020 08:32:48 +0200 Subject: [PATCH 03/12] boards/native: add native_drivers module to Kconfig --- boards/native/Kconfig | 2 ++ boards/native/drivers/Kconfig | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 boards/native/drivers/Kconfig diff --git a/boards/native/Kconfig b/boards/native/Kconfig index 977cba18b9..87331ba398 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/drivers/Kconfig b/boards/native/drivers/Kconfig new file mode 100644 index 0000000000..1fe03b86ef --- /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. From 8df4512960df448850e21c6677f6ef6754151699 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Wed, 9 Sep 2020 14:27:53 +0200 Subject: [PATCH 04/12] cpu/native: add default configuration --- cpu/native/Makefile.features | 6 ++++++ cpu/native/native.config | 2 ++ 2 files changed, 8 insertions(+) create mode 100644 cpu/native/native.config diff --git a/cpu/native/Makefile.features b/cpu/native/Makefile.features index 023c7e56df..a2e82ccce3 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/native.config b/cpu/native/native.config new file mode 100644 index 0000000000..92d9ea6d2c --- /dev/null +++ b/cpu/native/native.config @@ -0,0 +1,2 @@ +# UART is needed by startup.c +CONFIG_MODULE_PERIPH_UART=y From 1d1a96fb8afdc4926df6e75ce34ee3d85461fb4e Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Wed, 9 Sep 2020 15:41:28 +0200 Subject: [PATCH 05/12] drivers/periph_common/kconfig.gpio: include CPU configs --- drivers/periph_common/Kconfig.gpio | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/periph_common/Kconfig.gpio b/drivers/periph_common/Kconfig.gpio index 59f5cd089f..8c7aa4cbfe 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" From 8715f19c260dce8efc3b8d9cc6a592373f2cef0d Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Wed, 9 Sep 2020 15:42:14 +0200 Subject: [PATCH 06/12] cpu/native/periph: add Native GPIO modules to Kconfig --- cpu/native/periph/Kconfig.gpio | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 cpu/native/periph/Kconfig.gpio diff --git a/cpu/native/periph/Kconfig.gpio b/cpu/native/periph/Kconfig.gpio new file mode 100644 index 0000000000..315d7ed60d --- /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 From 1d868f2b7b8ded55276116b85b32fe5ec0c9002a Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Wed, 9 Sep 2020 16:56:49 +0200 Subject: [PATCH 07/12] cpu/native: select needed modules in Kconfig --- cpu/native/Kconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cpu/native/Kconfig b/cpu/native/Kconfig index fbe5a23e2b..87202b5255 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 From f973f8de03d5528c1346799fac71c82ec65a1b1d Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Wed, 9 Sep 2020 17:19:16 +0200 Subject: [PATCH 08/12] murdock: add native:hello-world and periph_* to Kconfig tests --- .murdock | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.murdock b/.murdock index bf31b8f2ff..a838296640 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() { From c4fda9f4a9c60bffe9076ab732024f45cc9a9a64 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Tue, 10 Nov 2020 10:35:38 +0100 Subject: [PATCH 09/12] cpu/native/backtrace: add module to Kconfig --- cpu/native/Kconfig | 7 +++++++ cpu/native/backtrace/Kconfig | 11 +++++++++++ 2 files changed, 18 insertions(+) create mode 100644 cpu/native/backtrace/Kconfig diff --git a/cpu/native/Kconfig b/cpu/native/Kconfig index 87202b5255..b1b181fc8d 100644 --- a/cpu/native/Kconfig +++ b/cpu/native/Kconfig @@ -77,3 +77,10 @@ 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 diff --git a/cpu/native/backtrace/Kconfig b/cpu/native/backtrace/Kconfig new file mode 100644 index 0000000000..339720f3f0 --- /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 From 2306516d0daaddf4102144c9d1dd94a54b690cbf Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Tue, 10 Nov 2020 17:02:35 +0100 Subject: [PATCH 10/12] drivers/periph_common: add CPU specific RTC Kconfig --- cpu/native/periph/Kconfig.rtc | 10 ++++++++++ drivers/periph_common/Kconfig | 10 +--------- drivers/periph_common/Kconfig.rtc | 19 +++++++++++++++++++ 3 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 cpu/native/periph/Kconfig.rtc create mode 100644 drivers/periph_common/Kconfig.rtc diff --git a/cpu/native/periph/Kconfig.rtc b/cpu/native/periph/Kconfig.rtc new file mode 100644 index 0000000000..d55a7de808 --- /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 f9ea06b6e2..6fb3850166 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.rtc b/drivers/periph_common/Kconfig.rtc new file mode 100644 index 0000000000..45bd98fe3b --- /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" From 43cc7beb26cc927896b519385d5df9a922ffa7f6 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Tue, 10 Nov 2020 17:12:21 +0100 Subject: [PATCH 11/12] cpu/native: add periph_spidev module to Kconfig --- cpu/native/Kconfig | 2 ++ cpu/native/periph/Kconfig | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 cpu/native/periph/Kconfig diff --git a/cpu/native/Kconfig b/cpu/native/Kconfig index b1b181fc8d..423a7b4c00 100644 --- a/cpu/native/Kconfig +++ b/cpu/native/Kconfig @@ -84,3 +84,5 @@ menu "Native modules" rsource "backtrace/Kconfig" endmenu # Native modules + +rsource "periph/Kconfig" diff --git a/cpu/native/periph/Kconfig b/cpu/native/periph/Kconfig new file mode 100644 index 0000000000..52440c0ff7 --- /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 From 9021a0b13ae14a92e37f1aecf0291ad34e65b85e Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Tue, 10 Nov 2020 17:46:01 +0100 Subject: [PATCH 12/12] tests/periph_gpio: add native-specific configuration file --- tests/periph_gpio/Makefile | 4 ++++ tests/periph_gpio/app.config.test.native | 2 ++ 2 files changed, 6 insertions(+) create mode 100644 tests/periph_gpio/app.config.test.native diff --git a/tests/periph_gpio/Makefile b/tests/periph_gpio/Makefile index 10b85c91c4..90e4fb42f4 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 0000000000..05fab9dc7e --- /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