blob: 99ca27371aef3961c81e74f886eb0a3beb97c03a [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
Ulf Magnussone96b6872020-01-13 12:06:44 +01006#include <devicetree.h>
David Vinczeb75c12a2019-03-22 14:58:33 +01007#include <mcuboot_config/mcuboot_config.h>
Andrzej Puzdrowski419a4752019-01-23 16:31:19 +01008
Andrzej Puzdrowskifdff3e12020-09-15 08:23:25 +02009#ifndef CONFIG_SINGLE_APPLICATION_SLOT
Dominik Ermel8101c0c2020-05-19 13:01:16 +000010
David Vinczeb75c12a2019-03-22 14:58:33 +010011#if (MCUBOOT_IMAGE_NUMBER == 1)
Fabio Utzigb0f04732019-07-31 09:49:19 -030012/*
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 Gala6e26e382020-05-07 19:31:57 -050018 FLASH_AREA_ID(image_0) : \
19 FLASH_AREA_ID(image_0))
Fabio Utzigb0f04732019-07-31 09:49:19 -030020#define FLASH_AREA_IMAGE_SECONDARY(x) (((x) == 0) ? \
Kumar Gala6e26e382020-05-07 19:31:57 -050021 FLASH_AREA_ID(image_1) : \
22 FLASH_AREA_ID(image_1))
David Vinczeb75c12a2019-03-22 14:58:33 +010023#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 Utzigb0f04732019-07-31 09:49:19 -030028#define FLASH_AREA_IMAGE_PRIMARY(x) (((x) == 0) ? \
Kumar Gala6e26e382020-05-07 19:31:57 -050029 FLASH_AREA_ID(image_0) : \
Fabio Utzigb0f04732019-07-31 09:49:19 -030030 ((x) == 1) ? \
Kumar Gala6e26e382020-05-07 19:31:57 -050031 FLASH_AREA_ID(image_2) : \
Fabio Utzigb0f04732019-07-31 09:49:19 -030032 255)
33#define FLASH_AREA_IMAGE_SECONDARY(x) (((x) == 0) ? \
Kumar Gala6e26e382020-05-07 19:31:57 -050034 FLASH_AREA_ID(image_1) : \
Fabio Utzigb0f04732019-07-31 09:49:19 -030035 ((x) == 1) ? \
Kumar Gala6e26e382020-05-07 19:31:57 -050036 FLASH_AREA_ID(image_3) : \
Fabio Utzigb0f04732019-07-31 09:49:19 -030037 255)
David Vinczeb75c12a2019-03-22 14:58:33 +010038#else
39#error "Image slot and flash area mapping is not defined"
40#endif
41
Fabio Utzigc58842e2019-11-28 10:30:01 -030042#if !defined(CONFIG_BOOT_SWAP_USING_MOVE)
Kumar Gala6e26e382020-05-07 19:31:57 -050043#define FLASH_AREA_IMAGE_SCRATCH FLASH_AREA_ID(image_scratch)
Fabio Utzigc58842e2019-11-28 10:30:01 -030044#endif
David Brown5153bd62017-01-06 11:16:53 -070045
Andrzej Puzdrowskifdff3e12020-09-15 08:23:25 +020046#else /* CONFIG_SINGLE_APPLICATION_SLOT */
Dominik Ermel8101c0c2020-05-19 13:01:16 +000047
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
Andrzej Puzdrowskifdff3e12020-09-15 08:23:25 +020056#endif /* CONFIG_SINGLE_APPLICATION_SLOT */
Dominik Ermel8101c0c2020-05-19 13:01:16 +000057
David Brown5153bd62017-01-06 11:16:53 -070058#endif /* __SYSFLASH_H__ */