Skip to content

Commit d905a69

Browse files
committed
boot: boot_serial: Fix upload for swap using offset mode
Fixes an issue whereby the offset of the secondary was wrongly used when uplading to the primary Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
1 parent 3fc94b3 commit d905a69

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

boot/boot_serial/src/boot_serial.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ bs_upload(char *buf, int len)
981981
*/
982982
const size_t area_size = flash_area_get_size(fap);
983983

984-
#ifdef MCUBOOT_SWAP_USING_OFFSET
984+
#if defined(MCUBOOT_SWAP_USING_OFFSET) && defined(MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD)
985985
uint32_t num_sectors = SWAP_USING_OFFSET_SECTOR_UPDATE_BEGIN;
986986
struct flash_sector sector_data;
987987
#endif
@@ -1028,8 +1028,7 @@ bs_upload(char *buf, int len)
10281028

10291029
img_size = img_size_tmp;
10301030

1031-
#ifdef MCUBOOT_SWAP_USING_OFFSET
1032-
#ifdef MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD
1031+
#if defined(MCUBOOT_SWAP_USING_OFFSET) && defined(MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD)
10331032
if (img_num > 0 &&
10341033
(img_num % BOOT_NUM_SLOTS) == BOOT_DIRECT_UPLOAD_SECONDARY_SLOT_ID_REMAINDER) {
10351034
rc = flash_area_sectors(fap, &num_sectors, &sector_data);
@@ -1044,17 +1043,6 @@ bs_upload(char *buf, int len)
10441043
} else {
10451044
start_off = 0;
10461045
}
1047-
#else
1048-
rc = flash_area_sectors(fap, &num_sectors, &sector_data);
1049-
1050-
if ((rc != 0 && rc != -ENOMEM) ||
1051-
num_sectors != SWAP_USING_OFFSET_SECTOR_UPDATE_BEGIN) {
1052-
rc = MGMT_ERR_ENOENT;
1053-
goto out;
1054-
}
1055-
1056-
start_off = sector_data.fs_size;
1057-
#endif
10581046
#endif
10591047
} else if (img_chunk_off != curr_off) {
10601048
/* If received chunk offset does not match expected one jump, pretend

0 commit comments

Comments
 (0)