You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/08/19 22:12:07 UTC

[08/12] incubator-mynewt-core git commit: bootutil; was returning wrong image header in response when swithing images. Add boot_set_req() routine for unit test use.

bootutil; was returning wrong image header in response when
swithing images. Add boot_set_req() routine for unit test use.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/ce4f1902
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/ce4f1902
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/ce4f1902

Branch: refs/heads/develop
Commit: ce4f1902cc4873937793fd527bd253f105f0d47b
Parents: 2331b50
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Aug 19 14:51:49 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Aug 19 15:11:50 2016 -0700

----------------------------------------------------------------------
 libs/bootutil/src/bootutil_priv.h |  3 +++
 libs/bootutil/src/loader.c        | 10 +++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ce4f1902/libs/bootutil/src/bootutil_priv.h
----------------------------------------------------------------------
diff --git a/libs/bootutil/src/bootutil_priv.h b/libs/bootutil/src/bootutil_priv.h
index 585f75c..7fe6eac 100644
--- a/libs/bootutil/src/bootutil_priv.h
+++ b/libs/bootutil/src/bootutil_priv.h
@@ -70,5 +70,8 @@ void boot_scratch_loc(uint8_t *flash_id, uint32_t *off);
 void boot_slot_magic(int slot_num, struct boot_img_trailer *bit);
 void boot_scratch_magic(struct boot_img_trailer *bit);
 
+struct boot_req;
+void boot_req_set(struct boot_req *req);
+
 #endif
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ce4f1902/libs/bootutil/src/loader.c
----------------------------------------------------------------------
diff --git a/libs/bootutil/src/loader.c b/libs/bootutil/src/loader.c
index b144c83..8037c98 100644
--- a/libs/bootutil/src/loader.c
+++ b/libs/bootutil/src/loader.c
@@ -47,6 +47,12 @@ static struct boot_status boot_state;
 static int boot_erase_area(int area_idx, uint32_t sz);
 static uint32_t boot_copy_sz(int max_idx, int *cnt);
 
+void
+boot_req_set(struct boot_req *req)
+{
+    boot_req = req;
+}
+
 /**
  * Calculates the flash offset of the specified image slot.
  *
@@ -491,6 +497,8 @@ boot_go(const struct boot_req *req, struct boot_rsp *rsp)
     }
 
     if (slot) {
+        boot_state.idx = 0;
+        boot_state.state = 0;
         rc = boot_copy_image();
         if (rc) {
             return rc;
@@ -500,7 +508,7 @@ boot_go(const struct boot_req *req, struct boot_rsp *rsp)
     /* Always boot from the primary slot. */
     rsp->br_flash_id = boot_img[0].loc.bil_flash_id;
     rsp->br_image_addr = boot_img[0].loc.bil_address;
-    rsp->br_hdr = &boot_img[0].hdr;
+    rsp->br_hdr = &boot_img[slot].hdr;
 
     return 0;
 }