Skip to content

Commit c62c19d

Browse files
taltenbachnordicjm
authored andcommitted
boot_serial: Use flash sectors from bootloader state when possible
When swap-offset is used, the bs_list and bs_set routines need to determine the size of the flash sectors. Now a valid bootloader state is available, the value can directly be retrieved using boot_img_sector_size. Signed-off-by: Thomas Altenbach <thomas.altenbach@legrand.com>
1 parent 13edc5f commit c62c19d

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

boot/boot_serial/src/boot_serial.c

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -326,17 +326,7 @@ bs_list(struct boot_loader_state *state, char *buf, int len)
326326

327327
#ifdef MCUBOOT_SWAP_USING_OFFSET
328328
if (slot == BOOT_SECONDARY_SLOT && swap_status != BOOT_SWAP_TYPE_REVERT) {
329-
uint32_t num_sectors = SWAP_USING_OFFSET_SECTOR_UPDATE_BEGIN;
330-
struct flash_sector sector_data;
331-
332-
rc = flash_area_sectors(fap, &num_sectors, &sector_data);
333-
334-
if ((rc != 0 && rc != -ENOMEM) ||
335-
num_sectors != SWAP_USING_OFFSET_SECTOR_UPDATE_BEGIN) {
336-
continue;
337-
}
338-
339-
start_off = sector_data.fs_size;
329+
start_off = boot_img_sector_size(state, slot, 0);
340330
}
341331
#endif
342332

@@ -556,8 +546,6 @@ bs_set(struct boot_loader_state *state, char *buf, int len)
556546
uint8_t tmpbuf[64];
557547

558548
#ifdef MCUBOOT_SWAP_USING_OFFSET
559-
uint32_t num_sectors = SWAP_USING_OFFSET_SECTOR_UPDATE_BEGIN;
560-
struct flash_sector sector_data;
561549
uint32_t start_off = 0;
562550
#endif
563551

@@ -568,14 +556,7 @@ bs_set(struct boot_loader_state *state, char *buf, int len)
568556

569557
#ifdef MCUBOOT_SWAP_USING_OFFSET
570558
if (slot == BOOT_SECONDARY_SLOT && swap_status != BOOT_SWAP_TYPE_REVERT) {
571-
rc = flash_area_sectors(fap, &num_sectors, &sector_data);
572-
573-
if ((rc != 0 && rc != -ENOMEM) ||
574-
num_sectors != SWAP_USING_OFFSET_SECTOR_UPDATE_BEGIN) {
575-
continue;
576-
}
577-
578-
start_off = sector_data.fs_size;
559+
start_off = boot_img_sector_size(state, slot, 0);
579560
}
580561
#endif
581562

0 commit comments

Comments
 (0)