diff options
author | Marko Kiiskila <marko@runtime.io> | 2016-08-19 14:51:49 -0700 |
---|---|---|
committer | Marko Kiiskila <marko@runtime.io> | 2016-08-19 15:11:50 -0700 |
commit | ce4f1902cc4873937793fd527bd253f105f0d47b (patch) | |
tree | dc477e73ac8107391f15d3b395ea8731beb87432 | |
parent | 2331b503e4421e82aa67033752e66b4c8ab3dd72 (diff) |
bootutil; was returning wrong image header in response when
swithing images. Add boot_set_req() routine for unit test use.
-rw-r--r-- | libs/bootutil/src/bootutil_priv.h | 3 | ||||
-rw-r--r-- | libs/bootutil/src/loader.c | 10 |
2 files changed, 12 insertions, 1 deletions
diff --git a/libs/bootutil/src/bootutil_priv.h b/libs/bootutil/src/bootutil_priv.h index 585f75c0..7fe6eace 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 diff --git a/libs/bootutil/src/loader.c b/libs/bootutil/src/loader.c index b144c836..8037c98c 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; } |