blob: d4617bbc90d3a980d70607ac7298386afc63f45f [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 +01009extern uint8_t current_image;
10
11#if (MCUBOOT_IMAGE_NUMBER == 1)
David Vincze2d736ad2019-02-18 11:50:22 +010012#define FLASH_AREA_IMAGE_PRIMARY DT_FLASH_AREA_IMAGE_0_ID
13#define FLASH_AREA_IMAGE_SECONDARY DT_FLASH_AREA_IMAGE_1_ID
David Vinczeb75c12a2019-03-22 14:58:33 +010014#elif (MCUBOOT_IMAGE_NUMBER == 2)
15/* MCUBoot currently supports only up to 2 updateable firmware images.
16 * If the number of the current image is greater than MCUBOOT_IMAGE_NUMBER - 1
17 * then a dummy value will be assigned to the flash area macros.
18 */
19#define FLASH_AREA_IMAGE_PRIMARY ((current_image == 0) ? \
20 DT_FLASH_AREA_IMAGE_0_ID : \
21 (current_image == 1) ? \
22 DT_FLASH_AREA_IMAGE_2_ID : \
23 255 )
24#define FLASH_AREA_IMAGE_SECONDARY ((current_image == 0) ? \
25 DT_FLASH_AREA_IMAGE_1_ID : \
26 (current_image == 1) ? \
27 DT_FLASH_AREA_IMAGE_3_ID : \
28 255 )
29#else
30#error "Image slot and flash area mapping is not defined"
31#endif
32
David Vincze2d736ad2019-02-18 11:50:22 +010033#define FLASH_AREA_IMAGE_SCRATCH DT_FLASH_AREA_IMAGE_SCRATCH_ID
David Brown5153bd62017-01-06 11:16:53 -070034
35#endif /* __SYSFLASH_H__ */