Skip to content

Conversation

hellesvik-nordic
Copy link
Contributor

An unprovisioned KMU can cause confusion, so improve the logs for this case.


BOOT_LOG_ERR("ED25519 signature verification failed %d", status);
if(status == PSA_ERROR_INVALID_HANDLE) {
BOOT_LOG_ERR("PSA_ERROR_INVALID_HANDLE(-136) could mean that the KMU slot is not provisioned.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
BOOT_LOG_ERR("PSA_ERROR_INVALID_HANDLE(-136) could mean that the KMU slot is not provisioned.");
BOOT_LOG_ERR("PSA ED25519 signature failed (-136), unknown key ID");

Are you sure we want to be that verbose? Non KMU specific message could actually be brought upstream too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would argue that we want users to think "Oh I need to provision the KMU" when reading the message, so at the very least the KMU should be mentioned.
This function is also KMU specific (inside the elif) so I think it makes sense to mention the KMU in the log.

@de-nordic de-nordic requested a review from nvlsianpu May 15, 2025 08:33
@rlubos rlubos requested a review from nordicjm as a code owner May 15, 2025 09:57
@hellesvik-nordic hellesvik-nordic marked this pull request as draft May 16, 2025 06:39
@hellesvik-nordic
Copy link
Contributor Author

@de-nordic, I added CONFIG_MCUBOOT_SETUP_VALIDATION, which might be what we talked about. What do you think about this?

Copy link
Contributor

@nordicjm nordicjm left a comment

Choose a reason for hiding this comment

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

4 space indent for C code in mcuboot
tab indent for Kconfigs
No default n in Kconfig, that is the default
1x tab followed by 2x spaces for Kconfig help text indent

@hellesvik-nordic
Copy link
Contributor Author

After discussing with @de-nordic directly, we concluded that this change will not need a Kconfig option, as this is a one-off extra log to catch a very common error case.

@hellesvik-nordic hellesvik-nordic marked this pull request as ready for review May 28, 2025 12:02
Checks if the KMU has been provisioned, and add extra log if it has not.
Error 136 could theoretically be caused by something else, so the
extra logs is not phrased in a absolute manner.

Fixes: NCSDK-33559

Signed-off-by: Sigurd Hellesvik <[email protected]>
Copy link

sonarqubecloud bot commented Jun 3, 2025

Copy link
Contributor

@nordicjm nordicjm left a comment

Choose a reason for hiding this comment

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

my problem with this is that this bloats anyone whose got logging enabled's code on a condition that will only appear on someone's board who doesn't know what they are doing or doesn't read documentation or doesn't use the new (default) kconfig that is being added to automatically provision things

}

BOOT_LOG_ERR("ED25519 signature verification failed %d", status);
if(status == PSA_ERROR_INVALID_HANDLE) {
Copy link
Contributor

Choose a reason for hiding this comment

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

space between if and bracket in c

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will only appear on someone's board who doesn't know what they are doing or doesn't read documentation

For these two, I would say that we should still warn for this case, as users who just program a sample can get this error. But then you say:

or doesn't use the new (default) kconfig that is being added to automatically provision things

And with this, Im not sure that this warning is needed after all.
The use-case for this PR is the following:

"I think that users should be able to enable a bootloader in any project without having to have a full overview over everything that happens. If the default case is that they need to provision manually, then pretty much everyone will get an error first time they try, and we should then tell them that they need to provision, so not everyone has to spend an hour reading docs to find the line saying they should provision."

However, if the devices will be automatically provisioned by default, then I think we can expect users that set CONFIG_MANUAL_PROVISION or whatever should understand the consequence of this, and the use-case for this PR is no longer valid.

@nordicjm Do I understand correctly that from v3.1.0 and onwards, the nRF54L15 KMU will be provisioned when I run "west flash", so that both MCUboot and NSIB will run without any issues first try?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if it's 3.1.0 or how it fully works because not tried running it manually myself but PR is nrfconnect/sdk-nrf#22516

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is good enough for me.
I will close this PR, and then test the new provisioning feature with "west flash" when that is ready to verify that it indeed solves the problem I see.

@hellesvik-nordic
Copy link
Contributor Author

A lot less reasons to give another warning for un-provisioned KMU if the KMU is provisioned by default:
nrfconnect/sdk-nrf#22516

@gchwier
Copy link
Contributor

gchwier commented Jun 20, 2025

A lot less reasons to give another warning for un-provisioned KMU if the KMU is provisioned by default: nrfconnect/sdk-nrf#22516

but it will not be provisioned by default, user must set:

  • SB_CONFIG_SECURE_BOOT_GENERATE_DEFAULT_KMU_KEYFILE, for NSIB or
  • SB_CONFIG_MCUBOOT_GENERATE_DEFAULT_KMU_KEYFILE for MCUboot,

So still the problem exists.

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.

5 participants