Skip to content

Commit e0afbd1

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. The sample is located within `$mcuboot/zephyr/samples/modules/mcuboot/` so that the directory path matches that used in Zephyr for samples of external modules. The directory name `mcuboot_external_config` intentionally begins with the module name to help avoid futures conflict with samples that may be defined in other repositories. Together, this pattern supports easy integration of this sample documentation with sample documentation in 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/modules/mcuboot/mcuboot_external_config/ 2. (Pass) ./zephyr/scripts/twister --testsuite-root mcuboot/zephyr/samples/ Fixes #1410 Signed-off-by: Gregory Shue <[email protected]>
1 parent ebca6cd commit e0afbd1

Some content is hidden

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

48 files changed

+1045
-0
lines changed

zephyr/module.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
name: mcuboot
77
samples:
88
- boot/zephyr
9+
- zephyr/samples
910
build:
1011
cmake: ./zephyr
1112
kconfig: ./zephyr/Kconfig
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
# NOTE: ${ZEPHYR_MCUBOOT_MODULE_DIR} requires delayed evaluation,
7+
# as it has not yet been defined. Relative paths must be used at this point.
8+
include(${CMAKE_CURRENT_LIST_DIR}/../../../../cmake/mcuboot_zephyr_runner_mass_erase.cmake)
9+
10+
# find_package(Zephyr) in order to load application boilerplate:
11+
# http://docs.zephyrproject.org/application/application.html
12+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
13+
project(mcuboot_exernal_config)
14+
15+
target_sources(app PRIVATE
16+
keys.c
17+
)
18+
19+
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/modules/mcuboot/mcuboot_external_config
25+
26+
27+
Sample Output
28+
=============
29+
30+
None.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/ {
2+
chosen {
3+
zephyr,code-partition = &boot_partition;
4+
};
5+
};
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

0 commit comments

Comments
 (0)