Add basic multi-image support for Mynewt
Allow Mynewt to be used in multi-image builds. Primary and secondary slots of image 1 are hard-coded to FLASH_AREA_IMAGE_2 and FLASH_AREA_IMAGE_3. Signed-off-by: Fabio Utzig <utzig@apache.org>
This commit is contained in:
parent
b63d995641
commit
61f08a04ae
|
@ -7,7 +7,10 @@
|
|||
#ifndef __FLASH_MAP_BACKEND_H__
|
||||
#define __FLASH_MAP_BACKEND_H__
|
||||
|
||||
#include <flash_map/flash_map.h>
|
||||
#include <sysflash/sysflash.h>
|
||||
#include <mcuboot_config/mcuboot_config.h>
|
||||
|
||||
#if (MCUBOOT_IMAGE_NUMBER == 1)
|
||||
|
||||
#define FLASH_AREA_IMAGE_PRIMARY(x) (((x) == 0) ? \
|
||||
FLASH_AREA_IMAGE_0 : \
|
||||
|
@ -16,6 +19,23 @@
|
|||
FLASH_AREA_IMAGE_1 : \
|
||||
FLASH_AREA_IMAGE_1)
|
||||
|
||||
#elif (MCUBOOT_IMAGE_NUMBER == 2)
|
||||
|
||||
#define FLASH_AREA_IMAGE_PRIMARY(x) (((x) == 0) ? \
|
||||
FLASH_AREA_IMAGE_0 : \
|
||||
((x) == 1) ? \
|
||||
FLASH_AREA_IMAGE_2 : \
|
||||
255)
|
||||
#define FLASH_AREA_IMAGE_SECONDARY(x) (((x) == 0) ? \
|
||||
FLASH_AREA_IMAGE_1 : \
|
||||
((x) == 1) ? \
|
||||
FLASH_AREA_IMAGE_3 : \
|
||||
255)
|
||||
|
||||
#else
|
||||
#error "Image slot and flash area mapping is not defined"
|
||||
#endif
|
||||
|
||||
int flash_area_id_from_multi_image_slot(int image_index, int slot);
|
||||
int flash_area_id_to_multi_image_slot(int image_index, int area_id);
|
||||
|
||||
|
|
|
@ -22,12 +22,21 @@
|
|||
|
||||
int flash_area_id_from_multi_image_slot(int image_index, int slot)
|
||||
{
|
||||
(void)image_index;
|
||||
return flash_area_id_from_image_slot(slot);
|
||||
switch (slot) {
|
||||
case 0: return FLASH_AREA_IMAGE_PRIMARY(image_index);
|
||||
case 1: return FLASH_AREA_IMAGE_SECONDARY(image_index);
|
||||
case 2: return FLASH_AREA_IMAGE_SCRATCH;
|
||||
}
|
||||
return 255;
|
||||
}
|
||||
|
||||
int flash_area_id_to_multi_image_slot(int image_index, int area_id)
|
||||
{
|
||||
(void)image_index;
|
||||
return flash_area_id_to_image_slot(area_id);
|
||||
if (area_id == FLASH_AREA_IMAGE_PRIMARY(image_index)) {
|
||||
return 0;
|
||||
}
|
||||
if (area_id == FLASH_AREA_IMAGE_SECONDARY(image_index)) {
|
||||
return 1;
|
||||
}
|
||||
return 255;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,11 @@
|
|||
|
||||
#include <syscfg/syscfg.h>
|
||||
|
||||
#if MYNEWT_VAL(BOOTUTIL_IMAGE_NUMBER)
|
||||
#define MCUBOOT_IMAGE_NUMBER MYNEWT_VAL(BOOTUTIL_IMAGE_NUMBER)
|
||||
#else
|
||||
#define MCUBOOT_IMAGE_NUMBER 1
|
||||
#endif
|
||||
#if MYNEWT_VAL(BOOT_SERIAL)
|
||||
#define MCUBOOT_SERIAL 1
|
||||
#endif
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
# Package: boot/mynewt/mcuboot_config
|
||||
|
||||
syscfg.defs:
|
||||
BOOTUTIL_IMAGE_NUMBER:
|
||||
description: 'Number of images for multi-image (0 and 1 mean single image).'
|
||||
value: 0
|
||||
BOOTUTIL_VALIDATE_SLOT0:
|
||||
description: 'Validate image at slot 0 on each boot.'
|
||||
value: 0
|
||||
|
|
Loading…
Reference in New Issue