Skip to content

Commit 8d14eeb

Browse files
committed
boot: bootutil: Fix upgrade only serial recovery slot info
Fixes an issue whereby a required variables were missing for this functionality by refactoring to use the common shared function for calculating the maximum size of an image Signed-off-by: Jamie McCrae <[email protected]>
1 parent 9942fe1 commit 8d14eeb

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

boot/bootutil/src/bootutil_misc.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -768,33 +768,32 @@ void boot_fetch_slot_state_sizes(void)
768768
{
769769
int rc = -1;
770770
int image_index;
771+
struct boot_loader_state *state = boot_get_loader_state();
771772

772-
rc = boot_open_all_flash_areas(boot_get_loader_state());
773+
rc = boot_open_all_flash_areas(state);
773774
if (rc != 0) {
774775
BOOT_LOG_DBG("boot_fetch_slot_state_sizes: error %d while opening flash areas", rc);
775776
goto finish;
776777
}
777778

778-
IMAGES_ITER(BOOT_CURR_IMG(boot_get_loader_state())) {
779+
IMAGES_ITER(BOOT_CURR_IMG(state)) {
779780
int max_size = 0;
780781

781-
image_index = BOOT_CURR_IMG(boot_get_loader_state());
782+
image_index = BOOT_CURR_IMG(state);
782783

783-
BOOT_IMG(boot_get_loader_state(), BOOT_SLOT_PRIMARY).sectors =
784-
sector_buffers.primary[image_index];
784+
BOOT_IMG(state, BOOT_SLOT_PRIMARY).sectors = sector_buffers.primary[image_index];
785785
#if BOOT_NUM_SLOTS > 1
786-
BOOT_IMG(boot_get_loader_state(), BOOT_SLOT_SECONDARY).sectors =
787-
sector_buffers.secondary[image_index];
786+
BOOT_IMG(state, BOOT_SLOT_SECONDARY).sectors = sector_buffers.secondary[image_index];
788787
#if MCUBOOT_SWAP_USING_SCRATCH
789-
boot_get_loader_state()->scratch.sectors = sector_buffers.scratch;
788+
state->scratch.sectors = sector_buffers.scratch;
790789
#endif
791790
#endif
792791

793792
/* Determine the sector layout of the image slots and scratch area. */
794-
rc = boot_read_sectors_recovery(boot_get_loader_state());
793+
rc = boot_read_sectors_recovery(state);
795794

796795
if (rc == 0) {
797-
max_size = app_max_size(boot_get_loader_state());
796+
max_size = bootutil_max_image_size(state, BOOT_IMG_AREA(state, 0));
798797

799798
if (max_size > 0) {
800799
boot_get_image_max_sizes()[image_index].calculated = true;
@@ -804,8 +803,8 @@ void boot_fetch_slot_state_sizes(void)
804803
}
805804

806805
finish:
807-
boot_close_all_flash_areas(boot_get_loader_state());
808-
memset(boot_get_loader_state(), 0, sizeof(struct boot_loader_state));
806+
boot_close_all_flash_areas(state);
807+
memset(state, 0, sizeof(struct boot_loader_state));
809808
}
810809
#endif
811810

0 commit comments

Comments
 (0)