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 | */ |
Gerard Marull-Paretas | 3cd2cec | 2022-05-09 12:10:05 +0200 | [diff] [blame] | 22 | #include <zephyr/devicetree.h> |
Marti Bolivar | 3d9e3eb | 2017-09-20 16:28:57 -0400 | [diff] [blame] | 23 | #include <soc.h> |
Gerard Marull-Paretas | 3cd2cec | 2022-05-09 12:10:05 +0200 | [diff] [blame] | 24 | #include <zephyr/storage/flash_map.h> |
Marti Bolivar | 51181cf | 2017-03-20 11:03:41 -0400 | [diff] [blame] | 25 | |
Marti Bolivar | 3d9e3eb | 2017-09-20 16:28:57 -0400 | [diff] [blame] | 26 | #define FLASH_ALIGN FLASH_WRITE_BLOCK_SIZE |
| 27 | |
Sergey Koziakov | 3f0738d | 2019-12-02 22:48:44 +0300 | [diff] [blame] | 28 | #endif /* !defined(MCUBOOT_TARGET_CONFIG) */ |
| 29 | |
Marti Bolivar | dc4c42b | 2017-09-21 14:20:40 -0400 | [diff] [blame] | 30 | /* |
Marti Bolivar | 3d9e3eb | 2017-09-20 16:28:57 -0400 | [diff] [blame] | 31 | * Sanity check the target support. |
Marti Bolivar | 61038df | 2017-09-01 12:52:56 -0400 | [diff] [blame] | 32 | */ |
Gerard Marull-Paretas | aa041a2 | 2022-03-25 12:22:29 +0100 | [diff] [blame] | 33 | #if (!defined(CONFIG_XTENSA) && !DT_HAS_CHOSEN(zephyr_flash_controller)) || \ |
Marek Matej | 6769344 | 2023-01-23 17:54:36 +0100 | [diff] [blame^] | 34 | (defined(CONFIG_XTENSA) && !DT_NODE_EXISTS(DT_INST(0, jedec_spi_nor)) && \ |
| 35 | !defined(CONFIG_SOC_FAMILY_ESP32)) || \ |
Marti Bolivar | 61038df | 2017-09-01 12:52:56 -0400 | [diff] [blame] | 36 | !defined(FLASH_ALIGN) || \ |
Dominik Ermel | 3a82b6f | 2022-08-24 14:35:24 +0000 | [diff] [blame] | 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)) |
Marti Bolivar | 61038df | 2017-09-01 12:52:56 -0400 | [diff] [blame] | 40 | #error "Target support is incomplete; cannot build mcuboot." |
| 41 | #endif |
| 42 | |
Dominik Ermel | 3a82b6f | 2022-08-24 14:35:24 +0000 | [diff] [blame] | 43 | #if (MCUBOOT_IMAGE_NUMBER == 2) && (!(FIXED_PARTITION_EXISTS(slot2_partition)) || \ |
| 44 | !(FIXED_PARTITION_EXISTS(slot3_partition))) |
David Vincze | b75c12a | 2019-03-22 14:58:33 +0100 | [diff] [blame] | 45 | #error "Target support is incomplete; cannot build mcuboot." |
Marti Bolivar | 51181cf | 2017-03-20 11:03:41 -0400 | [diff] [blame] | 46 | #endif |
David Vincze | b75c12a | 2019-03-22 14:58:33 +0100 | [diff] [blame] | 47 | |
| 48 | #endif /* H_TARGETS_TARGET_ */ |