You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ut...@apache.org on 2021/02/12 10:33:48 UTC

[mynewt-mcumgr] 02/02: zephyr: Use flash_img_init_id instead of flash_img_init

This is an automated email from the ASF dual-hosted git repository.

utzig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-mcumgr.git

commit 35d290eadf4414f4902da67e01b165a39e61080c
Author: Dominik Ermel <do...@nordicsemi.no>
AuthorDate: Thu Feb 11 12:14:41 2021 +0000

    zephyr: Use flash_img_init_id instead of flash_img_init
    
    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 <do...@nordicsemi.no>
---
 cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c b/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c
index ef72c1e..777aad5 100644
--- a/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c
+++ b/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c
@@ -292,7 +292,7 @@ img_mgmt_impl_write_image_data(unsigned int offset, const void *data,
 			}
 		}
 #endif
-		rc = flash_img_init(ctx);
+		rc = flash_img_init_id(ctx, img_mgmt_find_best_area_id());
 
 		if (rc != 0) {
 			return MGMT_ERR_EUNKNOWN;