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:46 UTC
[mynewt-mcumgr] branch master updated (130ae98 -> 35d290e)
This is an automated email from the ASF dual-hosted git repository.
utzig pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-mcumgr.git.
from 130ae98 Merge pull request #111 from utzig/fix-linked-list
new c8151d8 zephyr: Rely on img_mgmt_find_best_area_id to select update partition
new 35d290e zephyr: Use flash_img_init_id instead of flash_img_init
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
[mynewt-mcumgr] 01/02: zephyr: Rely on img_mgmt_find_best_area_id
to select update partition
Posted by ut...@apache.org.
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 c8151d8023f2f985c66a9dcecb4e741cf5306393
Author: Dominik Ermel <do...@nordicsemi.no>
AuthorDate: Thu Feb 11 12:08:22 2021 +0000
zephyr: Rely on img_mgmt_find_best_area_id to select update partition
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 <do...@nordicsemi.no>
---
cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
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 d6169b8..ef72c1e 100644
--- a/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c
+++ b/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c
@@ -194,14 +194,16 @@ img_mgmt_impl_erase_slot(void)
bool empty;
int rc;
- rc = zephyr_img_mgmt_flash_check_empty(FLASH_AREA_ID(image_1),
- &empty);
+ /* Select non-active slot */
+ const int best_id = img_mgmt_find_best_area_id();
+
+ rc = zephyr_img_mgmt_flash_check_empty(best_id, &empty);
if (rc != 0) {
return MGMT_ERR_EUNKNOWN;
}
if (!empty) {
- rc = boot_erase_img_bank(FLASH_AREA_ID(image_1));
+ rc = boot_erase_img_bank(best_id);
if (rc != 0) {
return MGMT_ERR_EUNKNOWN;
}
@@ -328,7 +330,7 @@ img_mgmt_impl_erase_image_data(unsigned int off, unsigned int num_bytes)
goto end;
}
- rc = flash_area_open(FLASH_AREA_ID(image_1), &fa);
+ rc = flash_area_open(img_mgmt_find_best_area_id(), &fa);
if (rc != 0) {
LOG_ERR("Can't bind to the flash area (err %d)", rc);
rc = MGMT_ERR_EUNKNOWN;
[mynewt-mcumgr] 02/02: zephyr: Use flash_img_init_id instead of
flash_img_init
Posted by ut...@apache.org.
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;