Skip to content

Commit c5011f2

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 11f9c6f commit c5011f2

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,20 +463,25 @@ int main(void)
463463
mcuboot_status_change(MCUBOOT_STATUS_STARTUP);
464464

465465
#ifdef CONFIG_BOOT_SERIAL_ENTRANCE_GPIO
466+
BOOT_LOG_DBG("Checking GPIO for serial recovery");
466467
if (io_detect_pin() &&
467468
!io_boot_skip_serial_recovery()) {
468469
boot_serial_enter();
469470
}
470471
#endif
471472

472473
#ifdef CONFIG_BOOT_SERIAL_PIN_RESET
474+
BOOT_LOG_DBG("Checking RESET pin for serial recovery");
473475
if (io_detect_pin_reset()) {
474476
boot_serial_enter();
475477
}
476478
#endif
477479

478480
#if defined(CONFIG_BOOT_USB_DFU_GPIO)
481+
BOOT_LOG_DBG("Checking GPIO for USB DFU request");
479482
if (io_detect_pin()) {
483+
BOOT_LOG_DBG("Entering USB DFU");
484+
480485
usb_dfu_requested = true;
481486

482487
#ifdef CONFIG_MCUBOOT_INDICATION_LED
@@ -498,6 +503,7 @@ int main(void)
498503
BOOT_LOG_INF("Waiting for USB DFU");
499504

500505
#if defined(CONFIG_BOOT_USB_DFU_WAIT)
506+
BOOT_LOG_DBG("Waiting for USB DFU for %dms", CONFIG_BOOT_USB_DFU_WAIT_DELAY_MS);
501507
mcuboot_status_change(MCUBOOT_STATUS_USB_DFU_WAITING);
502508
wait_for_usb_dfu(K_MSEC(CONFIG_BOOT_USB_DFU_WAIT_DELAY_MS));
503509
BOOT_LOG_INF("USB DFU wait time elapsed");
@@ -529,12 +535,14 @@ int main(void)
529535
if (FIH_EQ(fih_rc, FIH_BOOT_HOOK_REGULAR)) {
530536
FIH_CALL(boot_go, fih_rc, &rsp);
531537
}
538+
BOOT_LOG_DBG("Left boot_go with success == %d", FIH_EQ(fih_rc, FIH_SUCCESS) ? 1 : 0);
532539

533540
#ifdef CONFIG_BOOT_SERIAL_BOOT_MODE
534541
if (io_detect_boot_mode()) {
535542
/* Boot mode to stay in bootloader, clear status and enter serial
536543
* recovery mode
537544
*/
545+
BOOT_LOG_DBG("Staying in serial recovery");
538546
boot_serial_enter();
539547
}
540548
#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)