dfu: allow to operate on primary slot

It is possible that dfu libraries are used by MCUBoot
itself while it has enabled CONFIG_SINGLE_APPLICATIO_SLOT.
In this mode only application slot is the primary slot.

Patch is required for supports USB DFU class in mentioned
MCUBoot's mode.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
This commit is contained in:
Andrzej Puzdrowski 2020-09-18 13:20:06 +02:00 committed by Carles Cufí
commit 9fd8508f71
2 changed files with 18 additions and 4 deletions

View file

@ -20,9 +20,13 @@
#include <devicetree.h>
/* FLASH_AREA_ID() values used below are auto-generated by DT */
#ifdef CONFIG_TRUSTED_EXECUTION_NONSECURE
#define FLASH_AREA_IMAGE_SECONDARY FLASH_AREA_ID(image_1_nonsecure)
#define UPLOAD_FLASH_AREA_ID FLASH_AREA_ID(image_1_nonsecure)
#else
#define FLASH_AREA_IMAGE_SECONDARY FLASH_AREA_ID(image_1)
#if FLASH_AREA_LABEL_EXISTS(image_1)
#define UPLOAD_FLASH_AREA_ID FLASH_AREA_ID(image_1)
#else
#define UPLOAD_FLASH_AREA_ID FLASH_AREA_ID(image_0)
#endif
#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE */
#define FLASH_WRITE_BLOCK_SIZE \
@ -82,7 +86,7 @@ int flash_img_init_id(struct flash_img_context *ctx, uint8_t area_id)
int flash_img_init(struct flash_img_context *ctx)
{
return flash_img_init_id(ctx, FLASH_AREA_IMAGE_SECONDARY);
return flash_img_init_id(ctx, UPLOAD_FLASH_AREA_ID);
}
#if defined(CONFIG_IMG_ENABLE_IMAGE_CHECK)