@@ -510,18 +510,25 @@ boot_write_copy_done(const struct flash_area *fap)
510510
511511#ifdef SEND_BOOT_REQUEST
512512static int
513- send_boot_request (uint8_t magic , bool confirm , int image_id , uint32_t slot_id )
513+ send_boot_request (uint8_t magic , uint8_t image_ok , bool confirm , int image_id ,
514+ uint32_t slot_id )
514515{
515516 int rc = BOOT_EBADIMAGE ;
516517
517518 /* Handle write-protected active image. */
518519 if ((magic == BOOT_MAGIC_GOOD ) || (magic == BOOT_MAGIC_UNSET )) {
519520 if (confirm ) {
520521 BOOT_LOG_DBG ("Confirm image: %d, %d" , image_id , slot_id );
521- rc = boot_request_confirm_slot (image_id , slot_id );
522+ if ((image_ok != BOOT_FLAG_SET ) || (magic != BOOT_MAGIC_GOOD )) {
523+ rc = boot_request_confirm_slot (image_id , slot_id );
524+ } else {
525+ rc = 0 ;
526+ }
527+ #ifdef CONFIG_NCS_MCUBOOT_BOOT_REQUEST_TEST_SETS_BOOT_PREFERENCE
522528 } else {
523529 BOOT_LOG_DBG ("Set image preference: %d, %d" , image_id , slot_id );
524530 rc = boot_request_set_preferred_slot (image_id , slot_id );
531+ #endif /* CONFIG_NCS_MCUBOOT_BOOT_REQUEST_TEST_SETS_BOOT_PREFERENCE */
525532 }
526533 if (rc != 0 ) {
527534 rc = BOOT_EBADIMAGE ;
@@ -594,7 +601,8 @@ boot_set_next(const struct flash_area *fa, bool active, bool confirm)
594601 image_id = flash_area_to_image_slot (fa , & slot_id );
595602
596603#ifdef SEND_BOOT_REQUEST
597- rc = send_boot_request (slot_state .magic , confirm , image_id , slot_id );
604+ rc = send_boot_request (slot_state .magic , slot_state .image_ok , confirm ,
605+ image_id , slot_id );
598606 if ((rc != 0 ) || active ) {
599607 return rc ;
600608 }
@@ -686,7 +694,8 @@ boot_set_next(const struct flash_area *fa, bool active, bool confirm)
686694#ifdef SEND_BOOT_REQUEST
687695 image_id = flash_area_to_image_slot (fa , & slot_id );
688696
689- rc = send_boot_request (slot_state .magic , confirm , image_id , slot_id );
697+ rc = send_boot_request (slot_state .magic , slot_state .image_ok , confirm ,
698+ image_id , slot_id );
690699 if ((rc != 0 ) || active ) {
691700 return rc ;
692701 }
0 commit comments