-
Notifications
You must be signed in to change notification settings - Fork 236
Zephyr: introduce bootloader requests #477
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
base: main
Are you sure you want to change the base?
Zephyr: introduce bootloader requests #477
Conversation
832b4c9
to
ce1a921
Compare
ce1a921
to
f6f21a3
Compare
f6f21a3
to
0b5d331
Compare
0b5d331
to
911bb8c
Compare
911bb8c
to
2be0d3d
Compare
4e1ece5
to
9be377a
Compare
/** | ||
* @brief Request a bootloader to boot recovery image. | ||
* | ||
* @return 0 if requested, negative error code otherwise. | ||
*/ | ||
int boot_request_enter_recovery(void); | ||
|
||
/** | ||
* @brief Request a bootloader to boot firmware loader image. | ||
* | ||
* @return 0 if requested, negative error code otherwise. | ||
*/ | ||
int boot_request_enter_firmware_loader(void); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can both be combined into boot_request_enter_recovery
there is either serial recovery or firmware loader, not both
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not really like to enter firmware loader by calling boot_request_enter_recovery
API.
/** | ||
* @brief Check if there is a request to boot recovery image. | ||
* | ||
* @return true if requested, false otherwise. | ||
*/ | ||
bool boot_request_detect_recovery(void); | ||
|
||
/** | ||
* @brief Check if there is a request to boot firmware loader image. | ||
* | ||
* @return true if requested, false otherwise. | ||
*/ | ||
bool boot_request_detect_firmware_loader(void); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as above
|
||
enum boot_request_type { | ||
/** Invalid request. */ | ||
BOOT_REQUEST_INVALID = 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit. enums start at 0 and count up anyway, the values don't need to be explicitly set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to keep explicit values in enums if they define a value, that is shared between two contexts (app and bl), even if they follow the "automatic" assignment.
*slot = 0; | ||
break; | ||
case BOOT_REQUEST_IMG_PREFERENCE: | ||
*slot = 1 + image * BOOT_REQUEST_PER_IMAGE; | ||
break; | ||
case BOOT_REQUEST_IMG_CONFIRM: | ||
*slot = 2 + image * BOOT_REQUEST_PER_IMAGE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use enum for what these values mean, can actually then have a _COUNT
in the enum and use that for the number of states instead of just defining to 2 separately
case 0: | ||
value = BOOT_REQUEST_SLOT_PRIMARY; | ||
break; | ||
case 1: | ||
value = BOOT_REQUEST_SLOT_SECONDARY; | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as above
case 0: | ||
value = BOOT_REQUEST_SLOT_PRIMARY; | ||
break; | ||
case 1: | ||
value = BOOT_REQUEST_SLOT_SECONDARY; | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and further below
* @return 0 on success; nonzero on failure. | ||
*/ | ||
static int | ||
boot_request_slot_find(enum boot_request_type type, boot_request_img_t image, size_t *slot) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slot term is used for image partitions in MCUboot.
Can we have different name there - index, reqest_idx, req_idx, entry_idx?
And so one for any code related to request entries?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decided to go with the entry
name instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just wonder whether flash_area_to_image() -> flash_area_to_image() can more associated with a upstream patch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yet I do not have an argument, why this change is needed there...
ad1c9eb
to
dc8f8c6
Compare
dc8f8c6
to
cb3eee7
Compare
cb3eee7
to
0ac02e0
Compare
Add a bootloader hook to alter the logic of the active slot selection in Direct XIP modes. Signed-off-by: Tomasz Chyrowicz <[email protected]> (cherry picked from commit 7c4ec9a)
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]> (cherry picked from commit d5f84b4)
0ac02e0
to
8e08f2f
Compare
Add a capability inside the Zephyr bootloader to handle memory-based bootloader requests to: - Boot recovery firmware - Boot firmware loader - Confirm an image - Set the slot preference Ref: NCSDK-34429 Signed-off-by: Tomasz Chyrowicz <[email protected]>
8e08f2f
to
17ac549
Compare
|
In some cases, a Zephyr platform is not able to use the RAM-based retention subsystem. This results in no ability to communicate with the bootloader to:
The other case in which the application wants to communicate with the bootloader are platforms that want to have the active slot configured as read-only. In such case, the following flow can be introduced to mitigate this restriction:
There is also a third use case for the application requests in the Direct XIP mode:
This PR introduces an API that can be used to collect all of the above requests in a single module.
The Kconfig to select or extend the boot request format is located in the configuration file of the mcuboot module in the Zephyr repository.
In addition, a simple integration with bootutil library is included, allowing this feature to be used with an existing MCUmgr implementation.