Skip to content

loader: Add boot hook for slot selection #2402

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

tomchy
Copy link
Contributor

@tomchy tomchy commented Jul 24, 2025

Add a bootloader hook to alter the logic of the active slot selection in Direct XIP modes.

@tomchy tomchy changed the title Zeohyr: introduce bootloader requests Zephyr: introduce bootloader requests Jul 24, 2025
Copy link
Collaborator

@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.

this is not how common code should work, bootutil is a common file for any RTOS, any zephyr specific code goes in boot/zephyr, and there should be no checking of e.g. Kconfigs in common code

@tomchy
Copy link
Contributor Author

tomchy commented Jul 24, 2025

this is not how common code should work, bootutil is a common file for any RTOS, any zephyr specific code goes in boot/zephyr, and there should be no checking of e.g. Kconfigs in common code

Is there a place for a code that is zephyr-specific, yet should be shared between the app and bootloader?

Honestly, I had an impression that the shared code/library problem is not fully resolved in the MCUboot ATM, so we are seeking for good ideas here 🙂

Side note: that's one of the reasons why this is a draft PR.

@nordicjm
Copy link
Collaborator

this is not how common code should work, bootutil is a common file for any RTOS, any zephyr specific code goes in boot/zephyr, and there should be no checking of e.g. Kconfigs in common code

Is there a place for a code that is zephyr-specific, yet should be shared between the app and bootloader?

Honestly, I had an impression that the shared code/library problem is not fully resolved in the MCUboot ATM, so we are seeking for good ideas here 🙂

Side note: that's one of the reasons why this is a draft PR.

Depends what it is, if it's zephyr centric then it can go into zephyr itself (e.g. boot mode is in zephyr and used in apps and mcuboot), I'm not sure what this code really does or what part is meant to be shared

@tomchy tomchy force-pushed the feature/zephyr/NCSDK-NONE_boot_requests branch from 91713dd to c58b35c Compare July 25, 2025 12:15
@tomchy
Copy link
Contributor Author

tomchy commented Jul 25, 2025

this is not how common code should work, bootutil is a common file for any RTOS, any zephyr specific code goes in boot/zephyr, and there should be no checking of e.g. Kconfigs in common code

Is there a place for a code that is zephyr-specific, yet should be shared between the app and bootloader?
Honestly, I had an impression that the shared code/library problem is not fully resolved in the MCUboot ATM, so we are seeking for good ideas here 🙂
Side note: that's one of the reasons why this is a draft PR.

Depends what it is, if it's zephyr centric then it can go into zephyr itself (e.g. boot mode is in zephyr and used in apps and mcuboot), I'm not sure what this code really does or what part is meant to be shared

Sine the boot request API is used by the bootutil logic, I decided to move it into the MCUBoot include directory.
That way the header is common, but the implementation is platform-specific (just like the security counter API).
There is still one Kconfig left: the CONFIG_MCUBOOT as it was already there for changing the implementation, based on the context (app vs bootloader). If there is a MCUboot-centric way to do that, let me know, I'll be happy to replace it.

If you agree on the current split, I'll add a note about the new configuration option inside the MCUboot docs.

@tomchy tomchy requested a review from nordicjm July 25, 2025 12:23
@tomchy tomchy force-pushed the feature/zephyr/NCSDK-NONE_boot_requests branch from c58b35c to e3d5b8e Compare July 28, 2025 10:50
@tomchy tomchy changed the title Zephyr: introduce bootloader requests loader: Add boot hook for slot selection Jul 28, 2025
@tomchy
Copy link
Contributor Author

tomchy commented Jul 28, 2025

Scope reduced to the bootloader hook for the active slot selection.

@tomchy tomchy marked this pull request as ready for review July 28, 2025 10:53
Copy link
Collaborator

@de-nordic de-nordic left a comment

Choose a reason for hiding this comment

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

Separate Zephyr and bootutil code into different commits.

@de-nordic de-nordic added area: core Affects core functionality area: zephyr Affects the Zephyr port labels Jul 29, 2025
@tomchy tomchy force-pushed the feature/zephyr/NCSDK-NONE_boot_requests branch from e3d5b8e to 85dc002 Compare July 30, 2025 10:11
@tomchy tomchy requested a review from de-nordic July 30, 2025 10:11
@tomchy tomchy force-pushed the feature/zephyr/NCSDK-NONE_boot_requests branch from 85dc002 to aa5fd8b Compare July 30, 2025 14:23
tomchy added 2 commits July 30, 2025 16:23
Add a bootloader hook to alter the logic of the active slot selection in
Direct XIP modes.

Signed-off-by: Tomasz Chyrowicz <[email protected]>
Add a Kconfig option to enable a bootloader hook to alter
the logic of the active slot selection in Direct XIP modes.

Signed-off-by: Tomasz Chyrowicz <[email protected]>
@tomchy tomchy force-pushed the feature/zephyr/NCSDK-NONE_boot_requests branch from aa5fd8b to fba755f Compare July 30, 2025 14:23
@tomchy tomchy requested a review from de-nordic July 30, 2025 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: core Affects core functionality area: zephyr Affects the Zephyr port
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants