bootutil tests - Don't assume min-write-sz==1.
This commit is contained in:
parent
874510ea54
commit
3569c37894
|
@ -59,6 +59,7 @@ extern struct boot_test_img_addrs boot_test_img_addrs[];
|
||||||
#define BOOT_TEST_AREA_IDX_SCRATCH 6
|
#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_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_init_flash(void);
|
||||||
void boot_test_util_copy_area(int from_area_idx, int to_area_idx);
|
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);
|
void boot_test_util_swap_areas(int area_idx1, int area_idx2);
|
||||||
|
|
|
@ -56,6 +56,17 @@ boot_test_util_byte_at(int img_msb, uint32_t image_offset)
|
||||||
return u8p[image_offset % 4];
|
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
|
void
|
||||||
boot_test_util_init_flash(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;
|
const struct flash_area *desc;
|
||||||
int64_t diff;
|
int64_t diff;
|
||||||
uint32_t trailer_start;
|
uint32_t trailer_start;
|
||||||
|
uint8_t elem_sz;
|
||||||
|
|
||||||
if (dst_idx != BOOT_TEST_AREA_IDX_SCRATCH - 1) {
|
if (dst_idx != BOOT_TEST_AREA_IDX_SCRATCH - 1) {
|
||||||
return size;
|
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. */
|
/* Don't include trailer in copy to second slot. */
|
||||||
desc = boot_test_area_descs + dst_idx;
|
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;
|
diff = off + size - trailer_start;
|
||||||
if (diff > 0) {
|
if (diff > 0) {
|
||||||
if (diff > size) {
|
if (diff > size) {
|
||||||
|
@ -255,10 +268,10 @@ boot_test_util_write_hash(const struct image_header *hdr, int slot)
|
||||||
tlv._pad = 0;
|
tlv._pad = 0;
|
||||||
tlv.it_len = sizeof(hash);
|
tlv.it_len = sizeof(hash);
|
||||||
|
|
||||||
rc = hal_flash_write(flash_id, addr + off, &tlv, sizeof(tlv));
|
memcpy(tmpdata, &tlv, sizeof tlv);
|
||||||
TEST_ASSERT(rc == 0);
|
memcpy(tmpdata + sizeof tlv, hash, sizeof hash);
|
||||||
off += sizeof(tlv);
|
rc = hal_flash_write(flash_id, addr + off, tmpdata,
|
||||||
rc = hal_flash_write(flash_id, addr + off, hash, sizeof(hash));
|
sizeof tlv + sizeof hash);
|
||||||
TEST_ASSERT(rc == 0);
|
TEST_ASSERT(rc == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue