Skip to content

Commit 2c88e69

Browse files
committed
Add some more debug logging
Signed-off-by: Christopher Collins <[email protected]>
1 parent 2adef70 commit 2c88e69

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

boot/bootutil/src/bootutil_misc.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ boot_write_magic(const struct flash_area *fap)
394394

395395
off = boot_magic_off(fap);
396396

397+
BOOT_LOG_DBG("writing magic; fa_id=%d off=0x%x (0x%x)",
398+
fap->fa_id, off, fap->fa_off + off);
397399
rc = flash_area_write(fap, off, boot_img_magic, BOOT_MAGIC_SZ);
398400
if (rc != 0) {
399401
return BOOT_EFLASH;
@@ -414,9 +416,13 @@ boot_write_flag(int flag, const struct flash_area *fap)
414416
switch (flag) {
415417
case BOOT_FLAG_COPY_DONE:
416418
off = boot_copy_done_off(fap);
419+
BOOT_LOG_DBG("writing copy_done; fa_id=%d off=0x%x (0x%x)",
420+
fap->fa_id, off, fap->fa_off + off);
417421
break;
418422
case BOOT_FLAG_IMAGE_OK:
419423
off = boot_image_ok_off(fap);
424+
BOOT_LOG_DBG("writing image_ok; fa_id=%d off=0x%x (0x%x)",
425+
fap->fa_id, off, fap->fa_off + off);
420426
break;
421427
default:
422428
return BOOT_EBADARGS;
@@ -467,6 +473,9 @@ boot_write_swap_size(const struct flash_area *fap, uint32_t swap_size)
467473
memset(buf, erased_val, BOOT_MAX_ALIGN);
468474
memcpy(buf, (uint8_t *)&swap_size, sizeof swap_size);
469475

476+
BOOT_LOG_DBG("writing swap_size; fa_id=%d off=0x%x (0x%x)",
477+
fap->fa_id, off, fap->fa_off + off);
478+
470479
rc = flash_area_write(fap, off, buf, align);
471480
if (rc != 0) {
472481
return BOOT_EFLASH;

boot/bootutil/src/loader.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,8 @@ boot_status_init(const struct flash_area *fap, const struct boot_status *bs)
975975
struct boot_swap_state swap_state;
976976
int rc;
977977

978+
BOOT_LOG_DBG("initializing status; fa_id=%d", fap->fa_id);
979+
978980
rc = boot_read_swap_state_by_id(FLASH_AREA_IMAGE_SECONDARY, &swap_state);
979981
assert(rc == 0);
980982

@@ -1013,6 +1015,8 @@ boot_erase_trailer_sectors(const struct flash_area *fap)
10131015
uint32_t sz;
10141016
int rc;
10151017

1018+
BOOT_LOG_DBG("erasing trailer; fa_id=%d", fap->fa_id);
1019+
10161020
switch (fap->fa_id) {
10171021
case FLASH_AREA_IMAGE_PRIMARY:
10181022
slot = BOOT_PRIMARY_SLOT;
@@ -1101,6 +1105,7 @@ boot_swap_sectors(int idx, uint32_t sz, struct boot_status *bs)
11011105
assert (rc == 0);
11021106

11031107
if (bs->state == BOOT_STATUS_STATE_0) {
1108+
BOOT_LOG_DBG("erasing scratch area");
11041109
rc = boot_erase_sector(fap_scratch, 0, sz);
11051110
assert(rc == 0);
11061111

@@ -1289,13 +1294,15 @@ boot_copy_image(struct boot_status *bs)
12891294
* image is written without a trailer as is the case when using newt, the
12901295
* trailer that was left might trigger a new upgrade.
12911296
*/
1297+
BOOT_LOG_DBG("erasing secondary header");
12921298
rc = boot_erase_sector(fap_secondary_slot,
12931299
boot_img_sector_off(&boot_data,
12941300
BOOT_SECONDARY_SLOT, 0),
12951301
boot_img_sector_size(&boot_data,
12961302
BOOT_SECONDARY_SLOT, 0));
12971303
assert(rc == 0);
12981304
last_sector = boot_img_num_sectors(&boot_data, BOOT_SECONDARY_SLOT) - 1;
1305+
BOOT_LOG_DBG("erasing secondary trailer");
12991306
rc = boot_erase_sector(fap_secondary_slot,
13001307
boot_img_sector_off(&boot_data,
13011308
BOOT_SECONDARY_SLOT, last_sector),
@@ -1481,7 +1488,8 @@ boot_swap_image(struct boot_status *bs)
14811488

14821489
#ifdef MCUBOOT_VALIDATE_PRIMARY_SLOT
14831490
if (boot_status_fails > 0) {
1484-
BOOT_LOG_WRN("%d status write fails performing the swap", boot_status_fails);
1491+
BOOT_LOG_WRN("%d status write fails performing the swap",
1492+
boot_status_fails);
14851493
}
14861494
#endif
14871495

0 commit comments

Comments
 (0)