blob: c422efd649604d2056740cbdf520f881d0d68f08 [file] [log] [blame]
David Brown5153bd62017-01-06 11:16:53 -07001/* Manual version of auto-generated version. */
2
3#ifndef __SYSFLASH_H__
4#define __SYSFLASH_H__
5
Andrzej Puzdrowski419a4752019-01-23 16:31:19 +01006#include <generated_dts_board.h>
David Vinczeb75c12a2019-03-22 14:58:33 +01007#include <mcuboot_config/mcuboot_config.h>
Andrzej Puzdrowski419a4752019-01-23 16:31:19 +01008
David Vinczeb75c12a2019-03-22 14:58:33 +01009#if (MCUBOOT_IMAGE_NUMBER == 1)
Fabio Utzigb0f04732019-07-31 09:49:19 -030010/*
11 * NOTE: the definition below returns the same values for true/false on
12 * purpose, to avoid having to mark x as non-used by all callers when
13 * running in single image mode.
14 */
15#define FLASH_AREA_IMAGE_PRIMARY(x) (((x) == 0) ? \
16 DT_FLASH_AREA_IMAGE_0_ID : \
17 DT_FLASH_AREA_IMAGE_0_ID)
18#define FLASH_AREA_IMAGE_SECONDARY(x) (((x) == 0) ? \
19 DT_FLASH_AREA_IMAGE_1_ID : \
20 DT_FLASH_AREA_IMAGE_1_ID)
David Vinczeb75c12a2019-03-22 14:58:33 +010021#elif (MCUBOOT_IMAGE_NUMBER == 2)
22/* MCUBoot currently supports only up to 2 updateable firmware images.
23 * If the number of the current image is greater than MCUBOOT_IMAGE_NUMBER - 1
24 * then a dummy value will be assigned to the flash area macros.
25 */
Fabio Utzigb0f04732019-07-31 09:49:19 -030026#define FLASH_AREA_IMAGE_PRIMARY(x) (((x) == 0) ? \
David Vinczeb75c12a2019-03-22 14:58:33 +010027 DT_FLASH_AREA_IMAGE_0_ID : \
Fabio Utzigb0f04732019-07-31 09:49:19 -030028 ((x) == 1) ? \
David Vinczeb75c12a2019-03-22 14:58:33 +010029 DT_FLASH_AREA_IMAGE_2_ID : \
Fabio Utzigb0f04732019-07-31 09:49:19 -030030 255)
31#define FLASH_AREA_IMAGE_SECONDARY(x) (((x) == 0) ? \
David Vinczeb75c12a2019-03-22 14:58:33 +010032 DT_FLASH_AREA_IMAGE_1_ID : \
Fabio Utzigb0f04732019-07-31 09:49:19 -030033 ((x) == 1) ? \
David Vinczeb75c12a2019-03-22 14:58:33 +010034 DT_FLASH_AREA_IMAGE_3_ID : \
Fabio Utzigb0f04732019-07-31 09:49:19 -030035 255)
David Vinczeb75c12a2019-03-22 14:58:33 +010036#else
37#error "Image slot and flash area mapping is not defined"
38#endif
39
David Vincze2d736ad2019-02-18 11:50:22 +010040#define FLASH_AREA_IMAGE_SCRATCH DT_FLASH_AREA_IMAGE_SCRATCH_ID
David Brown5153bd62017-01-06 11:16:53 -070041
42#endif /* __SYSFLASH_H__ */