Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/compliance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
# debug
ls -la
git log --pretty=oneline | head -n 10
./scripts/ci/check_compliance.py -m Devicetree -m Gitlint -m Identity -m Nits -m pylint -m checkpatch -m Kconfig -c origin/${BASE_REF}..
./scripts/ci/check_compliance.py -m Devicetree -m Gitlint -m Identity -m Nits -m pylint -m checkpatch -m Kconfig -m KconfigBoardV2 -c origin/${BASE_REF}..

- name: upload-results
uses: actions/upload-artifact@v3
Expand Down
21 changes: 0 additions & 21 deletions arch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -904,27 +904,6 @@ config ARCH
help
System architecture string.

config SOC
string
help
SoC name which can be found under soc/<arch>/<soc name>.
This option holds the directory name used by the build system to locate
the correct linker and header files for the SoC.

config SOC_SERIES
string
help
SoC series name which can be found under soc/<arch>/<family>/<series>.
This option holds the directory name used by the build system to locate
the correct linker and header files.

config SOC_FAMILY
string
help
SoC family name which can be found under soc/<arch>/<family>.
This option holds the directory name used by the build system to locate
the correct linker and header files.

config TOOLCHAIN_HAS_BUILTIN_FFS
bool
default y if !(64BIT && RISCV)
Expand Down
11 changes: 3 additions & 8 deletions boards/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

config BOARD
string
# When using Board scheme v2, then the board is inherited from CMake.
default "$(BOARD)" if "$(BOARD_SCHEME)" = "v2"
help
This option holds the name of the board and is used to locate the files
related to the board in the source tree (under boards/).
Expand Down Expand Up @@ -38,14 +40,7 @@ config NET_DRIVERS
When building for a qemu target then NET_DRIVERS will be default
enabled to allow for easy use of SLIP or PPP

# Note: $BOARD_DIR might be a glob pattern

choice
prompt "Board Selection"

source "$(BOARD_DIR)/Kconfig.board"

endchoice
rsource "Kconfig.$(BOARD_SCHEME)"

# Parse shields references
# Don't do it as a menuconfig, as shield selection is a CMake feature.
Expand Down
10 changes: 10 additions & 0 deletions boards/Kconfig.v1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2022 Nordic Semiconductor ASA

# SPDX-License-Identifier: Apache-2.0

choice
prompt "Board Selection"

source "$(BOARD_DIR)/Kconfig.board"

endchoice
5 changes: 5 additions & 0 deletions boards/Kconfig.v2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) 2022 Nordic Semiconductor ASA

# SPDX-License-Identifier: Apache-2.0

osource "$(BOARD_DIR)/Kconfig.v2.$(BOARD)"
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
# SPDX-License-Identifier: Apache-2.0

config BOARD_NRF52840DK_NRF52811
bool "nRF52840 DK NRF52811"
depends on SOC_NRF52811_QFAA
bool
default y
select SOC_NRF52811_QFAA
select SOC_SERIES_NRF52X
4 changes: 0 additions & 4 deletions boards/arm/nrf52840dk_nrf52811/nrf52840dk_nrf52811_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

# SPDX-License-Identifier: Apache-2.0

CONFIG_SOC_SERIES_NRF52X=y
CONFIG_SOC_NRF52811_QFAA=y
CONFIG_BOARD_NRF52840DK_NRF52811=y

# Enable MPU
CONFIG_ARM_MPU=y

Expand Down
8 changes: 0 additions & 8 deletions boards/arm/nrf52840dk_nrf52840/Kconfig.board

This file was deleted.

9 changes: 9 additions & 0 deletions boards/arm/nrf52840dk_nrf52840/Kconfig.v2.nrf52840dk_nrf52840
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2022 Zephyr Project members and individual contributors
# SPDX-License-Identifier: Apache-2.0

config BOARD_NRF52840DK_NRF52840
bool
default y
select SOC_SERIES_NRF52X
select SOC_NRF52840_QIAA
select NATIVE_APPLICATION
4 changes: 0 additions & 4 deletions boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840_defconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# SPDX-License-Identifier: Apache-2.0

CONFIG_SOC_SERIES_NRF52X=y
CONFIG_SOC_NRF52840_QIAA=y
CONFIG_BOARD_NRF52840DK_NRF52840=y

# Enable MPU
CONFIG_ARM_MPU=y

Expand Down
13 changes: 13 additions & 0 deletions cmake/modules/kconfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,17 @@ string(REPLACE ";" "\\\;" SHIELD_AS_LIST_ESCAPED "${SHIELD_AS_LIST}")
# cmake commands are escaped differently
string(REPLACE ";" "\\;" SHIELD_AS_LIST_ESCAPED_COMMAND "${SHIELD_AS_LIST}")

# A Kconfig.board indicates legacy style board definition, whereas
# Kconfig.${BOARD} indicates new and improved style.
if(EXISTS ${BOARD_DIR}/Kconfig.board AND NOT EXISTS ${BOARD_DIR}/Kconfig.${BOARD})
set(BOARD_SCHEME v1)
elseif(NOT EXISTS ${BOARD_DIR}/Kconfig.board AND EXISTS ${BOARD_DIR}/Kconfig.${BOARD})
set(BOARD_SCHEME v2)
elseif(EXISTS ${BOARD_DIR}/Kconfig.board AND EXISTS ${BOARD_DIR}/Kconfig.${BOARD})
message(WARNING "Mixed board scheme (v1 + v2) not allowed, using board scheme v2.")
set(BOARD_SCHEME v2)
endif()

set(COMMON_KCONFIG_ENV_SETTINGS
PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
srctree=${ZEPHYR_BASE}
Expand All @@ -122,7 +133,9 @@ set(COMMON_KCONFIG_ENV_SETTINGS
ARCH=${ARCH}
ARCH_DIR=${ARCH_DIR}
BOARD_DIR=${BOARD_DIR}
BOARD=${BOARD}
BOARD_REVISION=${BOARD_REVISION}
BOARD_SCHEME=${BOARD_SCHEME}
KCONFIG_BINARY_DIR=${KCONFIG_BINARY_DIR}
ZEPHYR_TOOLCHAIN_VARIANT=${ZEPHYR_TOOLCHAIN_VARIANT}
TOOLCHAIN_KCONFIG_DIR=${TOOLCHAIN_KCONFIG_DIR}
Expand Down
1 change: 1 addition & 0 deletions doc/_extensions/zephyr/kconfig/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def kconfig_load(app: Sphinx) -> Tuple[kconfiglib.Kconfig, Dict[str, str]]:
os.environ["ARCH_DIR"] = "arch"
os.environ["ARCH"] = "*"
os.environ["BOARD_DIR"] = "boards/*/*"
os.environ["BOARD_SCHEME"] = "v*"

# insert external Kconfigs to the environment
module_paths = dict()
Expand Down
11 changes: 11 additions & 0 deletions scripts/ci/Kconfig.board.v2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Kconfig top-level ci for compliance testing Kconfig tree for boards / SoC v2 scheme.
#
# Copyright (c) 2022 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0

mainmenu "Zephyr board / SoC v2 Configuration"

SOC_SCHEME = $(BOARD_SCHEME)
source "boards/Kconfig.$(BOARD_SCHEME)"
source "soc/Kconfig.$(SOC_SCHEME)"
28 changes: 24 additions & 4 deletions scripts/ci/check_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ class KconfigCheck(ComplianceTest):
doc = "See https://docs.zephyrproject.org/latest/guides/kconfig/index.html for more details."
path_hint = ZEPHYR_BASE

def run(self, full=True):
kconf = self.parse_kconfig()
def run(self, full=True, board_scheme="v*", filename="Kconfig"):
kconf = self.parse_kconfig(board_scheme=board_scheme, filename=filename)

self.check_top_menu_not_too_long(kconf)
self.check_no_pointless_menuconfigs(kconf)
Expand Down Expand Up @@ -294,7 +294,7 @@ def get_kconfig_dts(self, kconfig_dts_file):
self.error(ex.output)


def parse_kconfig(self):
def parse_kconfig(self, board_scheme="v*", filename="Kconfig"):
"""
Returns a kconfiglib.Kconfig object for the Kconfig files. We reuse
this object for all tests to avoid having to reparse for each test.
Expand All @@ -321,6 +321,8 @@ def parse_kconfig(self):
os.environ["SOC_DIR"] = "soc/"
os.environ["ARCH_DIR"] = "arch/"
os.environ["BOARD_DIR"] = "boards/*/*"
os.environ["BOARD_SCHEME"] = board_scheme
os.environ["BOARD"] = "*"
os.environ["ARCH"] = "*"
os.environ["KCONFIG_BINARY_DIR"] = tempfile.gettempdir()
os.environ['DEVICETREE_CONF'] = "dummy"
Expand All @@ -345,7 +347,7 @@ def parse_kconfig(self):
# them: so some warnings might get printed
# twice. "warn_to_stderr=False" could unfortunately cause
# some (other) warnings to never be printed.
return kconfiglib.Kconfig()
return kconfiglib.Kconfig(filename=filename)
except kconfiglib.KconfigError as e:
self.add_failure(str(e))
raise EndTest
Expand Down Expand Up @@ -632,6 +634,24 @@ def run(self):
super().run(full=False)


class KconfigBoardV2Check(KconfigCheck, ComplianceTest):
"""
This runs the Kconfig test for board and SoC v2 scheme.
This check ensures that all symbols inside the v2 scheme is also defined
within the same tree.
This ensures the board and SoC trees are fully self-contained and reusable.
"""
name = "KconfigBoardV2"
doc = "See https://docs.zephyrproject.org/latest/guides/kconfig/index.html for more details."
path_hint = ZEPHYR_BASE

def run(self):
# Use dedicated Kconfig board / soc v2 scheme file.
# This file sources only v2 scheme tree.
kconfig_file = os.path.join(os.path.dirname(__file__), "Kconfig.board.v2")
super().run(full=False, board_scheme="v2", filename=kconfig_file)


class Codeowners(ComplianceTest):
"""
Check if added files have an owner.
Expand Down
12 changes: 4 additions & 8 deletions soc/Kconfig
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# SPDX-License-Identifier: Apache-2.0

choice
prompt "SoC/CPU/Configuration Selection"
# SoC scheme follows the board scheme versioning.
SOC_SCHEME = $(BOARD_SCHEME)

# This loads custom SoC root Kconfig (only available if custom SoC root are defined)
osource "$(KCONFIG_BINARY_DIR)/Kconfig.soc"
# This loads Zephyr base SoC root Kconfig
osource "soc/$(ARCH)/*/Kconfig.soc"

endchoice
# This loads any SoC scheme specific content.
rsource "Kconfig.$(SOC_SCHEME)"

menu "Hardware Configuration"
# This loads custom SoC root Kconfig (only available if custom SoC root are defined)
Expand Down
34 changes: 34 additions & 0 deletions soc/Kconfig.v1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (c) 2022 Nordic Semiconductor ASA

# SPDX-License-Identifier: Apache-2.0

config SOC
string
help
SoC name which can be found under soc/<arch>/<soc name>.
This option holds the directory name used by the build system to locate
the correct linker and header files for the SoC.

config SOC_SERIES
string
help
SoC series name which can be found under soc/<arch>/<family>/<series>.
This option holds the directory name used by the build system to locate
the correct linker and header files.

config SOC_FAMILY
string
help
SoC family name which can be found under soc/<arch>/<family>.
This option holds the directory name used by the build system to locate
the correct linker and header files.

choice
prompt "SoC/CPU/Configuration Selection"

# This loads custom SoC root Kconfig (only available if custom SoC root are defined)
osource "$(KCONFIG_BINARY_DIR)/Kconfig.soc"
# This loads Zephyr base SoC scheme v1 root Kconfig
osource "soc/$(ARCH)/*/Kconfig.soc"

endchoice
37 changes: 37 additions & 0 deletions soc/Kconfig.v2
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright (c) 2022 Nordic Semiconductor ASA

# SPDX-License-Identifier: Apache-2.0

# Load all SoCs.
# SoCs that has transistioned to SoC scheme v2 are promptless, and thus
# unselectable by the user or thorugh configuration files.
#
# SoC that are still using scheme v1 are still having a prompt but is loaded as
# they offer board maintainers the possibility to use board scheme v2.

config SOC
string
help
SoC name which can be found under soc/<arch>/<soc name>.
This option holds the directory name used by the build system to locate
the correct linker and header files for the SoC.

config SOC_SERIES
string
help
SoC series name which can be found under soc/<arch>/<family>/<series>.
This option holds the directory name used by the build system to locate
the correct linker and header files.

config SOC_FAMILY
string
help
SoC family name which can be found under soc/<arch>/<family>.
This option holds the directory name used by the build system to locate
the correct linker and header files.

osource "$(KCONFIG_BINARY_DIR)/Kconfig.soc.v2"
# This loads Zephyr base SoC root Kconfig
osource "soc/$(ARCH)/*/Kconfig.soc.v2"

#endif
16 changes: 16 additions & 0 deletions soc/arm/nordic_nrf/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,28 @@ config SOC_FAMILY_NRF
select PLATFORM_SPECIFIC_INIT
bool

config SOC_SERIES_NRF52X
bool
select ARM
select SOC_COMPATIBLE_NRF52X
select CPU_CORTEX_M4
select CPU_HAS_ARM_MPU
select SOC_FAMILY_NRF
select XIP
select HAS_NRFX
select HAS_NORDIC_DRIVERS
select HAS_SEGGER_RTT
select HAS_SWO
help
Enable support for NRF52 MCU series

if SOC_FAMILY_NRF
config SOC_FAMILY
string
default "nordic_nrf"

source "soc/arm/nordic_nrf/Kconfig.peripherals"
source "soc/arm/nordic_nrf/*/Kconfig.soc.$(SOC_SCHEME)"
source "soc/arm/nordic_nrf/*/Kconfig.soc"

config NRF_SOC_SECURE_SUPPORTED
Expand Down
6 changes: 0 additions & 6 deletions soc/arm/nordic_nrf/Kconfig.soc

This file was deleted.

Loading