@@ -510,18 +510,25 @@ boot_write_copy_done(const struct flash_area *fap)
510
510
511
511
#ifdef SEND_BOOT_REQUEST
512
512
static 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 )
514
515
{
515
516
int rc = BOOT_EBADIMAGE ;
516
517
517
518
/* Handle write-protected active image. */
518
519
if ((magic == BOOT_MAGIC_GOOD ) || (magic == BOOT_MAGIC_UNSET )) {
519
520
if (confirm ) {
520
521
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
522
528
} else {
523
529
BOOT_LOG_DBG ("Set image preference: %d, %d" , image_id , slot_id );
524
530
rc = boot_request_set_preferred_slot (image_id , slot_id );
531
+ #endif /* CONFIG_NCS_MCUBOOT_BOOT_REQUEST_TEST_SETS_BOOT_PREFERENCE */
525
532
}
526
533
if (rc != 0 ) {
527
534
rc = BOOT_EBADIMAGE ;
@@ -594,7 +601,8 @@ boot_set_next(const struct flash_area *fa, bool active, bool confirm)
594
601
image_id = flash_area_to_image_slot (fa , & slot_id );
595
602
596
603
#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 );
598
606
if ((rc != 0 ) || active ) {
599
607
return rc ;
600
608
}
@@ -686,7 +694,8 @@ boot_set_next(const struct flash_area *fa, bool active, bool confirm)
686
694
#ifdef SEND_BOOT_REQUEST
687
695
image_id = flash_area_to_image_slot (fa , & slot_id );
688
696
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 );
690
699
if ((rc != 0 ) || active ) {
691
700
return rc ;
692
701
}
0 commit comments