X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fflash%2Fnor%2Fstm32lx.c;h=29a7aac9fc91abf73472c35000348c8ee861c040;hb=afe95871c59f05d532529af84e1ee80e3845e923;hp=8a6ad7bcb3a04e8120401c7a87ae7d1dd8d10d42;hpb=5f83378a9ca788e8a27e298b9e2b8969c944988b;p=fw%2Fopenocd diff --git a/src/flash/nor/stm32lx.c b/src/flash/nor/stm32lx.c index 8a6ad7bcb..29a7aac9f 100644 --- a/src/flash/nor/stm32lx.c +++ b/src/flash/nor/stm32lx.c @@ -464,17 +464,12 @@ static int stm32lx_write(struct flash_bank *bank, uint8_t *buffer, if (bytes_remaining) { - uint32_t value = 0; - for (int i = 0; i < 4; i++) - { - if (bytes_remaining) - { - value += (buffer[i] << (8 * i)); - bytes_remaining--; - } - } + uint8_t last_word[4] = {0xff, 0xff, 0xff, 0xff}; - retval = target_write_u32(target, address, value); + /* copy the last remaining bytes into the write buffer */ + memcpy(last_word, buffer+bytes_written, bytes_remaining); + + retval = target_write_buffer(target, address, 4, last_word); if (retval != ERROR_OK) return retval;