blob: 61dfd932246850ba4197ebd399ee496939dc1cd6 [file] [log] [blame]
Marti Bolivar51181cf2017-03-20 11:03:41 -04001/*
2 * Copyright (C) 2017, Linaro Ltd
David Vinczeb75c12a2019-03-22 14:58:33 +01003 * Copyright (c) 2019, Arm Limited
4 *
Marti Bolivar51181cf2017-03-20 11:03:41 -04005 * 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)
Marti Bolivar3d9e3eb2017-09-20 16:28:57 -040012/*
13 * Target-specific definitions are permitted in legacy cases that
14 * don't provide the information via DTS, etc.
15 */
Marti Bolivar51181cf2017-03-20 11:03:41 -040016#include MCUBOOT_TARGET_CONFIG
Marti Bolivar3d9e3eb2017-09-20 16:28:57 -040017#else
18/*
19 * Otherwise, the Zephyr SoC header and the DTS provide most
20 * everything we need.
Marti Bolivar3d9e3eb2017-09-20 16:28:57 -040021 */
Gerard Marull-Paretas3cd2cec2022-05-09 12:10:05 +020022#include <zephyr/devicetree.h>
Marti Bolivar3d9e3eb2017-09-20 16:28:57 -040023#include <soc.h>
Gerard Marull-Paretas3cd2cec2022-05-09 12:10:05 +020024#include <zephyr/storage/flash_map.h>
Marti Bolivar51181cf2017-03-20 11:03:41 -040025
Marti Bolivar3d9e3eb2017-09-20 16:28:57 -040026#define FLASH_ALIGN FLASH_WRITE_BLOCK_SIZE
27
Sergey Koziakov3f0738d2019-12-02 22:48:44 +030028#endif /* !defined(MCUBOOT_TARGET_CONFIG) */
29
Marti Bolivardc4c42b2017-09-21 14:20:40 -040030/*
Marti Bolivar3d9e3eb2017-09-20 16:28:57 -040031 * Sanity check the target support.
Marti Bolivar61038df2017-09-01 12:52:56 -040032 */
Gerard Marull-Paretasaa041a22022-03-25 12:22:29 +010033#if (!defined(CONFIG_XTENSA) && !DT_HAS_CHOSEN(zephyr_flash_controller)) || \
Marek Matej67693442023-01-23 17:54:36 +010034 (defined(CONFIG_XTENSA) && !DT_NODE_EXISTS(DT_INST(0, jedec_spi_nor)) && \
35 !defined(CONFIG_SOC_FAMILY_ESP32)) || \
Marti Bolivar61038df2017-09-01 12:52:56 -040036 !defined(FLASH_ALIGN) || \
Dominik Ermel3a82b6f2022-08-24 14:35:24 +000037 !(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))
Marti Bolivar61038df2017-09-01 12:52:56 -040040#error "Target support is incomplete; cannot build mcuboot."
41#endif
42
Dominik Ermel3a82b6f2022-08-24 14:35:24 +000043#if (MCUBOOT_IMAGE_NUMBER == 2) && (!(FIXED_PARTITION_EXISTS(slot2_partition)) || \
44 !(FIXED_PARTITION_EXISTS(slot3_partition)))
David Vinczeb75c12a2019-03-22 14:58:33 +010045#error "Target support is incomplete; cannot build mcuboot."
Marti Bolivar51181cf2017-03-20 11:03:41 -040046#endif
David Vinczeb75c12a2019-03-22 14:58:33 +010047
48#endif /* H_TARGETS_TARGET_ */