David Brown | 5153bd6 | 2017-01-06 11:16:53 -0700 | [diff] [blame] | 1 | /* Manual version of auto-generated version. */ |
| 2 | |
| 3 | #ifndef __SYSFLASH_H__ |
| 4 | #define __SYSFLASH_H__ |
| 5 | |
David Vincze | b75c12a | 2019-03-22 14:58:33 +0100 | [diff] [blame] | 6 | #include <mcuboot_config/mcuboot_config.h> |
Dominik Ermel | 0119cdb | 2023-02-21 13:58:03 +0000 | [diff] [blame^] | 7 | #include <zephyr/devicetree.h> |
| 8 | #include <zephyr/storage/flash_map.h> |
Andrzej Puzdrowski | 419a475 | 2019-01-23 16:31:19 +0100 | [diff] [blame] | 9 | |
Andrzej Puzdrowski | fdff3e1 | 2020-09-15 08:23:25 +0200 | [diff] [blame] | 10 | #ifndef CONFIG_SINGLE_APPLICATION_SLOT |
Dominik Ermel | 8101c0c | 2020-05-19 13:01:16 +0000 | [diff] [blame] | 11 | |
David Vincze | b75c12a | 2019-03-22 14:58:33 +0100 | [diff] [blame] | 12 | #if (MCUBOOT_IMAGE_NUMBER == 1) |
Fabio Utzig | b0f0473 | 2019-07-31 09:49:19 -0300 | [diff] [blame] | 13 | /* |
| 14 | * NOTE: the definition below returns the same values for true/false on |
| 15 | * purpose, to avoid having to mark x as non-used by all callers when |
| 16 | * running in single image mode. |
| 17 | */ |
| 18 | #define FLASH_AREA_IMAGE_PRIMARY(x) (((x) == 0) ? \ |
Dominik Ermel | 3a82b6f | 2022-08-24 14:35:24 +0000 | [diff] [blame] | 19 | FIXED_PARTITION_ID(slot0_partition) : \ |
| 20 | FIXED_PARTITION_ID(slot0_partition)) |
Fabio Utzig | b0f0473 | 2019-07-31 09:49:19 -0300 | [diff] [blame] | 21 | #define FLASH_AREA_IMAGE_SECONDARY(x) (((x) == 0) ? \ |
Dominik Ermel | 3a82b6f | 2022-08-24 14:35:24 +0000 | [diff] [blame] | 22 | FIXED_PARTITION_ID(slot1_partition) : \ |
| 23 | FIXED_PARTITION_ID(slot1_partition)) |
David Vincze | b75c12a | 2019-03-22 14:58:33 +0100 | [diff] [blame] | 24 | #elif (MCUBOOT_IMAGE_NUMBER == 2) |
| 25 | /* MCUBoot currently supports only up to 2 updateable firmware images. |
| 26 | * If the number of the current image is greater than MCUBOOT_IMAGE_NUMBER - 1 |
| 27 | * then a dummy value will be assigned to the flash area macros. |
| 28 | */ |
Fabio Utzig | b0f0473 | 2019-07-31 09:49:19 -0300 | [diff] [blame] | 29 | #define FLASH_AREA_IMAGE_PRIMARY(x) (((x) == 0) ? \ |
Dominik Ermel | 3a82b6f | 2022-08-24 14:35:24 +0000 | [diff] [blame] | 30 | FIXED_PARTITION_ID(slot0_partition) : \ |
Fabio Utzig | b0f0473 | 2019-07-31 09:49:19 -0300 | [diff] [blame] | 31 | ((x) == 1) ? \ |
Dominik Ermel | 3a82b6f | 2022-08-24 14:35:24 +0000 | [diff] [blame] | 32 | FIXED_PARTITION_ID(slot2_partition) : \ |
Fabio Utzig | b0f0473 | 2019-07-31 09:49:19 -0300 | [diff] [blame] | 33 | 255) |
| 34 | #define FLASH_AREA_IMAGE_SECONDARY(x) (((x) == 0) ? \ |
Dominik Ermel | 3a82b6f | 2022-08-24 14:35:24 +0000 | [diff] [blame] | 35 | FIXED_PARTITION_ID(slot1_partition) : \ |
Fabio Utzig | b0f0473 | 2019-07-31 09:49:19 -0300 | [diff] [blame] | 36 | ((x) == 1) ? \ |
Dominik Ermel | 3a82b6f | 2022-08-24 14:35:24 +0000 | [diff] [blame] | 37 | FIXED_PARTITION_ID(slot3_partition) : \ |
Fabio Utzig | b0f0473 | 2019-07-31 09:49:19 -0300 | [diff] [blame] | 38 | 255) |
David Vincze | b75c12a | 2019-03-22 14:58:33 +0100 | [diff] [blame] | 39 | #else |
| 40 | #error "Image slot and flash area mapping is not defined" |
| 41 | #endif |
| 42 | |
Fabio Utzig | c58842e | 2019-11-28 10:30:01 -0300 | [diff] [blame] | 43 | #if !defined(CONFIG_BOOT_SWAP_USING_MOVE) |
Dominik Ermel | 3a82b6f | 2022-08-24 14:35:24 +0000 | [diff] [blame] | 44 | #define FLASH_AREA_IMAGE_SCRATCH FIXED_PARTITION_ID(scratch_partition) |
Fabio Utzig | c58842e | 2019-11-28 10:30:01 -0300 | [diff] [blame] | 45 | #endif |
David Brown | 5153bd6 | 2017-01-06 11:16:53 -0700 | [diff] [blame] | 46 | |
Andrzej Puzdrowski | fdff3e1 | 2020-09-15 08:23:25 +0200 | [diff] [blame] | 47 | #else /* CONFIG_SINGLE_APPLICATION_SLOT */ |
Dominik Ermel | 8101c0c | 2020-05-19 13:01:16 +0000 | [diff] [blame] | 48 | |
Dominik Ermel | 3a82b6f | 2022-08-24 14:35:24 +0000 | [diff] [blame] | 49 | #define FLASH_AREA_IMAGE_PRIMARY(x) FIXED_PARTITION_ID(slot0_partition) |
| 50 | #define FLASH_AREA_IMAGE_SECONDARY(x) FIXED_PARTITION_ID(slot0_partition) |
Dominik Ermel | 8101c0c | 2020-05-19 13:01:16 +0000 | [diff] [blame] | 51 | |
Andrzej Puzdrowski | fdff3e1 | 2020-09-15 08:23:25 +0200 | [diff] [blame] | 52 | #endif /* CONFIG_SINGLE_APPLICATION_SLOT */ |
Dominik Ermel | 8101c0c | 2020-05-19 13:01:16 +0000 | [diff] [blame] | 53 | |
David Brown | 5153bd6 | 2017-01-06 11:16:53 -0700 | [diff] [blame] | 54 | #endif /* __SYSFLASH_H__ */ |