blob: 1b0c8f52fb13db5e02895eca121e28cbc9704353 [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 */
22#include <soc.h>
Kumar Gala6e26e382020-05-07 19:31:57 -050023#include <storage/flash_map.h>
Marti Bolivar51181cf2017-03-20 11:03:41 -040024
Marti Bolivar3d9e3eb2017-09-20 16:28:57 -040025#define FLASH_ALIGN FLASH_WRITE_BLOCK_SIZE
26
Sergey Koziakov3f0738d2019-12-02 22:48:44 +030027#endif /* !defined(MCUBOOT_TARGET_CONFIG) */
28
Kumar Gala9a5b9512020-04-08 12:06:21 -050029#if DT_NODE_HAS_PROP(DT_INST(0, jedec_spi_nor), label)
30#define JEDEC_SPI_NOR_0_LABEL DT_LABEL(DT_INST(0, jedec_spi_nor))
31#endif
32
Marti Bolivardc4c42b2017-09-21 14:20:40 -040033/*
Marti Bolivar3d9e3eb2017-09-20 16:28:57 -040034 * Sanity check the target support.
Marti Bolivar61038df2017-09-01 12:52:56 -040035 */
Kumar Gala32b61f32020-04-08 12:02:03 -050036#if (!defined(CONFIG_XTENSA) && !defined(DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL)) || \
Kumar Gala9a5b9512020-04-08 12:06:21 -050037 (defined(CONFIG_XTENSA) && !defined(JEDEC_SPI_NOR_0_LABEL)) || \
Marti Bolivar61038df2017-09-01 12:52:56 -040038 !defined(FLASH_ALIGN) || \
Kumar Gala6e26e382020-05-07 19:31:57 -050039 !(FLASH_AREA_LABEL_EXISTS(image_0)) || \
Andrzej Puzdrowskifdff3e12020-09-15 08:23:25 +020040 !(FLASH_AREA_LABEL_EXISTS(image_1) || CONFIG_SINGLE_APPLICATION_SLOT) || \
41 (!defined(CONFIG_BOOT_SWAP_USING_MOVE) && !FLASH_AREA_LABEL_EXISTS(image_scratch) && !defined(CONFIG_SINGLE_APPLICATION_SLOT))
Marti Bolivar61038df2017-09-01 12:52:56 -040042#error "Target support is incomplete; cannot build mcuboot."
43#endif
44
Andrzej Puzdrowski70243402020-05-11 14:20:29 +020045#if (MCUBOOT_IMAGE_NUMBER == 2) && (!(FLASH_AREA_LABEL_EXISTS(image_2)) || \
46 !(FLASH_AREA_LABEL_EXISTS(image_3)))
David Vinczeb75c12a2019-03-22 14:58:33 +010047#error "Target support is incomplete; cannot build mcuboot."
Marti Bolivar51181cf2017-03-20 11:03:41 -040048#endif
David Vinczeb75c12a2019-03-22 14:58:33 +010049
50#endif /* H_TARGETS_TARGET_ */