dts: mcuboot: Support for common overlays and mcuboot
When the Kconfig BOOTLOADER_MCUBOOT is selected, an overlay to place the image at the slot0 location is required. In order to avoid having to do this manually for all samples when targetting MCUboot, include the logic inside the dts.cmake script to prepend a new common.dts file that then conditionally includes mcuboot.overlay. Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This commit is contained in:
parent
06b9841675
commit
72684ef815
5 changed files with 41 additions and 2 deletions
|
@ -11,6 +11,7 @@
|
|||
set(GENERATED_DTS_BOARD_H ${PROJECT_BINARY_DIR}/include/generated/generated_dts_board.h)
|
||||
set(GENERATED_DTS_BOARD_CONF ${PROJECT_BINARY_DIR}/include/generated/generated_dts_board.conf)
|
||||
set_ifndef(DTS_SOURCE ${PROJECT_SOURCE_DIR}/boards/${ARCH}/${BOARD_FAMILY}/${BOARD_FAMILY}.dts)
|
||||
set_ifndef(DTS_COMMON_OVERLAYS ${PROJECT_SOURCE_DIR}/dts/common/common.dts)
|
||||
|
||||
message(STATUS "Generating zephyr/include/generated/generated_dts_board.h")
|
||||
|
||||
|
@ -21,6 +22,9 @@ if(CONFIG_HAS_DTS)
|
|||
string(REPLACE " " ";" DTC_OVERLAY_FILE_AS_LIST ${DTC_OVERLAY_FILE})
|
||||
endif()
|
||||
|
||||
# Prepend common overlays
|
||||
set(DTC_OVERLAY_FILE_AS_LIST ${DTS_COMMON_OVERLAYS} ${DTC_OVERLAY_FILE_AS_LIST})
|
||||
|
||||
set(
|
||||
dts_files
|
||||
${DTS_SOURCE}
|
||||
|
|
|
@ -907,6 +907,8 @@ following available sources, in order:
|
|||
:makevar:`DTC_OVERLAY_FILE` variable, either as set explicitly by the user
|
||||
or using one of the default values detailed below.
|
||||
|
||||
#. Common overlays conditionally included by :file:`dts/common/common.dts`.
|
||||
|
||||
#. The board's default DT configuration for the current :makevar:`BOARD`
|
||||
setting (i.e. the :file:`boards/ARCHITECTURE/BOARD/BOARD.dts`
|
||||
file in the Zephyr base directory).
|
||||
|
@ -928,6 +930,12 @@ checking the following until one is found, in order:
|
|||
If :makevar:`DTC_OVERLAY_FILE` specifies multiple files, they will be merged in
|
||||
order.
|
||||
|
||||
The build system will automatically prepend :file:`dts/common/common.dts` to
|
||||
:makevar:`DTC_OVERLAY_FILE`, which conditionally includes certain overlays that
|
||||
are considered common to all applications. This includes the required overlay
|
||||
for MCUboot chain-loading (located in :file:`dts/comon/mcuboot.overlay`)
|
||||
whenever the :option:`CONFIG_BOOTLOADER_MCUBOOT` is set using Kconfig.
|
||||
|
||||
Application-Specific Code
|
||||
*************************
|
||||
|
||||
|
|
9
dts/common/common.dts
Normal file
9
dts/common/common.dts
Normal file
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
* Common Device Tree source, used for conditionally pulling in features and
|
||||
* additions by the build system.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_BOOTLOADER_MCUBOOT
|
||||
#include "mcuboot.overlay"
|
||||
#endif
|
||||
|
10
dts/common/mcuboot.overlay
Normal file
10
dts/common/mcuboot.overlay
Normal file
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* Basic Device Tree overlay file for chain-loading by MCUboot.
|
||||
* Automatically pulled in when CONFIG_BOOTLOADER_MCUBOOT is set.
|
||||
*/
|
||||
|
||||
/ {
|
||||
chosen {
|
||||
zephyr,code-partition = &slot0_partition;
|
||||
};
|
||||
};
|
12
misc/Kconfig
12
misc/Kconfig
|
@ -317,8 +317,16 @@ config BOOTLOADER_MCUBOOT
|
|||
help
|
||||
This option signifies that the target uses MCUboot as a bootloader,
|
||||
or in other words that the image is to be chain-loaded by MCUboot.
|
||||
This sets several required options in order for the image generated
|
||||
to be bootable using the MCUboot open source bootloader.
|
||||
This sets several required build system and Device Tree options in
|
||||
order for the image generated to be bootable using the MCUboot open
|
||||
source bootloader. Currently this includes:
|
||||
|
||||
* Setting TEXT_LOAD_OFFSET to a default value that allows space for
|
||||
the MCUboot image header
|
||||
* Activating SW_VECTOR_RELAY on Cortex-M0 targets with no built-in
|
||||
vector relocation mechanisms
|
||||
* Including dts/common/mcuboot.overlay when building the Device
|
||||
Tree in order to place and link the image at the slot0 offset
|
||||
|
||||
config BOOTLOADER_KEXEC
|
||||
bool
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue