1 /*
2  *  Copyright (C) 2017, Linaro Ltd
3  *  Copyright (c) 2019, Arm Limited
4  *
5  *  SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #ifndef H_TARGETS_TARGET_
9 #define H_TARGETS_TARGET_
10 
11 #if defined(MCUBOOT_TARGET_CONFIG)
12 /*
13  * Target-specific definitions are permitted in legacy cases that
14  * don't provide the information via DTS, etc.
15  */
16 #include MCUBOOT_TARGET_CONFIG
17 #else
18 /*
19  * Otherwise, the Zephyr SoC header and the DTS provide most
20  * everything we need.
21  */
22 #include <zephyr/devicetree.h>
23 #include <soc.h>
24 #include <zephyr/storage/flash_map.h>
25 
26 #define FLASH_ALIGN FLASH_WRITE_BLOCK_SIZE
27 
28 #endif /* !defined(MCUBOOT_TARGET_CONFIG) */
29 
30 /*
31  * Sanity check the target support.
32  */
33 #if (!defined(CONFIG_XTENSA) && !DT_HAS_CHOSEN(zephyr_flash_controller)) || \
34     (defined(CONFIG_XTENSA) && !DT_NODE_EXISTS(DT_INST(0, jedec_spi_nor)) && \
35     !defined(CONFIG_SOC_FAMILY_ESP32)) || \
36     !defined(FLASH_ALIGN) ||                  \
37     !(FIXED_PARTITION_EXISTS(slot0_partition)) || \
38     !(FIXED_PARTITION_EXISTS(slot1_partition) || CONFIG_SINGLE_APPLICATION_SLOT) || \
39     (defined(CONFIG_BOOT_SWAP_USING_SCRATCH) && !FIXED_PARTITION_EXISTS(scratch_partition))
40 #error "Target support is incomplete; cannot build mcuboot."
41 #endif
42 
43 #if (MCUBOOT_IMAGE_NUMBER == 2) && (!(FIXED_PARTITION_EXISTS(slot2_partition)) || \
44                                      !(FIXED_PARTITION_EXISTS(slot3_partition)))
45 #error "Target support is incomplete; cannot build mcuboot."
46 #endif
47 
48 #endif /* H_TARGETS_TARGET_ */
49