Commit c62c19db authored by Thomas Altenbach's avatar Thomas Altenbach Committed by Jamie
Browse files

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: default avatarThomas Altenbach <thomas.altenbach@legrand.com>
parent 13edc5fb
Loading
Loading
Loading
Loading
+2 −21
Original line number Diff line number Diff line
@@ -326,17 +326,7 @@ bs_list(struct boot_loader_state *state, char *buf, int len)

#ifdef MCUBOOT_SWAP_USING_OFFSET
            if (slot == BOOT_SECONDARY_SLOT && swap_status != BOOT_SWAP_TYPE_REVERT) {
                uint32_t num_sectors = SWAP_USING_OFFSET_SECTOR_UPDATE_BEGIN;
                struct flash_sector sector_data;

                rc = flash_area_sectors(fap, &num_sectors, &sector_data);

                if ((rc != 0 && rc != -ENOMEM) ||
                    num_sectors != SWAP_USING_OFFSET_SECTOR_UPDATE_BEGIN) {
                    continue;
                }

                start_off = sector_data.fs_size;
                start_off = boot_img_sector_size(state, slot, 0);
            }
#endif

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

#ifdef MCUBOOT_SWAP_USING_OFFSET
                uint32_t num_sectors = SWAP_USING_OFFSET_SECTOR_UPDATE_BEGIN;
                struct flash_sector sector_data;
                uint32_t start_off = 0;
#endif

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

#ifdef MCUBOOT_SWAP_USING_OFFSET
                if (slot == BOOT_SECONDARY_SLOT && swap_status != BOOT_SWAP_TYPE_REVERT) {
                    rc = flash_area_sectors(fap, &num_sectors, &sector_data);

                    if ((rc != 0 && rc != -ENOMEM) ||
                        num_sectors != SWAP_USING_OFFSET_SECTOR_UPDATE_BEGIN) {
                        continue;
                    }

                    start_off = sector_data.fs_size;
                    start_off = boot_img_sector_size(state, slot, 0);
                }
#endif