Browse Source

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>
pull/6079/head
Carles Cufi 8 years ago committed by Anas Nashif
parent
commit
72684ef815
  1. 4
      cmake/dts.cmake
  2. 8
      doc/application/application.rst
  3. 9
      dts/common/common.dts
  4. 10
      dts/common/mcuboot.overlay
  5. 12
      misc/Kconfig

4
cmake/dts.cmake

@ -11,6 +11,7 @@ @@ -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) @@ -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}

8
doc/application/application.rst

@ -907,6 +907,8 @@ following available sources, in order: @@ -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: @@ -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

@ -0,0 +1,9 @@ @@ -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

@ -0,0 +1,10 @@ @@ -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

@ -317,8 +317,16 @@ config BOOTLOADER_MCUBOOT @@ -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…
Cancel
Save