Skip to content

Commit 883b240

Browse files
Duplicate local configuration files
In order to achieve the same configuration settings as used in mcuboot/boot/zephyr with the current Zephyr build system (zephyr_v3.2.0) AND follow a pattern that works across repositories, the config files local to one project (e.g., prj.conf) must be duplicated into another project. Incremental verification: 1. (Pass) west build -p always -b nrf52840dk_nrf52840 mcuboot/boot/zephyr 2. (Pass) ./zephyr/scripts/twister --testsuite-root zephyr/tests/subsys/dfu 3. (Pass) ./zephyr/scripts/twister --testsuite-root zephyr/samples/subsys/mgmt/mcumgr/smp_svr 4. (Pass) ./zephyr/scripts/twister --testsuite-root mcuboot/boot/zephyr 5. (Pass) ./zephyr/scripts/twister --testsuite-root mcuboot/samples/zephyr_exernal_config Resolve #1410 Signed-off-by: Gregory SHUE <[email protected]>
1 parent 256ca06 commit 883b240

Some content is hidden

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

44 files changed

+898
-1
lines changed

samples/zephyr_external_config/CMakeLists.txt

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,85 @@
33

44
cmake_minimum_required(VERSION 3.20.0)
55

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+
if(DTC_OVERLAY_FILE)
11+
set(DTC_OVERLAY_FILE
12+
"${DTC_OVERLAY_FILE} ${CMAKE_CURRENT_LIST_DIR}/dts.overlay"
13+
CACHE STRING "" FORCE
14+
)
15+
else()
16+
set(DTC_OVERLAY_FILE ${CMAKE_CURRENT_LIST_DIR}/dts.overlay)
17+
endif()
18+
19+
# Enable Zephyr runner options which request mass erase if so
20+
# configured.
21+
#
22+
# Note that this also disables the default "leave" option when
23+
# targeting STM32 DfuSe devices with dfu-util, making the chip stay in
24+
# the bootloader after flashing.
25+
#
26+
# That's the right thing, because mcuboot has nothing to do since the
27+
# chip was just erased. The next thing the user is going to want to do
28+
# is flash the application. (Developers can reset DfuSE devices
29+
# manually to test mcuboot behavior on an otherwise erased flash
30+
# device.)
31+
macro(app_set_runner_args)
32+
if(CONFIG_ZEPHYR_TRY_MASS_ERASE)
33+
board_runner_args(dfu-util "--dfuse-modifiers=force:mass-erase")
34+
board_runner_args(pyocd "--flash-opt=-e=chip")
35+
board_runner_args(nrfjprog "--erase")
36+
endif()
37+
endmacro()
38+
39+
# find_package(Zephyr) in order to load application boilerplate:
40+
# http://docs.zephyrproject.org/application/application.html
641
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
742
project(mcuboot_exernal_config)
843

944
target_sources(app PRIVATE empty.c)
45+
46+
target_sources(app PRIVATE
47+
keys.c
48+
)
49+
50+
if(NOT CONFIG_BOOT_SIGNATURE_KEY_FILE STREQUAL "")
51+
# CONF_FILE points to the KConfig configuration files of the bootloader.
52+
foreach (filepath ${CONF_FILE})
53+
file(READ ${filepath} temp_text)
54+
string(FIND "${temp_text}" ${CONFIG_BOOT_SIGNATURE_KEY_FILE} match)
55+
if (${match} GREATER_EQUAL 0)
56+
if (NOT DEFINED CONF_DIR)
57+
get_filename_component(CONF_DIR ${filepath} DIRECTORY)
58+
else()
59+
message(FATAL_ERROR "Signature key file defined in multiple conf files")
60+
endif()
61+
endif()
62+
endforeach()
63+
64+
if(IS_ABSOLUTE ${CONFIG_BOOT_SIGNATURE_KEY_FILE})
65+
set(KEY_FILE ${CONFIG_BOOT_SIGNATURE_KEY_FILE})
66+
elseif((DEFINED CONF_DIR) AND
67+
(EXISTS ${CONF_DIR}/${CONFIG_BOOT_SIGNATURE_KEY_FILE}))
68+
set(KEY_FILE ${CONF_DIR}/${CONFIG_BOOT_SIGNATURE_KEY_FILE})
69+
else()
70+
set(KEY_FILE ${ZEPHYR_MCUBOOT_MODULE_DIR}/${CONFIG_BOOT_SIGNATURE_KEY_FILE})
71+
endif()
72+
message("MCUBoot bootloader key file: ${KEY_FILE}")
73+
74+
set(GENERATED_PUBKEY ${ZEPHYR_BINARY_DIR}/autogen-pubkey.c)
75+
add_custom_command(
76+
OUTPUT ${GENERATED_PUBKEY}
77+
COMMAND
78+
${PYTHON_EXECUTABLE}
79+
${ZEPHYR_MCUBOOT_MODULE_DIR}/scripts/imgtool.py
80+
getpub
81+
-k
82+
${KEY_FILE}
83+
> ${GENERATED_PUBKEY}
84+
DEPENDS ${KEY_FILE}
85+
)
86+
zephyr_library_sources(${GENERATED_PUBKEY})
87+
endif()
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
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CONFIG_DEBUG=n
2+
CONFIG_I2C=n
3+
CONFIG_BOOT_MAX_IMG_SECTORS=512
4+
CONFIG_BOOT_WAIT_FOR_USB_DFU=y
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright (c) 2018 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
/ {
7+
sram0: memory@be000000 {
8+
device_type = "memory";
9+
compatible = "mmio-sram";
10+
reg = <0xbe000000 0x30000>;
11+
};
12+
};
13+

0 commit comments

Comments
 (0)