blob: 97365c226db0de3531433f4ad5a0f7e760f4552f [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-Paretasaa041a22022-03-25 12:22:29 +010022#include <devicetree.h>
Marti Bolivar3d9e3eb2017-09-20 16:28:57 -040023#include <soc.h>
Kumar Gala6e26e382020-05-07 19:31:57 -050024#include <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
Kumar Gala9a5b9512020-04-08 12:06:21 -050030#if DT_NODE_HAS_PROP(DT_INST(0, jedec_spi_nor), label)
31#define JEDEC_SPI_NOR_0_LABEL DT_LABEL(DT_INST(0, jedec_spi_nor))
32#endif
33
Marti Bolivardc4c42b2017-09-21 14:20:40 -040034/*
Marti Bolivar3d9e3eb2017-09-20 16:28:57 -040035 * Sanity check the target support.
Marti Bolivar61038df2017-09-01 12:52:56 -040036 */
Gerard Marull-Paretasaa041a22022-03-25 12:22:29 +010037#if (!defined(CONFIG_XTENSA) && !DT_HAS_CHOSEN(zephyr_flash_controller)) || \
Kumar Gala9a5b9512020-04-08 12:06:21 -050038 (defined(CONFIG_XTENSA) && !defined(JEDEC_SPI_NOR_0_LABEL)) || \
Marti Bolivar61038df2017-09-01 12:52:56 -040039 !defined(FLASH_ALIGN) || \
Kumar Gala6e26e382020-05-07 19:31:57 -050040 !(FLASH_AREA_LABEL_EXISTS(image_0)) || \
Andrzej Puzdrowskifdff3e12020-09-15 08:23:25 +020041 !(FLASH_AREA_LABEL_EXISTS(image_1) || CONFIG_SINGLE_APPLICATION_SLOT) || \
Andrzej Puzdrowskic49d7c92021-05-13 12:52:34 +020042 (defined(CONFIG_BOOT_SWAP_USING_SCRATCH) && !FLASH_AREA_LABEL_EXISTS(image_scratch))
Marti Bolivar61038df2017-09-01 12:52:56 -040043#error "Target support is incomplete; cannot build mcuboot."
44#endif
45
Andrzej Puzdrowski70243402020-05-11 14:20:29 +020046#if (MCUBOOT_IMAGE_NUMBER == 2) && (!(FLASH_AREA_LABEL_EXISTS(image_2)) || \
47 !(FLASH_AREA_LABEL_EXISTS(image_3)))
David Vinczeb75c12a2019-03-22 14:58:33 +010048#error "Target support is incomplete; cannot build mcuboot."
Marti Bolivar51181cf2017-03-20 11:03:41 -040049#endif
David Vinczeb75c12a2019-03-22 14:58:33 +010050
51#endif /* H_TARGETS_TARGET_ */