Skip to content

Commit ca61577

Browse files
de-nordicnvlsianpu
authored andcommitted
[nrf fromtree] zephyr: Improve logging
Improve logging to make it easier to track image validation failures in development. Signed-off-by: Dominik Ermel <[email protected]> (cherry picked from commit c5011f2)
1 parent 0bef0bb commit ca61577

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
@@ -508,20 +508,25 @@ int main(void)
508508
mcuboot_status_change(MCUBOOT_STATUS_STARTUP);
509509

510510
#ifdef CONFIG_BOOT_SERIAL_ENTRANCE_GPIO
511+
BOOT_LOG_DBG("Checking GPIO for serial recovery");
511512
if (io_detect_pin() &&
512513
!io_boot_skip_serial_recovery()) {
513514
boot_serial_enter();
514515
}
515516
#endif
516517

517518
#ifdef CONFIG_BOOT_SERIAL_PIN_RESET
519+
BOOT_LOG_DBG("Checking RESET pin for serial recovery");
518520
if (io_detect_pin_reset()) {
519521
boot_serial_enter();
520522
}
521523
#endif
522524

523525
#if defined(CONFIG_BOOT_USB_DFU_GPIO)
526+
BOOT_LOG_DBG("Checking GPIO for USB DFU request");
524527
if (io_detect_pin()) {
528+
BOOT_LOG_DBG("Entering USB DFU");
529+
525530
usb_dfu_requested = true;
526531

527532
#ifdef CONFIG_MCUBOOT_INDICATION_LED
@@ -543,6 +548,7 @@ int main(void)
543548
BOOT_LOG_INF("Waiting for USB DFU");
544549

545550
#if defined(CONFIG_BOOT_USB_DFU_WAIT)
551+
BOOT_LOG_DBG("Waiting for USB DFU for %dms", CONFIG_BOOT_USB_DFU_WAIT_DELAY_MS);
546552
mcuboot_status_change(MCUBOOT_STATUS_USB_DFU_WAITING);
547553
wait_for_usb_dfu(K_MSEC(CONFIG_BOOT_USB_DFU_WAIT_DELAY_MS));
548554
BOOT_LOG_INF("USB DFU wait time elapsed");
@@ -574,12 +580,14 @@ int main(void)
574580
if (FIH_EQ(fih_rc, FIH_BOOT_HOOK_REGULAR)) {
575581
FIH_CALL(boot_go, fih_rc, &rsp);
576582
}
583+
BOOT_LOG_DBG("Left boot_go with success == %d", FIH_EQ(fih_rc, FIH_SUCCESS) ? 1 : 0);
577584

578585
#ifdef CONFIG_BOOT_SERIAL_BOOT_MODE
579586
if (io_detect_boot_mode()) {
580587
/* Boot mode to stay in bootloader, clear status and enter serial
581588
* recovery mode
582589
*/
590+
BOOT_LOG_DBG("Staying in serial recovery");
583591
boot_serial_enter();
584592
}
585593
#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)