77
88cmake_minimum_required (VERSION 3.13.1)
99
10- # Enable Zephyr runner options which request mass erase if so
11- # configured.
12- #
13- # Note that this also disables the default "leave" option when
14- # targeting STM32 DfuSe devices with dfu-util, making the chip stay in
15- # the bootloader after flashing.
16- #
17- # That's the right thing, because mcuboot has nothing to do since the
18- # chip was just erased. The next thing the user is going to want to do
19- # is flash the application. (Developers can reset DfuSE devices
20- # manually to test mcuboot behavior on an otherwise erased flash
21- # device.)
22- macro (app_set_runner_args)
23- if (CONFIG_ZEPHYR_TRY_MASS_ERASE)
24- board_runner_args(dfu-util "--dfuse-modifiers=force:mass-erase" )
25- board_runner_args(pyocd "--flash-opt=-e=chip" )
26- board_runner_args(nrfjprog "--erase" )
27- endif ()
28- endmacro ()
10+ # NOTE: ${ZEPHYR_MCUBOOT_MODULE_DIR} requires delayed evaluation,
11+ # as it has not yet been defined. Relative paths must be used at this point.
12+ include (${CMAKE_CURRENT_LIST_DIR} /../../zephyr/cmake/mcuboot_zephyr_runner_mass_erase.cmake)
2913
3014# find_package(Zephyr) in order to load application boilerplate:
3115# http://docs.zephyrproject.org/application/application.html
@@ -36,41 +20,4 @@ target_sources(app PRIVATE
3620 keys.c
3721 )
3822
39- if (NOT CONFIG_BOOT_SIGNATURE_KEY_FILE STREQUAL "" )
40- # CONF_FILE points to the KConfig configuration files of the bootloader.
41- foreach (filepath ${CONF_FILE} )
42- file (READ ${filepath} temp_text)
43- string (FIND "${temp_text} " ${CONFIG_BOOT_SIGNATURE_KEY_FILE} match)
44- if (${match} GREATER_EQUAL 0)
45- if (NOT DEFINED CONF_DIR)
46- get_filename_component (CONF_DIR ${filepath} DIRECTORY )
47- else ()
48- message (FATAL_ERROR "Signature key file defined in multiple conf files" )
49- endif ()
50- endif ()
51- endforeach ()
52-
53- if (IS_ABSOLUTE ${CONFIG_BOOT_SIGNATURE_KEY_FILE} )
54- set (KEY_FILE ${CONFIG_BOOT_SIGNATURE_KEY_FILE} )
55- elseif ((DEFINED CONF_DIR) AND
56- (EXISTS ${CONF_DIR} /${CONFIG_BOOT_SIGNATURE_KEY_FILE} ))
57- set (KEY_FILE ${CONF_DIR} /${CONFIG_BOOT_SIGNATURE_KEY_FILE} )
58- else ()
59- set (KEY_FILE ${ZEPHYR_MCUBOOT_MODULE_DIR} /${CONFIG_BOOT_SIGNATURE_KEY_FILE} )
60- endif ()
61- message ("MCUBoot bootloader key file: ${KEY_FILE} " )
62-
63- set (GENERATED_PUBKEY ${ZEPHYR_BINARY_DIR} /autogen-pubkey.c)
64- add_custom_command (
65- OUTPUT ${GENERATED_PUBKEY}
66- COMMAND
67- ${PYTHON_EXECUTABLE}
68- ${ZEPHYR_MCUBOOT_MODULE_DIR} /scripts/imgtool.py
69- getpub
70- -k
71- ${KEY_FILE}
72- > ${GENERATED_PUBKEY}
73- DEPENDS ${KEY_FILE}
74- )
75- zephyr_library_sources(${GENERATED_PUBKEY} )
76- endif ()
23+ include (${ZEPHYR_MCUBOOT_MODULE_DIR} /zephyr/cmake/mcuboot_signature_key_file_generation.cmake)
0 commit comments