Skip to content

Additional dbg logging in MCUboot to allow easier finding of reason for image validation failure #2308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

de-nordic
Copy link
Collaborator

No description provided.

@de-nordic de-nordic force-pushed the additional-logs branch 12 times, most recently from 283c6f5 to f183240 Compare May 15, 2025 17:47
@de-nordic de-nordic marked this pull request as ready for review May 20, 2025 08:22
@@ -783,6 +799,7 @@ boot_image_load_header(const struct flash_area *fa_p,

if (!boot_u32_safe_add(&size, hdr->ih_img_size, hdr->ih_hdr_size) ||
size >= flash_area_get_size(fa_p)) {
BOOT_LOG_ERR("Incorrect image size");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should log them probably

@@ -411,6 +414,8 @@ boot_decrypt_key(const uint8_t *buf, uint8_t *enckey)
uint8_t *cpend;
size_t olen;
#endif

BOOT_LOG_DBG("boot_decrypt_key:");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing some debug?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I have done several of these as a general notification that code has entered specific function.

@@ -280,6 +287,8 @@ bootutil_find_key(uint8_t *keyhash, uint8_t keyhash_len)
const struct bootutil_key *key;
uint8_t hash[IMAGE_HASH_SIZE];

BOOT_LOG_DBG("bootutil_find_key:");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likewise here, the : makes it look like there is some expected output but other ones above do not have it when there is nothing to output

Comment on lines 286 to 298
BOOT_LOG_DBG("boot_version_cmp: ver1 %d.%d.%d vs ver2 %d.%d.%d",
ver1->iv_major, ver1->iv_minor, ver1->iv_revision,
ver2->iv_major, ver2->iv_minor, ver2->iv_revision);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should just log the full versions part if the Kconfig is enabled, having it output in 2 parts is ugly

@@ -2340,6 +2357,8 @@ context_boot_go(struct boot_loader_state *state, struct boot_rsp *rsp)
bool has_upgrade;
volatile int fih_cnt;

BOOT_LOG_DBG("context_boot_go:");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

@@ -120,6 +124,7 @@ bootutil_img_hash(struct boot_loader_state *state,
/* Encrypted images only exist in the secondary slot */
if (MUST_DECRYPT(fap, image_index, hdr) &&
!boot_enc_valid(enc_state, 1)) {
BOOT_LOG_DBG("bootutil_img_hash Error: encrypted image found in primary slot");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

: should be before error and error should be lowercase like other instances

@@ -262,6 +264,7 @@ boot_read_swap_state(const struct flash_area *fap,
off = boot_swap_info_off(fap);
rc = flash_area_read(fap, off, &swap_info, sizeof swap_info);
if (rc < 0) {
BOOT_LOG_DBG("boot_read_swap_state: error %d reading state", rc);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all places where code exits with BOOT_EFLASH i would go with BOOT_LOG_ERR()

de-nordic added 2 commits May 21, 2025 14:22
Add additional log lines to allow easier tracking potential
failures in image validation.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Improve logging to make it easier to track image validation
failures in development.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
@de-nordic de-nordic force-pushed the additional-logs branch 2 times, most recently from 1609c02 to a2b1cf2 Compare May 21, 2025 15:23
@de-nordic de-nordic requested a review from d3zd3z as a code owner May 21, 2025 15:23
@de-nordic de-nordic force-pushed the additional-logs branch 2 times, most recently from 24764d9 to 1609c02 Compare May 21, 2025 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants