Skip to content

Conversation

@adeaarm
Copy link
Contributor

@adeaarm adeaarm commented Dec 8, 2025

Currently error messages when the security counter updates fail (i.e. when Rollback protection is enabled) just return a textual string and possibly the image ID failing. Amend that such that it will also return the error code rc from the platform functions that are accessing the security counter, as it helps debugging where the issue might lie without providing a special build with logging enabled or attaching to the device which might be impractical.

Signed-off-by: Antonio de Angelis <[email protected]>
Change-Id: I6d18c6b555effaa7153c8098ebd813a65378689d
@adeaarm adeaarm requested a review from davidvincze as a code owner December 8, 2025 14:44
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

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.

2 participants