Skip to content

Commit 3296af0

Browse files
nvlsianpujukkar
authored andcommitted
[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]> (cherry picked from commit c72ed15)
1 parent 2a8428a commit 3296af0

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
@@ -913,8 +919,10 @@ bs_upload(char *buf, int len)
913919
* erase has stopped to let us know whether erase
914920
* is needed to be able to write current chunk.
915921
*/
922+
#ifdef BOOT_IMAGE_HAS_STATUS_FIELDS
916923
static struct flash_sector status_sector;
917924
#endif
925+
#endif /* MCUBOOT_ERASE_PROGRESSIVELY */
918926
#ifdef MCUBOOT_SWAP_USING_OFFSET
919927
static uint32_t start_off = 0;
920928
#endif
@@ -987,7 +995,7 @@ bs_upload(char *buf, int len)
987995
#endif
988996

989997
curr_off = 0;
990-
#ifdef MCUBOOT_ERASE_PROGRESSIVELY
998+
#if defined(MCUBOOT_ERASE_PROGRESSIVELY) && defined(BOOT_IMAGE_HAS_STATUS_FIELDS)
991999
/* Get trailer sector information; this is done early because inability to get
9921000
* that sector information means that upload will not work anyway.
9931001
* TODO: This is single occurrence issue, it should get detected during tests
@@ -1154,7 +1162,7 @@ bs_upload(char *buf, int len)
11541162
if (rc == 0) {
11551163
curr_off += img_chunk_len + rem_bytes;
11561164
if (curr_off == img_size) {
1157-
#ifdef MCUBOOT_ERASE_PROGRESSIVELY
1165+
#if defined(MCUBOOT_ERASE_PROGRESSIVELY) && defined(BOOT_IMAGE_HAS_STATUS_FIELDS)
11581166
/* Assure that sector for image trailer was erased. */
11591167
/* Check whether it was erased during previous upload. */
11601168
off_t start = flash_sector_get_off(&status_sector);

0 commit comments

Comments
 (0)