Marti Bolivar | 51181cf | 2017-03-20 11:03:41 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017, Linaro Ltd |
David Vincze | b75c12a | 2019-03-22 14:58:33 +0100 | [diff] [blame] | 3 | * Copyright (c) 2019, Arm Limited |
| 4 | * |
Marti Bolivar | 51181cf | 2017-03-20 11:03:41 -0400 | [diff] [blame] | 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) |
Marti Bolivar | 3d9e3eb | 2017-09-20 16:28:57 -0400 | [diff] [blame] | 12 | /* |
| 13 | * Target-specific definitions are permitted in legacy cases that |
| 14 | * don't provide the information via DTS, etc. |
| 15 | */ |
Marti Bolivar | 51181cf | 2017-03-20 11:03:41 -0400 | [diff] [blame] | 16 | #include MCUBOOT_TARGET_CONFIG |
Marti Bolivar | 3d9e3eb | 2017-09-20 16:28:57 -0400 | [diff] [blame] | 17 | #else |
| 18 | /* |
| 19 | * Otherwise, the Zephyr SoC header and the DTS provide most |
| 20 | * everything we need. |
Marti Bolivar | 3d9e3eb | 2017-09-20 16:28:57 -0400 | [diff] [blame] | 21 | */ |
| 22 | #include <soc.h> |
Kumar Gala | 6e26e38 | 2020-05-07 19:31:57 -0500 | [diff] [blame] | 23 | #include <storage/flash_map.h> |
Marti Bolivar | 51181cf | 2017-03-20 11:03:41 -0400 | [diff] [blame] | 24 | |
Marti Bolivar | 3d9e3eb | 2017-09-20 16:28:57 -0400 | [diff] [blame] | 25 | #define FLASH_ALIGN FLASH_WRITE_BLOCK_SIZE |
| 26 | |
Sergey Koziakov | 3f0738d | 2019-12-02 22:48:44 +0300 | [diff] [blame] | 27 | #endif /* !defined(MCUBOOT_TARGET_CONFIG) */ |
| 28 | |
Kumar Gala | 9a5b951 | 2020-04-08 12:06:21 -0500 | [diff] [blame] | 29 | #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 Bolivar | dc4c42b | 2017-09-21 14:20:40 -0400 | [diff] [blame] | 33 | /* |
Marti Bolivar | 3d9e3eb | 2017-09-20 16:28:57 -0400 | [diff] [blame] | 34 | * Sanity check the target support. |
Marti Bolivar | 61038df | 2017-09-01 12:52:56 -0400 | [diff] [blame] | 35 | */ |
Kumar Gala | 32b61f3 | 2020-04-08 12:02:03 -0500 | [diff] [blame] | 36 | #if (!defined(CONFIG_XTENSA) && !defined(DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL)) || \ |
Kumar Gala | 9a5b951 | 2020-04-08 12:06:21 -0500 | [diff] [blame] | 37 | (defined(CONFIG_XTENSA) && !defined(JEDEC_SPI_NOR_0_LABEL)) || \ |
Marti Bolivar | 61038df | 2017-09-01 12:52:56 -0400 | [diff] [blame] | 38 | !defined(FLASH_ALIGN) || \ |
Kumar Gala | 6e26e38 | 2020-05-07 19:31:57 -0500 | [diff] [blame] | 39 | !(FLASH_AREA_LABEL_EXISTS(image_0)) || \ |
Andrzej Puzdrowski | fdff3e1 | 2020-09-15 08:23:25 +0200 | [diff] [blame^] | 40 | !(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 Bolivar | 61038df | 2017-09-01 12:52:56 -0400 | [diff] [blame] | 42 | #error "Target support is incomplete; cannot build mcuboot." |
| 43 | #endif |
| 44 | |
Andrzej Puzdrowski | 7024340 | 2020-05-11 14:20:29 +0200 | [diff] [blame] | 45 | #if (MCUBOOT_IMAGE_NUMBER == 2) && (!(FLASH_AREA_LABEL_EXISTS(image_2)) || \ |
| 46 | !(FLASH_AREA_LABEL_EXISTS(image_3))) |
David Vincze | b75c12a | 2019-03-22 14:58:33 +0100 | [diff] [blame] | 47 | #error "Target support is incomplete; cannot build mcuboot." |
Marti Bolivar | 51181cf | 2017-03-20 11:03:41 -0400 | [diff] [blame] | 48 | #endif |
David Vincze | b75c12a | 2019-03-22 14:58:33 +0100 | [diff] [blame] | 49 | |
| 50 | #endif /* H_TARGETS_TARGET_ */ |