Skip to content

Commit c72ed15

Browse files
committed
[nrf fromlist] boot/boot_serial: build-time skip of the erasing of img status page
For MCUboot's MCUBOOT_SINGLE_APPLICATION_SLOT, MCUBOOT_FIRMWARE_LOADER, MCUBOOT_SINGLE_APPLICATION_SLOT_RAM_LOAD modes there is not image run-time status data at the end on the image. Erase of that was done as the last image page erase - and was no harm before by luck. Following commit just reveled the issue: #35536633846b53ccdf01bea0594526de4b416fc0 Upstream PR #: 2417 Signed-off-by: Andrzej Puzdrowski <[email protected]>
1 parent 8d31ad7 commit c72ed15

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

boot/boot_serial/src/boot_serial.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@
7777

7878
BOOT_LOG_MODULE_DECLARE(mcuboot);
7979

80+
#if !(defined(MCUBOOT_SINGLE_APPLICATION_SLOT) || \
81+
defined(MCUBOOT_FIRMWARE_LOADER) || \
82+
defined(MCUBOOT_SINGLE_APPLICATION_SLOT_RAM_LOAD))
83+
#define BOOT_IMAGE_HAS_STATUS_FIELDS
84+
#endif
85+
8086
#ifndef ARRAY_SIZE
8187
#define ARRAY_SIZE ZCBOR_ARRAY_SIZE
8288
#endif
@@ -914,8 +920,10 @@ bs_upload(char *buf, int len)
914920
* erase has stopped to let us know whether erase
915921
* is needed to be able to write current chunk.
916922
*/
923+
#ifdef BOOT_IMAGE_HAS_STATUS_FIELDS
917924
static struct flash_sector status_sector;
918925
#endif
926+
#endif /* MCUBOOT_ERASE_PROGRESSIVELY */
919927
#ifdef MCUBOOT_SWAP_USING_OFFSET
920928
static uint32_t start_off = 0;
921929
#endif
@@ -988,7 +996,7 @@ bs_upload(char *buf, int len)
988996
#endif
989997

990998
curr_off = 0;
991-
#ifdef MCUBOOT_ERASE_PROGRESSIVELY
999+
#if defined(MCUBOOT_ERASE_PROGRESSIVELY) && defined(BOOT_IMAGE_HAS_STATUS_FIELDS)
9921000
/* Get trailer sector information; this is done early because inability to get
9931001
* that sector information means that upload will not work anyway.
9941002
* TODO: This is single occurrence issue, it should get detected during tests
@@ -1167,7 +1175,7 @@ bs_upload(char *buf, int len)
11671175
if (rc == 0) {
11681176
curr_off += img_chunk_len + rem_bytes;
11691177
if (curr_off == img_size) {
1170-
#ifdef MCUBOOT_ERASE_PROGRESSIVELY
1178+
#if defined(MCUBOOT_ERASE_PROGRESSIVELY) && defined(BOOT_IMAGE_HAS_STATUS_FIELDS)
11711179
/* Assure that sector for image trailer was erased. */
11721180
/* Check whether it was erased during previous upload. */
11731181
off_t start = flash_sector_get_off(&status_sector);

0 commit comments

Comments
 (0)