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 2016/12/13 22:51:01 UTC
incubator-mynewt-core git commit: bootutil tests - Don't assume
min-write-sz==1.
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/develop 5e0f1bce5 -> 70f72d24d
bootutil tests - Don't assume min-write-sz==1.
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/70f72d24
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/70f72d24
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/70f72d24
Branch: refs/heads/develop
Commit: 70f72d24de1b85c5cf66df5497daf1e9bd0a2fe3
Parents: 5e0f1bc
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Dec 13 14:50:29 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Dec 13 14:50:56 2016 -0800
----------------------------------------------------------------------
boot/bootutil/test/src/boot_test.h | 1 +
boot/bootutil/test/src/boot_test_utils.c | 23 ++++++++++++++++++-----
2 files changed, 19 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/70f72d24/boot/bootutil/test/src/boot_test.h
----------------------------------------------------------------------
diff --git a/boot/bootutil/test/src/boot_test.h b/boot/bootutil/test/src/boot_test.h
index b10bec6..072dfbb 100644
--- a/boot/bootutil/test/src/boot_test.h
+++ b/boot/bootutil/test/src/boot_test.h
@@ -59,6 +59,7 @@ extern struct boot_test_img_addrs boot_test_img_addrs[];
#define BOOT_TEST_AREA_IDX_SCRATCH 6
uint8_t boot_test_util_byte_at(int img_msb, uint32_t image_offset);
+uint8_t boot_test_util_flash_align(void);
void boot_test_util_init_flash(void);
void boot_test_util_copy_area(int from_area_idx, int to_area_idx);
void boot_test_util_swap_areas(int area_idx1, int area_idx2);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/70f72d24/boot/bootutil/test/src/boot_test_utils.c
----------------------------------------------------------------------
diff --git a/boot/bootutil/test/src/boot_test_utils.c b/boot/bootutil/test/src/boot_test_utils.c
index d882101..dc6fbb0 100644
--- a/boot/bootutil/test/src/boot_test_utils.c
+++ b/boot/bootutil/test/src/boot_test_utils.c
@@ -56,6 +56,17 @@ boot_test_util_byte_at(int img_msb, uint32_t image_offset)
return u8p[image_offset % 4];
}
+uint8_t
+boot_test_util_flash_align(void)
+{
+ const struct flash_area *fap;
+ int rc;
+
+ rc = flash_area_open(FLASH_AREA_IMAGE_0, &fap);
+ TEST_ASSERT_FATAL(rc == 0);
+
+ return flash_area_align(fap);
+}
void
boot_test_util_init_flash(void)
@@ -113,6 +124,7 @@ boot_test_util_area_write_size(int dst_idx, uint32_t off, uint32_t size)
const struct flash_area *desc;
int64_t diff;
uint32_t trailer_start;
+ uint8_t elem_sz;
if (dst_idx != BOOT_TEST_AREA_IDX_SCRATCH - 1) {
return size;
@@ -120,7 +132,8 @@ boot_test_util_area_write_size(int dst_idx, uint32_t off, uint32_t size)
/* Don't include trailer in copy to second slot. */
desc = boot_test_area_descs + dst_idx;
- trailer_start = desc->fa_size - boot_trailer_sz(1);
+ elem_sz = boot_test_util_flash_align();
+ trailer_start = desc->fa_size - boot_trailer_sz(elem_sz);
diff = off + size - trailer_start;
if (diff > 0) {
if (diff > size) {
@@ -255,10 +268,10 @@ boot_test_util_write_hash(const struct image_header *hdr, int slot)
tlv._pad = 0;
tlv.it_len = sizeof(hash);
- rc = hal_flash_write(flash_id, addr + off, &tlv, sizeof(tlv));
- TEST_ASSERT(rc == 0);
- off += sizeof(tlv);
- rc = hal_flash_write(flash_id, addr + off, hash, sizeof(hash));
+ memcpy(tmpdata, &tlv, sizeof tlv);
+ memcpy(tmpdata + sizeof tlv, hash, sizeof hash);
+ rc = hal_flash_write(flash_id, addr + off, tmpdata,
+ sizeof tlv + sizeof hash);
TEST_ASSERT(rc == 0);
}