You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2021/06/15 15:10:32 UTC

[GitHub] [mynewt-mcumgr] de-nordic commented on a change in pull request #124: Zephyr fixes

de-nordic commented on a change in pull request #124:
URL: https://github.com/apache/mynewt-mcumgr/pull/124#discussion_r651889668



##########
File path: cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c
##########
@@ -108,48 +108,23 @@ zephyr_img_mgmt_flash_area_id(int slot)
         break;
 
     default:
-        assert(0);
-        fa_id = FLASH_AREA_ID(image_1);
+        fa_id = -1;
         break;
     }
 
     return fa_id;
 }
 
+/**
+ * The function will check if second(ary) slot is available, and allowed,
+ * for DFU; if checks area positive, then area ID is returned, -1 is returned
+ * otherwise.
+ */
 static int
-img_mgmt_find_best_area_id(void)
+img_mgmt_get_second_slot_area_id(void)
 {
-    struct image_version ver;
-    int best = -1;
-    int i;
-    int rc;
-
-    for (i = 0; i < 2; i++) {
-        rc = img_mgmt_read_info(i, &ver, NULL, NULL);
-        if (rc < 0) {
-            continue;
-        }
-        if (rc == 0) {
-            /* Image in slot is ok. */
-            if (img_mgmt_slot_in_use(i)) {
-                /* Slot is in use; can't use this. */
-                continue;
-            } else {
-                /*
-                 * Not active slot, but image is ok. Use it if there are
-                 * no better candidates.
-                 */
-                best = i;
-            }
-            continue;
-        }
-        best = i;
-        break;
-    }
-    if (best >= 0) {
-        best = zephyr_img_mgmt_flash_area_id(best);
-    }
-    return best;
+    /* In case of Zephyr slot 0 is always unavailable */
+    return img_mgmt_slot_in_use(1) == 0 ? zephyr_img_mgmt_flash_area_id(1) : -1;

Review comment:
       You are right. I have completely forgotten about the Direct-XIP. Thanks!




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org