Skip to content
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

Use img_mgmt_find_best_area_id to select upload slot instead of FLASH_AREA_ID #110

Merged
merged 2 commits into from
Feb 12, 2021

Conversation

de-nordic
Copy link
Contributor

The mcumgr should relay on single decision point for upload flash area selection; instead the img_mgmt_find_best_area_id and FLASH_AREA_ID macros were used for similar purpose through the code, even though img_mgmt_find_best_area_id is more restrictive and may not agree with FLASH_AREA_ID.

The img_mgmt_find_best_area_id is supposed to figure out the best, which
also means possible, partition for software update.
Unfortunately in the code in many places the direct reference the to
FLASH_AREA_ID(image_1) is used, which may cause image_1 being
overwritten, even if other partition would be selected as the "best".

Signed-off-by: Dominik Ermel <[email protected]>
Within mcumgr Zephyr port, the img_mgmt_find_best_area_id is used to
get information on the update flash ID, yet the call to the flash_img_init
selects such flash ID via value hardcoded during compilation. This may
lead to situation where the mcumgr library and flash_img_init may select
different partition for update.
This commit replaces call to flash_img_init with flash_img_init_id, which
takes flash area ID as a parameter, and uses img_mgmt_find_best_area_id
to get the ID.
This approach is better as img_mgmt_find_best_area_id, while searching for
empty image, will also check its boot status (pending, test, etc).

Signed-off-by: Dominik Ermel <[email protected]>
de-nordic added a commit to de-nordic/zephyr that referenced this pull request Feb 11, 2021
This is test commit for mcumgr change:
 apache/mynewt-mcumgr#110

Signed-off-by: Dominik Ermel <[email protected]>
@de-nordic
Copy link
Contributor Author

@nvlsianpu , @utzig Please check.
The Zephyr test commit is here: zephyrproject-rtos/zephyr#32215

Copy link
Contributor

@nvlsianpu nvlsianpu left a comment

Choose a reason for hiding this comment

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

Need to ensure that img_mgmt_slot_in_use() might recognize active slot for direct-xip MCUboot mode.
flash_img_init() might be removed.

@utzig utzig merged commit 35d290e into apache:master Feb 12, 2021
@de-nordic de-nordic deleted the fix-flash-id-selection branch February 22, 2021 08:09
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.

3 participants