From 34d84ad8c63a7fa11465c5a5a42d29b88d23a8e1 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Fri, 9 Oct 2020 18:01:33 +0200 Subject: [PATCH 1/2] makefile: add check for ERROR_ Kconfig symbols This adds a check in the build process to verify that no ERROR_ Kconfig symbols are set. These symbols indicate invalid conditions in the Kconfig configuration. --- Makefile.include | 2 +- makefiles/kconfig.mk | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Makefile.include b/Makefile.include index 3f7ef5cab0..43f2d2f33d 100644 --- a/Makefile.include +++ b/Makefile.include @@ -644,7 +644,7 @@ endif ..compiler-check: $(call check_cmd,$(CC),Compiler) -..build-message: +..build-message: $(if $(SHOULD_RUN_KCONFIG), check-kconfig-errors) @$(COLOR_ECHO) '$(COLOR_GREEN)Building application "$(APPLICATION)" for "$(BOARD)" with MCU "$(MCU)".$(COLOR_RESET)' @$(COLOR_ECHO) diff --git a/makefiles/kconfig.mk b/makefiles/kconfig.mk index 1aa1788731..0069c71271 100644 --- a/makefiles/kconfig.mk +++ b/makefiles/kconfig.mk @@ -168,4 +168,19 @@ $(KCONFIG_GENERATED_AUTOCONF_HEADER_C): $(KCONFIG_OUT_CONFIG) $(GENERATED_DIR_DE # Try to load the list of Kconfig files used -include $(KCONFIG_OUT_DEP) +# capture all ERROR_ prefixed Kconfig symbols +_KCONFIG_ERROR_VARS = $(filter CONFIG_ERROR_%,$(.VARIABLES)) +_KCONFIG_ERRORS = $(foreach v,$(_KCONFIG_ERROR_VARS),$($(v))) + +# this checks that no Kconfig error symbols are set. These symbols are used +# to indicate invalid conditions +check-kconfig-errors: $(KCONFIG_OUT_CONFIG) $(KCONFIG_GENERATED_AUTOCONF_HEADER_C) +ifneq (,$(_KCONFIG_ERRORS)) + @$(COLOR_ECHO) "$(COLOR_RED) !! There are ERRORS in the configuration !! $(COLOR_RESET)" + @for err in $(_KCONFIG_ERRORS); do \ + echo "- $$err"; \ + done + @false +endif + endif From fe6d66d92ab23e19206e185706fb752de53497ad Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Thu, 24 Sep 2020 15:21:07 +0200 Subject: [PATCH 2/2] kconfig: add ERROR symbol for conflicting modules --- Kconfig | 6 ++++++ boards/stm32f4discovery/Kconfig | 4 ++++ cpu/atmega_common/Kconfig | 4 ++++ cpu/efm32/Kconfig | 4 ++++ cpu/sam0_common/Kconfig | 3 +++ cpu/stm32/Kconfig | 5 +++++ kconfigs/Kconfig.errors | 20 ++++++++++++++++++++ 7 files changed, 46 insertions(+) create mode 100644 kconfigs/Kconfig.errors diff --git a/Kconfig b/Kconfig index a5ea17d0e3..75fb259853 100644 --- a/Kconfig +++ b/Kconfig @@ -12,6 +12,9 @@ rsource "kconfigs/Kconfig.consts" # Load feature declarations rsource "kconfigs/Kconfig.features" +# Load error symbols +rsource "kconfigs/Kconfig.errors" + # For now, get used modules as macros from this file (see kconfig.mk) osource "$(KCONFIG_GENERATED_DEPENDENCIES)" @@ -33,6 +36,9 @@ rsource "pkg/Kconfig" comment "RIOT is in a migration phase." comment "Some configuration options may not be here. Use CFLAGS instead." +comment "!! ERROR: There are conflicting modules active !!" + depends on ERROR_MODULES_CONFLICT != "" + config TEST_KCONFIG bool default y if '$(TEST_KCONFIG)' = '1' diff --git a/boards/stm32f4discovery/Kconfig b/boards/stm32f4discovery/Kconfig index c18869f17a..c5a92163c4 100644 --- a/boards/stm32f4discovery/Kconfig +++ b/boards/stm32f4discovery/Kconfig @@ -27,3 +27,7 @@ config BOARD_STM32F4DISCOVERY # Various other features (if any) select HAS_ARDUINO + +config ERROR_MODULES_CONFLICT + default "On stm32f4discovery boards there are the same pins for the DAC and/or SPI_0." if MODULE_PERIPH_SPI && MODULE_PERIPH_DAC + depends on BOARD_STM32F4DISCOVERY diff --git a/cpu/atmega_common/Kconfig b/cpu/atmega_common/Kconfig index 3748434b00..fca23e122b 100644 --- a/cpu/atmega_common/Kconfig +++ b/cpu/atmega_common/Kconfig @@ -68,3 +68,7 @@ config HAS_ATMEGA_PCINT3 bool help Indicates that the Pin Change Interrupt bank 3 is present. + +config ERROR_MODULES_CONFLICT + default "On ATmega, the RTC and RTT use to the same hardware timer." if MODULE_PERIPH_RTC && MODULE_PERIPH_RTT + depends on CPU_COMMON_ATMEGA diff --git a/cpu/efm32/Kconfig b/cpu/efm32/Kconfig index 03f45d03ef..a14d8cccd3 100644 --- a/cpu/efm32/Kconfig +++ b/cpu/efm32/Kconfig @@ -37,5 +37,9 @@ config HAS_CPU_EFM32 config CPU default "efm32" if CPU_COMMON_EFM32 +config ERROR_MODULES_CONFLICT + default "On the EFM32, the RTC and RTT map to the same hardware peripheral." if MODULE_PERIPH_RTC && MODULE_PERIPH_RTT + depends on CPU_COMMON_EFM32 + orsource "families/*/Kconfig" source "$(RIOTCPU)/cortexm_common/Kconfig" diff --git a/cpu/sam0_common/Kconfig b/cpu/sam0_common/Kconfig index 9a525df6fc..333e15dc00 100644 --- a/cpu/sam0_common/Kconfig +++ b/cpu/sam0_common/Kconfig @@ -28,6 +28,9 @@ if CPU_COMMON_SAM0 rsource "periph/Kconfig" +config ERROR_MODULES_CONFLICT + default "On SAM0, the RTC and RTT map to the same hardware peripheral." if MODULE_PERIPH_RTC && MODULE_PERIPH_RTT + endif # CPU_COMMON_SAM0 source "$(RIOTCPU)/cortexm_common/Kconfig" diff --git a/cpu/stm32/Kconfig b/cpu/stm32/Kconfig index 324ad8de7a..8a96cde81d 100644 --- a/cpu/stm32/Kconfig +++ b/cpu/stm32/Kconfig @@ -32,7 +32,12 @@ config HAS_BOOTLOADER_STM32 help Indicates that the stm32 bootloader is being used. +config ERROR_MODULES_CONFLICT + default "On STM32, the RTC and RTT map to the same hardware peripheral." if MODULE_PERIPH_RTC && MODULE_PERIPH_RTT + depends on CPU_STM32 + orsource "kconfig/*/Kconfig" orsource "kconfig/*/Kconfig.lines" orsource "kconfig/*/Kconfig.models" + source "$(RIOTCPU)/cortexm_common/Kconfig" diff --git a/kconfigs/Kconfig.errors b/kconfigs/Kconfig.errors new file mode 100644 index 0000000000..46ef792405 --- /dev/null +++ b/kconfigs/Kconfig.errors @@ -0,0 +1,20 @@ +# 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. +# + +# Definition of common error symbols. To indicate an error set the default value +# to the correspondent symbol guarded with the error condition. e.g.: +# +# config ERROR_MODULES_CONFLICT +# default "On SAM0 platforms RTT and RTC cannot be set at the same time" +# depends on MODULE_PERIPH_RTC && MODULE_PERIPH_RTT && CPU_COMMON_SAM0 +# + +config ERROR_MODULES_CONFLICT + string + help + Used to indicate that conflicting modules (i.e. modules that can't be + active at the same time) are being used together.