From a763454c0bc41c13001b672b62f22dc4ec21c877 Mon Sep 17 00:00:00 2001 From: Dominik Ermel Date: Tue, 9 May 2023 15:54:05 +0000 Subject: [PATCH] mgmt/mcumgr/grp/img: No MCUboot flags setting in DirectXIP It is no longer possible to select image for test or confirm when MCUboot has been configured for DirectXIP. MCUboot flags, in image trailer, are now ignored in DirectXIP mode allowing to use entire slot for image upload. Signed-off-by: Dominik Ermel --- subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c | 4 ++++ .../mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c | 15 ++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c index f2dea609958..988c06c4bc4 100644 --- a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c +++ b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c @@ -669,7 +669,11 @@ img_mgmt_my_version(struct image_version *ver) static const struct mgmt_handler img_mgmt_handlers[] = { [IMG_MGMT_ID_STATE] = { .mh_read = img_mgmt_state_read, +#ifdef CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP + .mh_write = NULL +#else .mh_write = img_mgmt_state_write, +#endif }, [IMG_MGMT_ID_UPLOAD] = { .mh_read = NULL, diff --git a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c index cbd0e63a851..9f04215760e 100644 --- a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c +++ b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c @@ -124,13 +124,18 @@ img_mgmt_state_any_pending(void) int img_mgmt_slot_in_use(int slot) { - uint8_t state_flags; int active_slot = img_mgmt_active_slot(img_mgmt_active_image()); - state_flags = img_mgmt_state_flags(slot); - return slot == active_slot || - state_flags & IMG_MGMT_STATE_F_CONFIRMED || - state_flags & IMG_MGMT_STATE_F_PENDING; +#ifndef CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP + uint8_t state_flags = img_mgmt_state_flags(slot); + + if (state_flags & IMG_MGMT_STATE_F_CONFIRMED || + state_flags & IMG_MGMT_STATE_F_PENDING) { + return 1; + } +#endif + + return (active_slot == slot); } /**