Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions boot/bootutil/src/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,10 @@ boot_copy_image(struct boot_loader_state *state, struct boot_status *bs)
*/
rc = boot_update_security_counter(state, BOOT_SLOT_PRIMARY, BOOT_SLOT_SECONDARY);
if (rc != 0) {
BOOT_LOG_ERR("Security counter update failed after image upgrade.");
BOOT_LOG_ERR(
"Security counter update failed after image upgrade (rc = 0x%x).",
Copy link
Collaborator

@nordicjm nordicjm Dec 9, 2025

Choose a reason for hiding this comment

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

let's use the same format of how we log errors in MCUboot already:

./boot/zephyr/main.c:        BOOT_LOG_ERR("flash_area_open failed with %d", rc);
./boot/zephyr/main.c:        BOOT_LOG_ERR("flash_area_read failed with %d", rc);
./boot/nuttx/src/flash_map_backend/flash_map_backend.c:      BOOT_LOG_ERR("Error retrieving MTD device geometry: %d", errcode);
./boot/nuttx/src/flash_map_backend/flash_map_backend.c:      BOOT_LOG_ERR("Error retrieving MTD partition info: %d", errcode);
./boot/nuttx/src/flash_map_backend/flash_map_backend.c:      BOOT_LOG_ERR("Error retrieving MTD device erase state: %d", errcode);
./boot/bootutil/src/encrypted_psa.c:        BOOT_LOG_ERR("Key derivation failed %d", psa_ret);
./boot/bootutil/src/encrypted_psa.c:        BOOT_LOG_ERR("Key derivation failed %d", psa_ret);
./boot/boot_serial/src/boot_serial.c:        BOOT_LOG_ERR("Failed to open flash areas: %d", rc);
./boot/boot_serial/src/boot_serial.c:            BOOT_LOG_ERR("Failed to read sectors: %d", rc);

and put it all on one line since the line length is 100 chars, fix in whole PR

rc);

return rc;
}
#endif /* MCUBOOT_HW_ROLLBACK_PROT */
Expand Down Expand Up @@ -1281,7 +1284,7 @@ boot_perform_update(struct boot_loader_state *state, struct boot_status *bs)
rc = boot_update_security_counter(state, BOOT_SLOT_PRIMARY, BOOT_SLOT_SECONDARY);
if (rc != 0) {
BOOT_LOG_ERR("Security counter update failed after "
"image upgrade.");
"image upgrade (rc = 0x%x).", rc);
BOOT_SWAP_TYPE(state) = BOOT_SWAP_TYPE_PANIC;
}
}
Expand Down Expand Up @@ -1614,16 +1617,18 @@ boot_update_hw_rollback_protection(struct boot_loader_state *state)
if (swap_state.magic != BOOT_MAGIC_GOOD || swap_state.image_ok == BOOT_FLAG_SET) {
rc = boot_update_security_counter(state, BOOT_SLOT_PRIMARY, BOOT_SLOT_PRIMARY);
if (rc != 0) {
BOOT_LOG_ERR("Security counter update failed after image %d validation.",
BOOT_CURR_IMG(state));
BOOT_LOG_ERR("Security counter update failed after image %d "
"validation (rc = 0x%x).",
BOOT_CURR_IMG(state), rc);
return rc;
}

#ifdef MCUBOOT_HW_ROLLBACK_PROT_LOCK
rc = boot_nv_security_counter_lock(BOOT_CURR_IMG(state));
if (rc != 0) {
BOOT_LOG_ERR("Security counter lock failed after image %d validation.",
BOOT_CURR_IMG(state));
BOOT_LOG_ERR("Security counter lock failed after image %d "
"validation (rc = 0x%x).",
BOOT_CURR_IMG(state), rc);
return rc;
}
#endif /* MCUBOOT_HW_ROLLBACK_PROT_LOCK */
Expand Down Expand Up @@ -2350,16 +2355,18 @@ boot_update_hw_rollback_protection(struct boot_loader_state *state)
state->slot_usage[BOOT_CURR_IMG(state)].active_slot,
state->slot_usage[BOOT_CURR_IMG(state)].active_slot);
if (rc != 0) {
BOOT_LOG_ERR("Security counter update failed after image %d validation.",
BOOT_CURR_IMG(state));
BOOT_LOG_ERR("Security counter update failed after image %d "
"validation (rc = 0x%x).",
BOOT_CURR_IMG(state), rc);
return rc;
}

#ifdef MCUBOOT_HW_ROLLBACK_PROT_LOCK
rc = boot_nv_security_counter_lock(BOOT_CURR_IMG(state));
if (rc != 0) {
BOOT_LOG_ERR("Security counter lock failed after image %d validation.",
BOOT_CURR_IMG(state));
BOOT_LOG_ERR("Security counter lock failed after image %d "
"validation (rc = 0x%x).",
BOOT_CURR_IMG(state), rc);
return rc;
}
#endif /* MCUBOOT_HW_ROLLBACK_PROT_LOCK */
Expand Down
Loading