1 /* 2 * Copyright (c) 2022 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef __SYSFLASH_H__ 8 #define __SYSFLASH_H__ 9 10 #include <devicetree.h> 11 #include <mcuboot_config/mcuboot_config.h> 12 13 #if (MCUBOOT_IMAGE_NUMBER == 1) 14 /* 15 * NOTE: the definition below returns the same values for true/false on 16 * purpose, to avoid having to mark x as non-used by all callers when 17 * running in single image mode. 18 */ 19 #define FLASH_AREA_IMAGE_PRIMARY(x) (((x) == 0) ? \ 20 FLASH_AREA_ID(image_0) : \ 21 FLASH_AREA_ID(image_0)) 22 #define FLASH_AREA_IMAGE_SECONDARY(x) (((x) == 0) ? \ 23 FLASH_AREA_ID(image_1) : \ 24 FLASH_AREA_ID(image_1)) 25 #elif (MCUBOOT_IMAGE_NUMBER == 2) 26 /* MCUBoot currently supports only up to 2 updateable firmware images. 27 * If the number of the current image is greater than MCUBOOT_IMAGE_NUMBER - 1 28 * then a dummy value will be assigned to the flash area macros. 29 */ 30 #define FLASH_AREA_IMAGE_PRIMARY(x) (((x) == 0) ? \ 31 FLASH_AREA_ID(image_0) : \ 32 ((x) == 1) ? \ 33 FLASH_AREA_ID(image_2) : \ 34 255) 35 #define FLASH_AREA_IMAGE_SECONDARY(x) (((x) == 0) ? \ 36 FLASH_AREA_ID(image_1) : \ 37 ((x) == 1) ? \ 38 FLASH_AREA_ID(image_3) : \ 39 255) 40 #else 41 #error "Image slot and flash area mapping is not defined" 42 #endif 43 44 #define FLASH_AREA_IMAGE_SCRATCH FLASH_AREA_ID(image_scratch) 45 46 #endif /* __SYSFLASH_H__ */ 47