3232#include  <mgmt/mcumgr/transport/smp_internal.h> 
3333#endif 
3434
35+ #ifdef  CONFIG_NRF_MCUBOOT_BOOT_REQUEST 
36+ #include  <bootutil/boot_request.h> 
37+ #endif  /* CONFIG_NRF_MCUBOOT_BOOT_REQUEST */ 
38+ 
3539LOG_MODULE_DECLARE (mcumgr_img_grp , CONFIG_MCUMGR_GRP_IMG_LOG_LEVEL );
3640
3741#ifndef  CONFIG_MCUMGR_GRP_IMG_FRUGAL_LIST 
@@ -140,6 +144,12 @@ img_mgmt_state_flags(int query_slot)
140144	if  (image  ==  img_mgmt_active_image () &&  query_slot  ==  active_slot ) {
141145		flags  =  IMG_MGMT_STATE_F_ACTIVE ;
142146#ifdef  CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP 
147+ #ifdef  CONFIG_NRF_MCUBOOT_BOOT_REQUEST 
148+ 	} else  if  (boot_request_get_preferred_slot (image ) ==  active_slot ) {
149+ 		/* Active slot is preferred. All updates are postponed. */ 
150+ 	} else  if  (boot_request_get_preferred_slot (image ) ==  other_slot ) {
151+ 		flags  =  IMG_MGMT_STATE_F_PENDING  | IMG_MGMT_STATE_F_PERMANENT ;
152+ #endif  /* CONFIG_NRF_MCUBOOT_BOOT_REQUEST */ 
143153	} else  {
144154		struct  image_version  sver ;
145155		struct  image_version  aver ;
@@ -294,6 +304,17 @@ int img_mgmt_get_next_boot_slot(int image, enum img_mgmt_next_boot_type *type)
294304		if  (active_slot_state  ==  DIRECT_XIP_BOOT_ONCE ) {
295305			lt  =  NEXT_BOOT_TYPE_TEST ;
296306		}
307+ #ifdef  CONFIG_NRF_MCUBOOT_BOOT_REQUEST 
308+ 	} else  if  (boot_request_get_preferred_slot (image ) ==  active_slot ) {
309+ 		/* Active slot is preferred. All updates are postponed. */ 
310+ 	} else  if  (boot_request_get_preferred_slot (image ) ==  other_slot ) {
311+ 		if  (other_slot_state  ==  DIRECT_XIP_BOOT_FOREVER ) {
312+ 			return_slot  =  other_slot ;
313+ 		} else  if  (other_slot_state  ==  DIRECT_XIP_BOOT_ONCE ) {
314+ 			lt  =  NEXT_BOOT_TYPE_TEST ;
315+ 			return_slot  =  other_slot ;
316+ 		}
317+ #endif  /* CONFIG_NRF_MCUBOOT_BOOT_REQUEST */ 
297318	} else  if  ((img_mgmt_vercmp (& aver , & over ) <  0 ) || 
298319		   ((img_mgmt_vercmp (& aver , & over ) ==  0 ) &&  (active_slot  >  other_slot ))) {
299320		/* Check if MCUboot will select the non-active slot during the next boot. 
@@ -312,6 +333,13 @@ int img_mgmt_get_next_boot_slot(int image, enum img_mgmt_next_boot_type *type)
312333
313334out :
314335#else 
336+ #ifdef  CONFIG_NRF_MCUBOOT_BOOT_REQUEST 
337+ 	if  (boot_request_get_preferred_slot (image ) ==  active_slot ) {
338+ 		/* Active slot is preferred. All updates are postponed. */ 
339+ 	} else  if  (boot_request_get_preferred_slot (image ) ==  other_slot ) {
340+ 		return_slot  =  other_slot ;
341+ 	} else 
342+ #endif  /* CONFIG_NRF_MCUBOOT_BOOT_REQUEST */ 
315343	if  (rcs  ==  0  &&  rca  ==  0  && 
316344	    ((img_mgmt_vercmp (& aver , & over ) <  0 ) || 
317345	     ((img_mgmt_vercmp (& aver , & over ) ==  0 ) &&  (active_slot  >  other_slot )))) {
0 commit comments