mgmt/MCUmgr/grp/img: Reduce logic in img_mgmt_active_slot

Make img_mgmt_active_slot independent from
CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER for MCUboot swap type
algorithms.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This commit is contained in:
Dominik Ermel 2023-08-09 09:29:59 +00:00 committed by Carles Cufí
commit 21c3263b95

View file

@ -141,16 +141,20 @@ static int img_mgmt_find_tlvs(int slot, size_t *start_off, size_t *end_off, uint
int img_mgmt_active_slot(int image) int img_mgmt_active_slot(int image)
{ {
#if CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER == 2 int slot = 0;
if (image == 1) {
return 2; /* Multi image does not support DirectXIP currently */
#if CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER > 1
slot = (image << 1);
#else
/* This covers single image, including DirectXiP */
if (FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot1_partition)) {
slot = 1;
} }
#endif #endif
/* Image 0 */ LOG_DBG("(%d) => %d", image, slot);
if (FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot1_partition)) {
return 1; return slot;
}
return 0;
} }
int img_mgmt_active_image(void) int img_mgmt_active_image(void)