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/24 10:50:12 UTC

[mynewt-mcumgr] branch master updated: img_mgmt: Use IMG_MGMT_BOOT_CURR_SLOT as current running slot ID

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


The following commit(s) were added to refs/heads/master by this push:
     new 99f9fd6  img_mgmt: Use IMG_MGMT_BOOT_CURR_SLOT as current running slot ID
     new e289ead  Merge pull request #114 from de-nordic/img-mgmt-curr-slot
99f9fd6 is described below

commit 99f9fd685149cfb6f9be8442fed1d39c37a5990e
Author: Dominik Ermel <do...@nordicsemi.no>
AuthorDate: Thu Feb 18 11:56:19 2021 +0000

    img_mgmt: Use IMG_MGMT_BOOT_CURR_SLOT as current running slot ID
    
    The commit changes function img_mgmt_state_flasg functions to use
    IMG_MGMT_BOOT_CURR_SLOT in comparisons as a currently running slot
    number instead of previously hard-coded 0.
    The change allows to correctly identify active partition when
    application is running from different slot than 0.
    
    Signed-off-by: Dominik Ermel <do...@nordicsemi.no>
---
 cmd/img_mgmt/src/img_mgmt_state.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/cmd/img_mgmt/src/img_mgmt_state.c b/cmd/img_mgmt/src/img_mgmt_state.c
index ffbdd8e..79d147b 100644
--- a/cmd/img_mgmt/src/img_mgmt_state.c
+++ b/cmd/img_mgmt/src/img_mgmt_state.c
@@ -46,32 +46,32 @@ img_mgmt_state_flags(int query_slot)
     swap_type = img_mgmt_impl_swap_type();
     switch (swap_type) {
     case IMG_MGMT_SWAP_TYPE_NONE:
-        if (query_slot == 0) {
+        if (query_slot == IMG_MGMT_BOOT_CURR_SLOT) {
             flags |= IMG_MGMT_STATE_F_CONFIRMED;
             flags |= IMG_MGMT_STATE_F_ACTIVE;
         }
         break;
 
     case IMG_MGMT_SWAP_TYPE_TEST:
-        if (query_slot == 0) {
+        if (query_slot == IMG_MGMT_BOOT_CURR_SLOT) {
             flags |= IMG_MGMT_STATE_F_CONFIRMED;
-        } else if (query_slot == 1) {
+        } else {
             flags |= IMG_MGMT_STATE_F_PENDING;
         }
         break;
 
     case IMG_MGMT_SWAP_TYPE_PERM:
-        if (query_slot == 0) {
+        if (query_slot == IMG_MGMT_BOOT_CURR_SLOT) {
             flags |= IMG_MGMT_STATE_F_CONFIRMED;
-        } else if (query_slot == 1) {
+        } else {
             flags |= IMG_MGMT_STATE_F_PENDING | IMG_MGMT_STATE_F_PERMANENT;
         }
         break;
 
     case IMG_MGMT_SWAP_TYPE_REVERT:
-        if (query_slot == 0) {
+        if (query_slot == IMG_MGMT_BOOT_CURR_SLOT) {
             flags |= IMG_MGMT_STATE_F_ACTIVE;
-        } else if (query_slot == 1) {
+        } else {
             flags |= IMG_MGMT_STATE_F_CONFIRMED;
         }
         break;
@@ -79,7 +79,7 @@ img_mgmt_state_flags(int query_slot)
 
     /* Slot 0 is always active. */
     /* XXX: The slot 0 assumption only holds when running from flash. */
-    if (query_slot == 0) {
+    if (query_slot == IMG_MGMT_BOOT_CURR_SLOT) {
         flags |= IMG_MGMT_STATE_F_ACTIVE;
     }
 
@@ -300,7 +300,7 @@ img_mgmt_state_write(struct mgmt_ctxt *ctxt)
     /* Determine which slot is being operated on. */
     if (hash_len == 0) {
         if (confirm) {
-            slot = 0;
+            slot = IMG_MGMT_BOOT_CURR_SLOT;
         } else {
             /* A 'test' without a hash is invalid. */
             return MGMT_ERR_EINVAL;
@@ -312,7 +312,7 @@ img_mgmt_state_write(struct mgmt_ctxt *ctxt)
         }
     }
 
-    if (slot == 0 && confirm) {
+    if (slot == IMG_MGMT_BOOT_CURR_SLOT && confirm) {
         /* Confirm current setup. */
         rc = img_mgmt_state_confirm();
     } else {