From fdfba64aebd4f89d56c2d43c9d2ddf266a79c838 Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Mon, 7 Aug 2023 11:43:34 +0200 Subject: [PATCH] boards: arm: thingy91: Exclude ADP536X driver from all bootloaders The ADP536X integrated circuit interfaces with two distinct drivers: the Zephyr regulator driver, responsible for power regulation aspects of the ADP536X, and the sdk-nrf ADP536X driver, which manages other functionalities. Both drivers are now reserved exclusively for inclusion within the application image. Introduced a new kconfig symbol IS_BOOTLOADER_IMG, to simplify checking for both MCUboot and secure bootloaders. In addition, changed how the driver is automatically enabled. Now it is enabled if the devicetree has an "adi,adp5360" compatible node enabled. CIA-604 Signed-off-by: Gregers Gram Rygg --- boards/arm/thingy91_nrf9160/CMakeLists.txt | 13 ++----------- boards/arm/thingy91_nrf9160/Kconfig.defconfig | 4 +++- .../arm/thingy91_nrf9160/thingy91_nrf9160_defconfig | 6 ------ .../thingy91_nrf9160/thingy91_nrf9160_ns_defconfig | 6 ------ .../releases/release-notes-changelog.rst | 4 +++- lib/adp536x/Kconfig | 4 ++++ subsys/bootloader/Kconfig | 7 +++++++ 7 files changed, 19 insertions(+), 25 deletions(-) diff --git a/boards/arm/thingy91_nrf9160/CMakeLists.txt b/boards/arm/thingy91_nrf9160/CMakeLists.txt index c8c7a866f50a..904f24325689 100644 --- a/boards/arm/thingy91_nrf9160/CMakeLists.txt +++ b/boards/arm/thingy91_nrf9160/CMakeLists.txt @@ -4,19 +4,10 @@ # # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -if(CONFIG_BOARD_THINGY91_NRF9160 AND NOT DEFINED CONFIG_MCUBOOT) - zephyr_library() - zephyr_library_sources(adp5360_init.c) -endif() +zephyr_library() +zephyr_library_sources_ifdef(CONFIG_ADP536X adp5360_init.c) if(CONFIG_BOARD_THINGY91_NRF9160_NS) - # If TF-M is used, the ADP5360 configuration must be done in non-secure - # as we can't instruct TF-M to run it. - if(CONFIG_BUILD_WITH_TFM) - zephyr_library() - zephyr_library_sources(adp5360_init.c) - endif() - # Use static partition layout to ensure the partition layout remains # unchanged after DFU. This needs to be made globally available # because it is used in other CMake files. diff --git a/boards/arm/thingy91_nrf9160/Kconfig.defconfig b/boards/arm/thingy91_nrf9160/Kconfig.defconfig index 477f48fdad9d..bdc58846d231 100644 --- a/boards/arm/thingy91_nrf9160/Kconfig.defconfig +++ b/boards/arm/thingy91_nrf9160/Kconfig.defconfig @@ -9,8 +9,10 @@ if BOARD_THINGY91_NRF9160 || BOARD_THINGY91_NRF9160_NS config BOARD default "thingy91_nrf9160" +# Enable Zephyr power regulator ADP536x config REGULATOR - default y if !MCUBOOT + default y + depends on !IS_BOOTLOADER_IMG # By default, if we build for a Non-Secure version of the board, # enable building with TF-M as the Secure Execution Environment. diff --git a/boards/arm/thingy91_nrf9160/thingy91_nrf9160_defconfig b/boards/arm/thingy91_nrf9160/thingy91_nrf9160_defconfig index 58ff7f914ca8..a00903ba4bae 100644 --- a/boards/arm/thingy91_nrf9160/thingy91_nrf9160_defconfig +++ b/boards/arm/thingy91_nrf9160/thingy91_nrf9160_defconfig @@ -21,11 +21,5 @@ CONFIG_SERIAL=y CONFIG_CONSOLE=y CONFIG_UART_CONSOLE=y -# Enable I2C -CONFIG_I2C=y - -# Enable power management IC ADP536x -CONFIG_ADP536X=y - # Disable entropy driver, as it's not yet implemented for nRF9160 CONFIG_ENTROPY_NRF5_RNG=n diff --git a/boards/arm/thingy91_nrf9160/thingy91_nrf9160_ns_defconfig b/boards/arm/thingy91_nrf9160/thingy91_nrf9160_ns_defconfig index f61bee0ca430..ab3363ea925e 100644 --- a/boards/arm/thingy91_nrf9160/thingy91_nrf9160_ns_defconfig +++ b/boards/arm/thingy91_nrf9160/thingy91_nrf9160_ns_defconfig @@ -24,15 +24,9 @@ CONFIG_SERIAL=y CONFIG_CONSOLE=y CONFIG_UART_CONSOLE=y -# Enable I2C -CONFIG_I2C=y - # Enable SPI CONFIG_SPI=y -# Enable power management IC ADP536x -CONFIG_ADP536X=y - # Disable entropy driver, as it's not yet implemented for nRF9160 CONFIG_ENTROPY_NRF5_RNG=n diff --git a/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst b/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst index 953ff3c302d8..af6c0c5c7bdf 100644 --- a/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst +++ b/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst @@ -599,7 +599,9 @@ nRF Security Other libraries --------------- -|no_changes_yet_note| +* :ref:`lib_adp536x` library: + + * Fixed issue where the adp536x driver was included in the immutable bootloader on Thingy:91 when :kconfig:option:`CONFIG_SECURE_BOOT` was enabled. Common Application Framework (CAF) ---------------------------------- diff --git a/lib/adp536x/Kconfig b/lib/adp536x/Kconfig index fa6e6a327b87..39a8abfcf7bb 100644 --- a/lib/adp536x/Kconfig +++ b/lib/adp536x/Kconfig @@ -7,5 +7,9 @@ config ADP536X bool "ADP536x" + default y + depends on !IS_BOOTLOADER_IMG + depends on DT_HAS_ADI_ADP5360_ENABLED + select I2C help Enable ADP536x diff --git a/subsys/bootloader/Kconfig b/subsys/bootloader/Kconfig index ae3ad5f57fbd..518a2cba9807 100644 --- a/subsys/bootloader/Kconfig +++ b/subsys/bootloader/Kconfig @@ -238,6 +238,13 @@ config SB_BPROT_IN_DEBUG endif # SECURE_BOOT_DEBUG endif # IS_SECURE_BOOTLOADER +config IS_BOOTLOADER_IMG + bool + default y if IS_SECURE_BOOTLOADER || MCUBOOT + help + Helper symbol which is set when the current image is a bootloader. This includes mcuboot + and the secure bootloader. + config NRF53_UPGRADE_NETWORK_CORE bool "Support updating nRF53 Network Core application" default y