|
3 | 3 | # |
4 | 4 | # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause |
5 | 5 | # |
| 6 | +include(${ZEPHYR_NRF_MODULE_DIR}/cmake/sysbuild/bootloader_dts_utils.cmake) |
6 | 7 |
|
7 | | -function(setup_bootconf_data) |
8 | | - if(SB_CONFIG_PARTITION_MANAGER) |
9 | | - add_custom_target(bootconf_target |
10 | | - DEPENDS ${CMAKE_BINARY_DIR}/bootconf.hex |
11 | | - ) |
| 8 | +set(bootconf_hex ${CMAKE_BINARY_DIR}/bootconf.hex) |
| 9 | +set(bootconf_dependency) |
12 | 10 |
|
13 | | - add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/bootconf.hex |
14 | | - COMMAND ${Python3_EXECUTABLE} |
15 | | - ${ZEPHYR_NRF_MODULE_DIR}/scripts/reglock.py |
16 | | - --output ${CMAKE_BINARY_DIR}/bootconf.hex |
17 | | - --size $<TARGET_PROPERTY:partition_manager,PM_B0_SIZE> |
18 | | - --soc ${SB_CONFIG_SOC} |
19 | | - DEPENDS ${APPLICATION_BINARY_DIR}/pm.config |
20 | | - VERBATIM |
21 | | - ) |
| 11 | +if(SB_CONFIG_PARTITION_MANAGER) |
| 12 | + set(bootconf_size $<TARGET_PROPERTY:partition_manager,PM_B0_SIZE>) |
| 13 | + set(bootconf_dependency ${APPLICATION_BINARY_DIR}/pm.config) |
| 14 | +else() |
| 15 | + dt_partition_size(bootconf_size LABEL b0_partition TARGET b0 REQUIRED) |
| 16 | +endif() |
22 | 17 |
|
23 | | - set_property( |
24 | | - GLOBAL PROPERTY |
25 | | - bootconf_PM_HEX_FILE |
26 | | - ${CMAKE_BINARY_DIR}/bootconf.hex |
27 | | - ) |
| 18 | +# bootconf.hex is only created when there is b0_partition, which |
| 19 | +# indicates that b0 is used. |
| 20 | +if(NOT bootconf_size EQUAL 0) |
| 21 | + add_custom_command(OUTPUT ${bootconf_hex} |
| 22 | + COMMAND ${Python3_EXECUTABLE} |
| 23 | + ${ZEPHYR_NRF_MODULE_DIR}/scripts/reglock.py |
| 24 | + --output ${bootconf_hex} |
| 25 | + --size ${bootconf_size} |
| 26 | + --soc ${SB_CONFIG_SOC} |
| 27 | + DEPENDS ${bootconf_dependency} |
| 28 | + VERBATIM |
| 29 | + ) |
| 30 | +else() |
| 31 | + # Whether we have this CMake invoked or not is controlled by paths in |
| 32 | + # scripts that invoke; it is expected to be called when Secure Bootloader is |
| 33 | + # build, which means that the B0 partition for it also exists. If these |
| 34 | + # expectations are not met and somehow we have this part invoked, this means |
| 35 | + # that bootconf build has been invoked for something it can not handle. |
| 36 | + message(FATAL_ERROR "bootconf.hex has nothing to protect." |
| 37 | + "CMake path that should not have been taken?" |
| 38 | + ) |
| 39 | +endif() |
28 | 40 |
|
29 | | - set_property( |
30 | | - GLOBAL PROPERTY |
31 | | - bootconf_PM_TARGET |
32 | | - bootconf_target |
33 | | - ) |
34 | | - endif() |
35 | | -endfunction() |
| 41 | +add_custom_target(bootconf_target |
| 42 | + DEPENDS ${bootconf_hex} |
| 43 | +) |
36 | 44 |
|
37 | | -setup_bootconf_data() |
| 45 | +if(SB_CONFIG_PARTITION_MANAGER) |
| 46 | + set_property( |
| 47 | + GLOBAL PROPERTY |
| 48 | + bootconf_PM_HEX_FILE |
| 49 | + ${bootconf_hex} |
| 50 | + ) |
| 51 | + |
| 52 | + set_property( |
| 53 | + GLOBAL PROPERTY |
| 54 | + bootconf_PM_TARGET |
| 55 | + bootconf_target |
| 56 | + ) |
| 57 | +else() |
| 58 | + # Add the bootconf with b0 as bootconf is supposed to protect it. |
| 59 | + add_dependencies(b0 bootconf_target) |
| 60 | +endif() |
0 commit comments