Skip to content

Commit

Permalink
mcuboot: locating mcuboot module glue code in modules/mcuboot
Browse files Browse the repository at this point in the history
This commit introduces sdk-nrf as a module_ext_root in Zephyr.
This allows Zephyr glue code to be included automatically from
`<sdk-nrf-repo>/modules/<module-name>`.

sdk-nrf specific mcuboot glue code has been moved to `modules/mcuboot`
to use this principle.
Similar the `<mcuboot-repo>/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 <[email protected]>
  • Loading branch information
tejlmand authored and jfischer-no committed Jan 29, 2021
1 parent 0ac4f23 commit 7971211
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions cmake/mcuboot.cmake → modules/mcuboot/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 $<TARGET_PROPERTY:partition_manager,PM_MCUBOOT_PAD_SIZE>
Expand Down
37 changes: 37 additions & 0 deletions modules/mcuboot/Kconfig
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions modules/modules.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
set(ZEPHYR_MCUBOOT_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR}/mcuboot)
set(ZEPHYR_MCUBOOT_KCONFIG ${CMAKE_CURRENT_LIST_DIR}/mcuboot/Kconfig)
1 change: 1 addition & 0 deletions zephyr/module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ build:
settings:
board_root: .
dts_root: .
module_ext_root: .

0 comments on commit 7971211

Please sign in to comment.