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 | |
Ulf Magnusson | e96b687 | 2020-01-13 12:06:44 +0100 | [diff] [blame] | 6 | #include <devicetree.h> |
David Vincze | b75c12a | 2019-03-22 14:58:33 +0100 | [diff] [blame] | 7 | #include <mcuboot_config/mcuboot_config.h> |
Andrzej Puzdrowski | 419a475 | 2019-01-23 16:31:19 +0100 | [diff] [blame] | 8 | |
Dominik Ermel | 8101c0c | 2020-05-19 13:01:16 +0000 | [diff] [blame] | 9 | #ifndef CONFIG_SINGLE_IMAGE_DFU |
| 10 | |
David Vincze | b75c12a | 2019-03-22 14:58:33 +0100 | [diff] [blame] | 11 | #if (MCUBOOT_IMAGE_NUMBER == 1) |
Fabio Utzig | b0f0473 | 2019-07-31 09:49:19 -0300 | [diff] [blame] | 12 | /* |
| 13 | * NOTE: the definition below returns the same values for true/false on |
| 14 | * purpose, to avoid having to mark x as non-used by all callers when |
| 15 | * running in single image mode. |
| 16 | */ |
| 17 | #define FLASH_AREA_IMAGE_PRIMARY(x) (((x) == 0) ? \ |
Kumar Gala | 6e26e38 | 2020-05-07 19:31:57 -0500 | [diff] [blame] | 18 | FLASH_AREA_ID(image_0) : \ |
| 19 | FLASH_AREA_ID(image_0)) |
Fabio Utzig | b0f0473 | 2019-07-31 09:49:19 -0300 | [diff] [blame] | 20 | #define FLASH_AREA_IMAGE_SECONDARY(x) (((x) == 0) ? \ |
Kumar Gala | 6e26e38 | 2020-05-07 19:31:57 -0500 | [diff] [blame] | 21 | FLASH_AREA_ID(image_1) : \ |
| 22 | FLASH_AREA_ID(image_1)) |
David Vincze | b75c12a | 2019-03-22 14:58:33 +0100 | [diff] [blame] | 23 | #elif (MCUBOOT_IMAGE_NUMBER == 2) |
| 24 | /* MCUBoot currently supports only up to 2 updateable firmware images. |
| 25 | * If the number of the current image is greater than MCUBOOT_IMAGE_NUMBER - 1 |
| 26 | * then a dummy value will be assigned to the flash area macros. |
| 27 | */ |
Fabio Utzig | b0f0473 | 2019-07-31 09:49:19 -0300 | [diff] [blame] | 28 | #define FLASH_AREA_IMAGE_PRIMARY(x) (((x) == 0) ? \ |
Kumar Gala | 6e26e38 | 2020-05-07 19:31:57 -0500 | [diff] [blame] | 29 | FLASH_AREA_ID(image_0) : \ |
Fabio Utzig | b0f0473 | 2019-07-31 09:49:19 -0300 | [diff] [blame] | 30 | ((x) == 1) ? \ |
Kumar Gala | 6e26e38 | 2020-05-07 19:31:57 -0500 | [diff] [blame] | 31 | FLASH_AREA_ID(image_2) : \ |
Fabio Utzig | b0f0473 | 2019-07-31 09:49:19 -0300 | [diff] [blame] | 32 | 255) |
| 33 | #define FLASH_AREA_IMAGE_SECONDARY(x) (((x) == 0) ? \ |
Kumar Gala | 6e26e38 | 2020-05-07 19:31:57 -0500 | [diff] [blame] | 34 | FLASH_AREA_ID(image_1) : \ |
Fabio Utzig | b0f0473 | 2019-07-31 09:49:19 -0300 | [diff] [blame] | 35 | ((x) == 1) ? \ |
Kumar Gala | 6e26e38 | 2020-05-07 19:31:57 -0500 | [diff] [blame] | 36 | FLASH_AREA_ID(image_3) : \ |
Fabio Utzig | b0f0473 | 2019-07-31 09:49:19 -0300 | [diff] [blame] | 37 | 255) |
David Vincze | b75c12a | 2019-03-22 14:58:33 +0100 | [diff] [blame] | 38 | #else |
| 39 | #error "Image slot and flash area mapping is not defined" |
| 40 | #endif |
| 41 | |
Fabio Utzig | c58842e | 2019-11-28 10:30:01 -0300 | [diff] [blame] | 42 | #if !defined(CONFIG_BOOT_SWAP_USING_MOVE) |
Kumar Gala | 6e26e38 | 2020-05-07 19:31:57 -0500 | [diff] [blame] | 43 | #define FLASH_AREA_IMAGE_SCRATCH FLASH_AREA_ID(image_scratch) |
Fabio Utzig | c58842e | 2019-11-28 10:30:01 -0300 | [diff] [blame] | 44 | #endif |
David Brown | 5153bd6 | 2017-01-06 11:16:53 -0700 | [diff] [blame] | 45 | |
Dominik Ermel | 8101c0c | 2020-05-19 13:01:16 +0000 | [diff] [blame] | 46 | #else /* CONFIG_SINGLE_IMAGE_DFU */ |
| 47 | |
| 48 | #define FLASH_AREA_IMAGE_PRIMARY(x) FLASH_AREA_ID(image_0) |
| 49 | #define FLASH_AREA_IMAGE_SECONDARY(x) FLASH_AREA_ID(image_0) |
| 50 | /* NOTE: Scratch parition is not used by single image DFU but some of |
| 51 | * functions in common files reference it, so the definitions has been |
| 52 | * provided to allow compilation of common units. |
| 53 | */ |
| 54 | #define FLASH_AREA_IMAGE_SCRATCH 0 |
| 55 | |
| 56 | #endif /* CONFIG_SINGLE_IMAGE_DFU */ |
| 57 | |
David Brown | 5153bd6 | 2017-01-06 11:16:53 -0700 | [diff] [blame] | 58 | #endif /* __SYSFLASH_H__ */ |