Skip to content

Commit 7e3d085

Browse files
New sample: mcuboot_external_config
Created a sample of how to configure MCUBoot build from an external repository. This sample provides no `main()` definition and reuses all logic from MCUBoot and other repositories. The functionality matches the existing functionality of mcuboot/boot/zephyr. NOTE: This commit required copying board and .conf files from mcuboot/boot/zephyr because the _current_ zephyr build system (about v3.2.0) does not fully support using APPLICATION_CONFIG_DIR with a list of files/directories in CONF_FILE and with boards/ beneath those settings. When APPLICATION_CONF_DIR was set to reference mcuboot/boot/zephyr/ and CONF_FILE referenced APPLICATION_CONFIG_DIR then here, the boot config did not pick up a board-specific configuration setting from APPLICATION_CONFIG_DIR, resulting in FLASH going from ~40000 to ~45000 bytes. This is captured in Zephyr Issue #51621. Verification: 1. (Pass) west build -p always -b nrf52840dk_nrf52840 \ mcuboot/zephyr/samples/mcuboot_external_config/ 2. (Pass) ./zephyr/scripts/twister --testsuite-root mcuboot/zephyr/samples/ Fixes #1410 Signed-off-by: Gregory Shue <[email protected]>
1 parent 178d6fc commit 7e3d085

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+913
-0
lines changed

zephyr/module.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
name: mcuboot
66
samples:
77
- boot/zephyr
8+
- zephyr/samples
89
build:
910
cmake: ./zephyr
1011
kconfig: ./zephyr/Kconfig
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) 2022 Legrand North America, LLC.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
cmake_minimum_required(VERSION 3.20.0)
5+
6+
# Add a common dts overlay necessary to ensure mcuboot is linked into,
7+
# and fits inside, the boot partition. (If the user specified a
8+
# DTC_OVERLAY_FILE on the CMake command line, we need to append onto
9+
# the list).
10+
set(DTC_OVERLAY_FILE
11+
"${DTC_OVERLAY_FILE};${CMAKE_CURRENT_LIST_DIR}/dts.overlay"
12+
CACHE STRING "" FORCE
13+
)
14+
15+
# NOTE: ${ZEPHYR_MCUBOOT_MODULE_DIR} requires delayed evaluation,
16+
# as it has not yet been defined. Relative paths must be used at this point.
17+
include(${CMAKE_CURRENT_LIST_DIR}/../../cmake/mcuboot_zephyr_runner_mass_erase.cmake)
18+
19+
# find_package(Zephyr) in order to load application boilerplate:
20+
# http://docs.zephyrproject.org/application/application.html
21+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
22+
project(mcuboot_exernal_config)
23+
24+
target_sources(app PRIVATE
25+
keys.c
26+
)
27+
28+
include(${ZEPHYR_MCUBOOT_MODULE_DIR}/zephyr/cmake/mcuboot_signature_key_file_generation.cmake)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.. _mcuboot_external_config:
2+
3+
MCUBoot External Config
4+
#######################
5+
6+
Overview
7+
********
8+
9+
A simple sample illustrating how to configure from a different module
10+
an MCUBoot image, using local keys and certificates.
11+
12+
NOTE: This references ${ZEPHYR_MCUBOOT_MODULE_DIR}/boot/zephyr
13+
for most configuration files for the verified set of boards. Other
14+
board configuration files will need to be provided locally.
15+
16+
Building and Running
17+
********************
18+
19+
This application can be built and executed on QEMU as follows:
20+
21+
.. code-block:: console
22+
23+
west build -b nrf52840dk_nrf52840 \
24+
bootloader/mcuboot/samples/zephyr_external_config
25+
26+
27+
Sample Output
28+
=============
29+
30+
None.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Disable Zephyr console
2+
CONFIG_CONSOLE=n
3+
4+
# MCUBoot settings
5+
CONFIG_BOOT_MAX_IMG_SECTORS=256
6+
7+
# MCUboot serial recovery
8+
CONFIG_MCUBOOT_SERIAL=y
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CONFIG_MULTITHREADING=y
2+
# Enable QSPI (MX25R64) - Slot 1 in QSPI
3+
CONFIG_NORDIC_QSPI_NOR=y
4+
CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
5+
CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=4
6+
CONFIG_BOOT_MAX_IMG_SECTORS=256
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Disable Zephyr console
2+
CONFIG_CONSOLE=n
3+
4+
# Multithreading
5+
CONFIG_MULTITHREADING=y
6+
7+
# MCUBoot settings
8+
CONFIG_BOOT_MAX_IMG_SECTORS=256
9+
10+
# MCUboot serial recovery
11+
CONFIG_MCUBOOT_SERIAL=y
12+
CONFIG_BOOT_SERIAL_DETECT_DELAY=450
13+
CONFIG_MCUBOOT_INDICATION_LED=y
14+
15+
# Size of mcuboot partition
16+
CONFIG_SIZE_OPTIMIZATIONS=y
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Disable Zephyr console
2+
CONFIG_CONSOLE=n
3+
CONFIG_CONSOLE_HANDLER=n
4+
CONFIG_UART_CONSOLE=n
5+
6+
# Multithreading
7+
CONFIG_MULTITHREADING=y
8+
9+
# MCUBoot settings
10+
CONFIG_BOOT_MAX_IMG_SECTORS=256
11+
12+
# MCUboot serial recovery
13+
CONFIG_MCUBOOT_SERIAL=y
14+
CONFIG_BOOT_SERIAL_DETECT_PORT="GPIO_0"
15+
CONFIG_BOOT_SERIAL_DETECT_PIN=12
16+
CONFIG_BOOT_SERIAL_DETECT_PIN_VAL=0
17+
CONFIG_BOOT_SERIAL_DETECT_DELAY=450
18+
CONFIG_MCUBOOT_INDICATION_LED=y
19+
20+
# Size of mcuboot partition
21+
CONFIG_SIZE_OPTIMIZATIONS=y
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_BOOT_MAX_IMG_SECTORS=256
2+
CONFIG_WATCHDOG=y
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_FLASH_SIMULATOR=y
2+
CONFIG_FLASH_SIMULATOR_UNALIGNED_READ=y
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_WATCHDOG=y

0 commit comments

Comments
 (0)