Skip to content

Commit bd265d2

Browse files
committed
zephyr: Improve logging
Improve logging to make it easier to track image validation failures in development. Signed-off-by: Dominik Ermel <[email protected]>
1 parent 2b5eae8 commit bd265d2

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

boot/zephyr/firmware_loader.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ boot_image_validate(const struct flash_area *fa_p,
4040
static uint8_t tmpbuf[BOOT_TMPBUF_SZ];
4141
FIH_DECLARE(fih_rc, FIH_FAILURE);
4242

43+
BOOT_LOG_DBG("boot_image_validate: encrypted == %d", (int)IS_ENCRYPTED(hdr));
44+
4345
/* NOTE: The first argument to boot_image_validate, for enc_state pointer,
4446
* is allowed to be NULL only because the single image loader compiles
4547
* with BOOT_IMAGE_NUMBER == 1, which excludes the code that uses
@@ -71,6 +73,8 @@ boot_image_validate_once(const struct flash_area *fa_p,
7173
int rc;
7274
FIH_DECLARE(fih_rc, FIH_FAILURE);
7375

76+
BOOT_LOG_DBG("boot_image_validate_once: flash area %p", fap_p);
77+
7478
memset(&state, 0, sizeof(struct boot_swap_state));
7579
rc = boot_read_swap_state(fa_p, &state);
7680
if (rc != 0)
@@ -108,6 +112,8 @@ static fih_ret validate_image_slot(int slot, struct boot_rsp *rsp)
108112
int rc = -1;
109113
FIH_DECLARE(fih_rc, FIH_FAILURE);
110114

115+
BOOT_LOG_DBG("validate_image_slot: slot %d", slot);
116+
111117
rc = flash_area_open(slot, &_fa_p);
112118
assert(rc == 0);
113119

@@ -156,6 +162,8 @@ boot_go(struct boot_rsp *rsp)
156162
bool boot_firmware_loader = false;
157163
FIH_DECLARE(fih_rc, FIH_FAILURE);
158164

165+
BOOT_LOG_DBG("boot_go: firmware loader");
166+
159167
#ifdef CONFIG_BOOT_FIRMWARE_LOADER_ENTRANCE_GPIO
160168
if (io_detect_pin() &&
161169
!io_boot_skip_serial_recovery()) {

boot/zephyr/main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,20 +459,24 @@ int main(void)
459459
mcuboot_status_change(MCUBOOT_STATUS_STARTUP);
460460

461461
#ifdef CONFIG_BOOT_SERIAL_ENTRANCE_GPIO
462+
BOOT_LOG_DBG("Checking GPIO for serial recovery");
462463
if (io_detect_pin() &&
463464
!io_boot_skip_serial_recovery()) {
464465
boot_serial_enter();
465466
}
466467
#endif
467468

468469
#ifdef CONFIG_BOOT_SERIAL_PIN_RESET
470+
BOOT_LOG_DBG("Checking RESET pin for serial recovery");
469471
if (io_detect_pin_reset()) {
470472
boot_serial_enter();
471473
}
472474
#endif
473475

474476
#if defined(CONFIG_BOOT_USB_DFU_GPIO)
477+
BOOT_LOG_DBG("Checking GPIO for USB DFU request");
475478
if (io_detect_pin()) {
479+
BOOT_LOG_DBG("Entering USB DFU");
476480
#ifdef CONFIG_MCUBOOT_INDICATION_LED
477481
io_led_set(1);
478482
#endif
@@ -489,6 +493,7 @@ int main(void)
489493
}
490494
}
491495
#elif defined(CONFIG_BOOT_USB_DFU_WAIT)
496+
BOOT_LOG_DBG("Waiting for USB DFU for %dms", CONFIG_BOOT_USB_DFU_WAIT_DELAY_MS);
492497
rc = usb_enable(NULL);
493498
if (rc) {
494499
BOOT_LOG_ERR("Cannot enable USB");
@@ -523,12 +528,14 @@ int main(void)
523528
if (FIH_EQ(fih_rc, FIH_BOOT_HOOK_REGULAR)) {
524529
FIH_CALL(boot_go, fih_rc, &rsp);
525530
}
531+
BOOT_LOG_DBG("Left boot_go with success == %d", FIH_EQ(fih_rc, FIH_SUCCESS) ? 1 : 0);
526532

527533
#ifdef CONFIG_BOOT_SERIAL_BOOT_MODE
528534
if (io_detect_boot_mode()) {
529535
/* Boot mode to stay in bootloader, clear status and enter serial
530536
* recovery mode
531537
*/
538+
BOOT_LOG_DBG("Staying in serial recovery");
532539
boot_serial_enter();
533540
}
534541
#endif

boot/zephyr/single_loader.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ boot_image_validate(const struct flash_area *fa_p,
4444
static uint8_t tmpbuf[BOOT_TMPBUF_SZ];
4545
FIH_DECLARE(fih_rc, FIH_FAILURE);
4646

47+
BOOT_LOG_DBG("boot_image_validate: encrypted == %d", (int)IS_ENCRYPTED(hdr));
48+
4749
/* NOTE: The first argument to boot_image_validate, for enc_state pointer,
4850
* is allowed to be NULL only because the single image loader compiles
4951
* with BOOT_IMAGE_NUMBER == 1, which excludes the code that uses
@@ -75,6 +77,8 @@ boot_image_validate_once(const struct flash_area *fa_p,
7577
int rc;
7678
FIH_DECLARE(fih_rc, FIH_FAILURE);
7779

80+
BOOT_LOG_DBG("boot_image_validate_once: flash area %p", fap_p);
81+
7882
memset(&state, 0, sizeof(struct boot_swap_state));
7983
rc = boot_read_swap_state(fa_p, &state);
8084
if (rc != 0)
@@ -112,6 +116,8 @@ boot_go(struct boot_rsp *rsp)
112116
int rc = -1;
113117
FIH_DECLARE(fih_rc, FIH_FAILURE);
114118

119+
BOOT_LOG_DBG("boot_go: Single loader");
120+
115121
rc = flash_area_open(FLASH_AREA_IMAGE_PRIMARY(0), &_fa_p);
116122
assert(rc == 0);
117123

0 commit comments

Comments
 (0)