From: Uwe Bonnes Date: Tue, 17 Jan 2012 20:24:01 +0000 (+0100) Subject: In write_buffer_to_sram() write as much as possible with write_mem32 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=079148247ce01c8b2ca0f8622e3d754d1f0ed3f3;p=fw%2Fstlink In write_buffer_to_sram() write as much as possible with write_mem32 --- diff --git a/src/stlink-common.c b/src/stlink-common.c index 0c39112..97bc3e1 100644 --- a/src/stlink-common.c +++ b/src/stlink-common.c @@ -864,8 +864,16 @@ on_error: int write_buffer_to_sram(stlink_t *sl, flash_loader_t* fl, const uint8_t* buf, size_t size) { /* write the buffer right after the loader */ - memcpy(sl->q_buf, buf, size); - stlink_write_mem8(sl, fl->buf_addr, size); + size_t chunk = size & ~0x3; + size_t rem = size & 0x3; + if (chunk) { + memcpy(sl->q_buf, buf, chunk); + stlink_write_mem32(sl, fl->buf_addr, chunk); + } + if (rem) { + memcpy(sl->q_buf, buf+chunk, rem); + stlink_write_mem8(sl, (fl->buf_addr)+chunk, rem); + } return 0; }