From 7971211ea2d05a1a1bf5ffc5a4f3c4a728520f56 Mon Sep 17 00:00:00 2001 From: Torsten Rasmussen Date: Fri, 22 Jan 2021 17:17:37 +0100 Subject: [PATCH] mcuboot: locating mcuboot module glue code in `modules/mcuboot` This commit introduces sdk-nrf as a module_ext_root in Zephyr. This allows Zephyr glue code to be included automatically from `/modules/`. sdk-nrf specific mcuboot glue code has been moved to `modules/mcuboot` to use this principle. Similar the `/zephyr/Kconfig` file has been moved to sdk-nrf. As minor cleanup in the process of moving this code, the CMake variable `MCUBOOT_DIR` has been adjusted to `ZEPHYR_MCUBOOT_MODULE_DIR`. Add codeowners for modules and modules/mcuboot. Signed-off-by: Torsten Rasmussen --- CODEOWNERS | 2 + .../mcuboot/CMakeLists.txt | 13 ++++--- modules/mcuboot/Kconfig | 37 +++++++++++++++++++ modules/modules.cmake | 2 + zephyr/module.yml | 1 + 5 files changed, 49 insertions(+), 6 deletions(-) rename cmake/mcuboot.cmake => modules/mcuboot/CMakeLists.txt (96%) create mode 100644 modules/mcuboot/Kconfig create mode 100644 modules/modules.cmake diff --git a/CODEOWNERS b/CODEOWNERS index 6777ab3b72e2..dba891b8b9fa 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -73,6 +73,8 @@ Kconfig* @tejlmand /lib/st25r3911b/ @grochu /lib/supl/ @rlubos @evenl /lib/date_time/ @simensrostad +/modules/ @tejlmand +/modules/mcuboot/ @nvlsianpu /samples/sensor/bh1749/ @wlgrd /samples/bluetooth/ @joerchan @lemrey @carlescufi /samples/bluetooth/mesh/ @trond-snekvik @joerchan diff --git a/cmake/mcuboot.cmake b/modules/mcuboot/CMakeLists.txt similarity index 96% rename from cmake/mcuboot.cmake rename to modules/mcuboot/CMakeLists.txt index 8d797c2b972b..77dae8ecb356 100644 --- a/cmake/mcuboot.cmake +++ b/modules/mcuboot/CMakeLists.txt @@ -1,5 +1,6 @@ -# Included by mcuboot/zephyr/CMakeLists.txt -set(MCUBOOT_DIR ${ZEPHYR_BASE}/../bootloader/mcuboot) +add_subdirectory(${ZEPHYR_MCUBOOT_MODULE_DIR}/boot/bootutil/zephyr + ${CMAKE_CURRENT_BINARY_DIR}/boot/bootutil/zephyr +) if(CONFIG_BOOTLOADER_MCUBOOT) @@ -91,7 +92,7 @@ if(CONFIG_BOOTLOADER_MCUBOOT) add_child_image( NAME mcuboot - SOURCE_DIR ${MCUBOOT_DIR}/boot/zephyr + SOURCE_DIR ${ZEPHYR_MCUBOOT_MODULE_DIR}/boot/zephyr ) set(merged_hex_file @@ -135,13 +136,13 @@ if(CONFIG_BOOTLOADER_MCUBOOT) --------------------------------------------------------- \n" ) - set(mcuboot_key_file ${MCUBOOT_DIR}/${CONFIG_BOOT_SIGNATURE_KEY_FILE}) + set(mcuboot_key_file ${ZEPHYR_MCUBOOT_MODULE_DIR}/${CONFIG_BOOT_SIGNATURE_KEY_FILE}) endif() if(CONFIG_SIGN_IMAGES) execute_process(COMMAND ${PYTHON_EXECUTABLE} - ${MCUBOOT_DIR}/scripts/imgtool.py + ${ZEPHYR_MCUBOOT_MODULE_DIR}/scripts/imgtool.py getpriv -k ${mcuboot_key_file} OUTPUT_QUIET ERROR_QUIET @@ -157,7 +158,7 @@ if(CONFIG_BOOTLOADER_MCUBOOT) set(sign_cmd ${PYTHON_EXECUTABLE} - ${MCUBOOT_DIR}/scripts/imgtool.py + ${ZEPHYR_MCUBOOT_MODULE_DIR}/scripts/imgtool.py sign --key ${mcuboot_key_file} --header-size $ diff --git a/modules/mcuboot/Kconfig b/modules/mcuboot/Kconfig new file mode 100644 index 000000000000..b3707c04f3a1 --- /dev/null +++ b/modules/mcuboot/Kconfig @@ -0,0 +1,37 @@ +menu "MCUboot" + +if BOOTLOADER_MCUBOOT + +# The name of this configuration needs to match the requirements set by the +# script `partition_manager.py`. See `pm.yml` in the application directory +# of MCUBoot. +module=MCUBOOT +source "${ZEPHYR_BASE}/../nrf/subsys/partition_manager/Kconfig.template.build_strategy" + +config MCUBOOT_IMAGE_VERSION + string "Image version" + default "0.0.0+0" + help + Value to be passed as 'version' argument to 'imgtool.py' when + creating signed image. Note that no semantics are connected to + this variable. It does not provide downgrade prevention, and is only + valuable for debugging purposes. Format: maj.min.rev+build with + latter parts optional. + +# HACK: NCS temphack to keep our imgtool integration working now that +# there is no CONFIG_DT_* CMake namespace anymore. Use Zephyr +# kconfigfunctions to thread the flash write block size through +# Kconfig so it can be accessed from CMake. Needs a better solution. +DT_ZEPHYR_FLASH := zephyr,flash +DT_CHOSEN_ZEPHYR_FLASH := $(dt_chosen_path,$(DT_ZEPHYR_FLASH)) +config MCUBOOT_FLASH_WRITE_BLOCK_SIZE + int + default $(dt_node_int_prop_int,$(DT_CHOSEN_ZEPHYR_FLASH),write-block-size) + +endif # BOOTLOADER_MCUBOOT + +config DT_FLASH_WRITE_BLOCK_SIZE + int + default $(dt_node_int_prop_int,$(DT_CHOSEN_ZEPHYR_FLASH),write-block-size) + +endmenu diff --git a/modules/modules.cmake b/modules/modules.cmake new file mode 100644 index 000000000000..12a60730edcc --- /dev/null +++ b/modules/modules.cmake @@ -0,0 +1,2 @@ +set(ZEPHYR_MCUBOOT_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR}/mcuboot) +set(ZEPHYR_MCUBOOT_KCONFIG ${CMAKE_CURRENT_LIST_DIR}/mcuboot/Kconfig) diff --git a/zephyr/module.yml b/zephyr/module.yml index 8f493fb207e2..455ec11f6dc8 100644 --- a/zephyr/module.yml +++ b/zephyr/module.yml @@ -4,3 +4,4 @@ build: settings: board_root: . dts_root: . + module_ext_root: .