-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
dfu/boot: rework using newly introduced MCUBOOT_BOOTUTIL library #30370
dfu/boot: rework using newly introduced MCUBOOT_BOOTUTIL library #30370
Conversation
The following projects have a revision update in this Pull Request:
Note: This message is automatically posted and updated by the Manifest GitHub Action. |
7d5b848
to
29f2b5d
Compare
7a5e7b3
to
4bccc6f
Compare
4bccc6f
to
69d49c8
Compare
include/dfu/mcuboot.h
Outdated
* @return 0 on success, negative errno code on fail. | ||
*/ | ||
int mcuboot_read_swap_state_by_id(int flash_area_id, | ||
struct mcuboot_swap_state *state); |
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.
Is there a rationale for adding this function and struct mcuboot_swap_state
instead of just using boot_read_swap_state_by_id
and struct boot_swap_state
?
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.
boot_read_swap_state_by_id() can't be made zephyr API. It can only be used by module which made a module shim (as it links with MCUBOOT_BOOTUTIL) (by convention). For the MCUBoot shell i can link it with the library as well, and left behind this API.
Do you think that this API will be rather not useful for other?
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.
@utzig ^^?
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.
Ok, I think I understand, but shouldn't you also add the image_num
field to struct mcuboot_swap_state
since mcuboot_read_swap_state_by_id
still calls boot_read_swap_state_by_id
(including a proper pointer cast) and boot_read_swap_state
tries to populate boot_num
which you have not included in your definition of struct mcuboot_swap_state
. Is it correct?
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.
Adding image_num
would be a short term fix. We should not blindly cast one structure to the other, because that is error prone. Somebody will change order of fields or add new information to struct boot_swap_state
and we will be screwed once again.
So we should either:
- add helper
struct boot_swap_state
variable and copy each structure field separately, - link
MCUBOOT_BOOTUTIL
to mcuboot shell or other modules that use mcuboot public API.
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.
- link MCUBOOT_BOOTUTIL to mcuboot shell or other modules that use mcuboot public API.
Ok, I will go with that
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.
done
69d49c8
to
ad0e275
Compare
ad0e275
to
b9bd15e
Compare
89b7130
to
fdd19bc
Compare
I will squash patches once PR changes will be accepted. |
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.
Looks OK.
modules/Kconfig.mcuboot_bootutil
Outdated
#hiden option for disabling module-own log configuration | ||
#while building MCUboot bootloader |
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.
Missing space between # and first word.
bool boot_is_img_confirmed(void) | ||
{ | ||
return boot_image_ok_read(FLASH_AREA_IMAGE_PRIMARY) == BOOT_FLAG_SET; | ||
return flag_val == BOOT_FLAG_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 have noticed that it is not distinguished between failure to access the flag and the flag not being set.
This is not issue to this PR but maybe we need return some other type than bool to distinguish between failures and actual flag check.
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.
Reworking this would be an API change - so, yes not in this PR.
ade92ac
to
357993d
Compare
@mniestroj Squashed |
ffa9038
to
29e876f
Compare
@mniestroj Regard next step for eliminate copied definitions (so linking test, mcumgr, img_utill to MCUBOOT_BOOTUTIL library)- I will do that in the next PR which will open immediately after this will be merge. I think this PR is heavy enough - I prefer smaller chunks of patches. |
29e876f
to
c30de78
Compare
mcuboot counterpart PR zephyrproject-rtos/mcuboot#42 |
Some parts of subsys/dfu/boot code are re-implementations of what is implemented in the MCUBoot repository. Mcuboot's repository already provide implementation of function required for application for interact with the MCUboot. This patch introduces new MCUBOOT_BOOTUTIL module which covers common code which is used in the bootloader and the chainnloaded application. dfu/boot: use MCUBoot's source code Module was reworked so it start using MCUBoot's bootutil_public API instead of copied code. Reworked boot_is_img_confirmed() used MCUBoot's API for determine image_ok flag. mcuboot_shell switchd to use MCUboot's boot_read_swap_state_by_id() This is MCUBoot function, use it for avoid linking conflict. test/subsys/mcuboot: fix `test_write_confirm` dfu/boot library was reworked so it uses MCUboot's bootutil_public library whenever it can. The library required that image was marked as copy-done before it can be pending. This patch adds such mark which fixes the test. Signed-off-by: Andrzej Puzdrowski <[email protected]>
MCUboot support flash write-bock-size up to BOOT_MAX_ALIGN. This patch takes this into account. Signed-off-by: Andrzej Puzdrowski <[email protected]>
c30de78
to
ae6404d
Compare
Mcumgr-cli application doesn't accept log on the communication channel. Since zephyrproject-rtos#30370 was merged log messages are generated from MCUBOOT_UTIL by default. That made `mcumgr image upload` failing. Patch disables logging via shell which cure the issue. It is not necessary if another application on the host intercepts log messages (like picocom can). Signed-off-by: Andrzej Puzdrowski <[email protected]>
Mcumgr-cli application doesn't accept log on the communication channel. Since #30370 was merged log messages are generated from MCUBOOT_UTIL by default. That made `mcumgr image upload` failing. Patch disables logging via shell which cure the issue. It is not necessary if another application on the host intercepts log messages (like picocom can). Signed-off-by: Andrzej Puzdrowski <[email protected]>
Mcumgr-cli application doesn't accept log on the communication channel. Since zephyrproject-rtos#30370 was merged log messages are generated from MCUBOOT_UTIL by default. That made `mcumgr image upload` failing. Patch disables logging via shell which cure the issue. It is not necessary if another application on the host intercepts log messages (like picocom can). Signed-off-by: Andrzej Puzdrowski <[email protected]> (cherry picked from commit cb6e2a6) Signed-off-by: Johann Fischer <[email protected]> (cherry picked from commit 895f9ed)
depends on mcu-tools/mcuboot#892
As some code are defined here and there it becomes problem when module is compiled within MCUboot.
It is possible to mitigate problem using #fdefry - but this is temporary hack.
aim to supersede #30060
fixes #29963
step needed for merge this PR
get the Zephyr's release-team member who can assist with merges sequence smoothly