Skip to content

Commit 87ef2c3

Browse files
bootloader: use aligned write
1 parent 6865fcb commit 87ef2c3

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

bootloader/src/bootloader.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,14 @@ static void file_read_response_handler(size_t msg_size, const void* buf, void* c
202202
erase_app_page(i);
203203
}
204204
}
205-
struct flash_write_buf_s buf = {res->data_len, (void*)res->data};
206-
flash_write((void*)get_app_address_from_ofs(flash_state.ofs), 1, &buf);
207205

208206
if (res->data_len < 256) {
207+
struct flash_write_buf_s buf = {((res->data_len/FLASH_WORD_SIZE) + 1) * FLASH_WORD_SIZE, (void*)res->data};
208+
flash_write((void*)get_app_address_from_ofs(flash_state.ofs), 1, &buf);
209209
on_update_complete();
210210
} else {
211+
struct flash_write_buf_s buf = {res->data_len, (void*)res->data};
212+
flash_write((void*)get_app_address_from_ofs(flash_state.ofs), 1, &buf);
211213
flash_state.ofs += res->data_len;
212214
do_send_read_request();
213215
}

0 commit comments

Comments
 (0)