bootutil: Fix issue with align > 1
Some flash devices not only require writes to occur on an `align` byte
boundary, but also require that the writes be done in chunks of this
size as well. Enhance the sections that write status bytes to write
more than a single status byte.
diff --git a/boot/bootutil/src/loader.c b/boot/bootutil/src/loader.c
index 20a34b8..3aadd82 100644
--- a/boot/bootutil/src/loader.c
+++ b/boot/bootutil/src/loader.c
@@ -462,6 +462,8 @@
uint32_t off;
int area_id;
int rc;
+ uint8_t buf[8];
+ uint8_t align;
if (bs->idx == 0) {
/* Write to scratch. */
@@ -480,7 +482,12 @@
off = boot_status_off(fap) +
boot_status_internal_off(bs->idx, bs->state, boot_data.write_sz);
- rc = flash_area_write(fap, off, &bs->state, 1);
+ align = hal_flash_align(fap->fa_device_id);
+ // ASSERT(align <= 8);
+ memset(buf, 0xFF, 8);
+ buf[0] = bs->state;
+
+ rc = flash_area_write(fap, off, buf, align);
if (rc != 0) {
rc = BOOT_EFLASH;
goto done;