You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2018/01/04 03:01:15 UTC

[mynewt-mcumgr] 01/08: img - Add `slot` param to `img_impl_write_pending`

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

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

commit 7ada577e39714ce19743bb215b1f7c33f945f52b
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Wed Jan 3 12:06:44 2018 -0800

    img - Add `slot` param to `img_impl_write_pending`
    
    The old interface precluded the use of split images in Mynewt.  For
    non-split-images, the `slot` argument is always 1.
---
 img/include/img/img_impl.h       | 8 +++++---
 img/port/zephyr/src/zephyr_img.c | 5 ++++-
 img/src/img_state.c              | 9 +--------
 3 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/img/include/img/img_impl.h b/img/include/img/img_impl.h
index f634110..7c3248d 100644
--- a/img/include/img/img_impl.h
+++ b/img/include/img/img_impl.h
@@ -14,9 +14,11 @@
 int img_impl_erase_slot(void);
 
 /**
- * @brief Marks the image in slot 1 as pending. On the next reboot, the system
- * will perform a boot of the slot 1 image.
+ * @brief Marks the image in the specified slot as pending. On the next reboot,
+ * the system will perform a boot of the specified image.
  *
+ * @param slot The slot to mark as pending.  In the typical use case, this is
+ * 1.
  * @param permanent Whether the image should be used permanently or
  * only tested once:
  *   0=run image once, then confirm or revert.
@@ -24,7 +26,7 @@ int img_impl_erase_slot(void);
  *
  * @return 0 on success, MGMT_ERR_[...] code on failure.
  */
-int img_impl_write_pending(bool permanent);
+int img_impl_write_pending(int slot, bool permanent);
 
 /**
  * @brief Marks the image in slot 0 as confirmed. The system will continue
diff --git a/img/port/zephyr/src/zephyr_img.c b/img/port/zephyr/src/zephyr_img.c
index f99d5fe..4d298eb 100644
--- a/img/port/zephyr/src/zephyr_img.c
+++ b/img/port/zephyr/src/zephyr_img.c
@@ -105,11 +105,14 @@ img_impl_erase_slot(void)
 }
 
 int
-img_impl_write_pending(bool permanent)
+img_impl_write_pending(int slot, bool permanent)
 {
     int rc;
 
     img_impl_init_flash();
+    if (slot != 1) {
+        return MGMT_ERR_EINVAL;
+    }
 
     rc = boot_request_upgrade(permanent);
     if (rc != 0) {
diff --git a/img/src/img_state.c b/img/src/img_state.c
index b8ae6fa..84b797f 100644
--- a/img/src/img_state.c
+++ b/img/src/img_state.c
@@ -106,7 +106,6 @@ img_state_slot_in_use(int slot)
 int
 img_state_set_pending(int slot, int permanent)
 {
-    uint32_t image_flags;
     uint8_t state_flags;
     int rc;
 
@@ -119,12 +118,7 @@ img_state_set_pending(int slot, int permanent)
         return MGMT_ERR_EBADSTATE;
     }
 
-    rc = img_read_info(slot, NULL, NULL, &image_flags);
-    if (rc != 0) {
-        return MGMT_ERR_EUNKNOWN;
-    }
-
-    rc = img_impl_write_pending(permanent);
+    rc = img_impl_write_pending(slot, permanent);
     if (rc != 0) {
         return MGMT_ERR_EUNKNOWN;
     }
@@ -142,7 +136,6 @@ img_state_confirm(void)
         return MGMT_ERR_EBADSTATE;
     }
 
-    /* Confirm the unified image or loader in slot 0. */
     rc = img_impl_write_confirmed();
     if (rc != 0) {
         return MGMT_ERR_EUNKNOWN;

-- 
To stop receiving notification emails like this one, please contact
"commits@mynewt.apache.org" <co...@mynewt.apache.org>.