@@ -716,7 +716,6 @@ boot_write_status(const struct boot_loader_state *state, struct boot_status *bs)
716
716
{
717
717
const struct flash_area * fap ;
718
718
uint32_t off ;
719
- int area_id ;
720
719
int rc = 0 ;
721
720
uint8_t buf [BOOT_MAX_ALIGN ];
722
721
uint32_t align ;
@@ -731,20 +730,15 @@ boot_write_status(const struct boot_loader_state *state, struct boot_status *bs)
731
730
#if MCUBOOT_SWAP_USING_SCRATCH
732
731
if (bs -> use_scratch ) {
733
732
/* Write to scratch. */
734
- area_id = FLASH_AREA_IMAGE_SCRATCH ;
733
+ fap = state -> scratch . area ;
735
734
} else {
736
735
#endif
737
736
/* Write to the primary slot. */
738
- area_id = FLASH_AREA_IMAGE_PRIMARY ( BOOT_CURR_IMG ( state ) );
737
+ fap = BOOT_IMG_AREA ( state , BOOT_PRIMARY_SLOT );
739
738
#if MCUBOOT_SWAP_USING_SCRATCH
740
739
}
741
740
#endif
742
741
743
- rc = flash_area_open (area_id , & fap );
744
- if (rc != 0 ) {
745
- return BOOT_EFLASH ;
746
- }
747
-
748
742
off = boot_status_off (fap ) +
749
743
boot_status_internal_off (bs , BOOT_WRITE_SZ (state ));
750
744
align = flash_area_align (fap );
@@ -761,8 +755,6 @@ boot_write_status(const struct boot_loader_state *state, struct boot_status *bs)
761
755
rc = BOOT_EFLASH ;
762
756
}
763
757
764
- flash_area_close (fap );
765
-
766
758
return rc ;
767
759
}
768
760
#endif /* !MCUBOOT_RAM_LOAD */
@@ -1470,13 +1462,11 @@ boot_copy_image(struct boot_loader_state *state, struct boot_status *bs)
1470
1462
BOOT_LOG_INF ("Image %d upgrade secondary slot -> primary slot" , image_index );
1471
1463
BOOT_LOG_INF ("Erasing the primary slot" );
1472
1464
1473
- rc = flash_area_open (FLASH_AREA_IMAGE_PRIMARY (image_index ),
1474
- & fap_primary_slot );
1475
- assert (rc == 0 );
1465
+ fap_primary_slot = BOOT_IMG_AREA (state , BOOT_PRIMARY_SLOT );
1466
+ assert (fap_primary_slot != NULL );
1476
1467
1477
- rc = flash_area_open (FLASH_AREA_IMAGE_SECONDARY (image_index ),
1478
- & fap_secondary_slot );
1479
- assert (rc == 0 );
1468
+ fap_secondary_slot = BOOT_IMG_AREA (state , BOOT_SECONDARY_SLOT );
1469
+ assert (fap_secondary_slot != NULL );
1480
1470
1481
1471
sect_count = boot_img_num_sectors (state , BOOT_PRIMARY_SLOT );
1482
1472
for (sect = 0 , size = 0 ; sect < sect_count ; sect ++ ) {
@@ -1590,9 +1580,6 @@ boot_copy_image(struct boot_loader_state *state, struct boot_status *bs)
1590
1580
last_sector ));
1591
1581
assert (rc == 0 );
1592
1582
1593
- flash_area_close (fap_primary_slot );
1594
- flash_area_close (fap_secondary_slot );
1595
-
1596
1583
/* TODO: Perhaps verify the primary slot's signature again? */
1597
1584
1598
1585
return 0 ;
0 commit comments