@@ -11,34 +11,11 @@ cmake_minimum_required(VERSION 3.13.1)
1111# and fits inside, the boot partition. (If the user specified a
1212# DTC_OVERLAY_FILE on the CMake command line, we need to append onto
1313# the list).
14- if (DTC_OVERLAY_FILE)
15- set (DTC_OVERLAY_FILE
16- "${DTC_OVERLAY_FILE} ${CMAKE_CURRENT_LIST_DIR} /dts.overlay"
17- CACHE STRING "" FORCE
18- )
19- else ()
20- set (DTC_OVERLAY_FILE ${CMAKE_CURRENT_LIST_DIR} /dts.overlay)
21- endif ()
14+ list (APPEND DTC_OVERLAY_FILE ${CMAKE_CURRENT_LIST_DIR} /dts.overlay)
2215
23- # Enable Zephyr runner options which request mass erase if so
24- # configured.
25- #
26- # Note that this also disables the default "leave" option when
27- # targeting STM32 DfuSe devices with dfu-util, making the chip stay in
28- # the bootloader after flashing.
29- #
30- # That's the right thing, because mcuboot has nothing to do since the
31- # chip was just erased. The next thing the user is going to want to do
32- # is flash the application. (Developers can reset DfuSE devices
33- # manually to test mcuboot behavior on an otherwise erased flash
34- # device.)
35- macro (app_set_runner_args)
36- if (CONFIG_ZEPHYR_TRY_MASS_ERASE)
37- board_runner_args(dfu-util "--dfuse-modifiers=force:mass-erase" )
38- board_runner_args(pyocd "--flash-opt=-e=chip" )
39- board_runner_args(nrfjprog "--erase" )
40- endif ()
41- endmacro ()
16+ # NOTE: ${ZEPHYR_MCUBOOT_MODULE_DIR} requires delayed evaluation,
17+ # as it has not yet been defined. Relative paths must be used at this point.
18+ include (${CMAKE_CURRENT_LIST_DIR} /../../zephyr/cmake/mcuboot_zephyr_runner_mass_erase.cmake)
4219
4320# find_package(Zephyr) in order to load application boilerplate:
4421# http://docs.zephyrproject.org/application/application.html
@@ -49,41 +26,4 @@ target_sources(app PRIVATE
4926 keys.c
5027 )
5128
52- if (NOT CONFIG_BOOT_SIGNATURE_KEY_FILE STREQUAL "" )
53- # CONF_FILE points to the KConfig configuration files of the bootloader.
54- foreach (filepath ${CONF_FILE} )
55- file (READ ${filepath} temp_text)
56- string (FIND "${temp_text} " ${CONFIG_BOOT_SIGNATURE_KEY_FILE} match)
57- if (${match} GREATER_EQUAL 0)
58- if (NOT DEFINED CONF_DIR)
59- get_filename_component (CONF_DIR ${filepath} DIRECTORY )
60- else ()
61- message (FATAL_ERROR "Signature key file defined in multiple conf files" )
62- endif ()
63- endif ()
64- endforeach ()
65-
66- if (IS_ABSOLUTE ${CONFIG_BOOT_SIGNATURE_KEY_FILE} )
67- set (KEY_FILE ${CONFIG_BOOT_SIGNATURE_KEY_FILE} )
68- elseif ((DEFINED CONF_DIR) AND
69- (EXISTS ${CONF_DIR} /${CONFIG_BOOT_SIGNATURE_KEY_FILE} ))
70- set (KEY_FILE ${CONF_DIR} /${CONFIG_BOOT_SIGNATURE_KEY_FILE} )
71- else ()
72- set (KEY_FILE ${ZEPHYR_MCUBOOT_MODULE_DIR} /${CONFIG_BOOT_SIGNATURE_KEY_FILE} )
73- endif ()
74- message ("MCUBoot bootloader key file: ${KEY_FILE} " )
75-
76- set (GENERATED_PUBKEY ${ZEPHYR_BINARY_DIR} /autogen-pubkey.c)
77- add_custom_command (
78- OUTPUT ${GENERATED_PUBKEY}
79- COMMAND
80- ${PYTHON_EXECUTABLE}
81- ${ZEPHYR_MCUBOOT_MODULE_DIR} /scripts/imgtool.py
82- getpub
83- -k
84- ${KEY_FILE}
85- > ${GENERATED_PUBKEY}
86- DEPENDS ${KEY_FILE}
87- )
88- zephyr_library_sources(${GENERATED_PUBKEY} )
89- endif ()
29+ include (${ZEPHYR_MCUBOOT_MODULE_DIR} /zephyr/cmake/mcuboot_signature_key_file_generation.cmake)
0 commit comments