Browse Source

kinetis: bugfix in kinetis_write() fallback path

Offset calculation into buffer was wrong and code would read outside buffer
if count was not a multiple of four.

Change-Id: Ied625b10221423d5a5f25d27ce1edd8c2c3eca8a
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/749
Reviewed-by: Peter Stuge <peter@stuge.se>
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
tags/v0.6.0-rc2
Andreas Fritiofson 12 years ago
committed by Freddie Chopin
parent
commit
73d87c6210
1 changed files with 7 additions and 1 deletions
  1. +7
    -1
      src/flash/nor/kinetis.c

+ 7
- 1
src/flash/nor/kinetis.c View File

@@ -435,7 +435,13 @@ static int kinetis_write(struct flash_bank *bank, uint8_t *buffer,
LOG_DEBUG("write longword @ %08X", offset + i);

w0 = (0x06 << 24) | (bank->base + offset + i);
w1 = buf_get_u32(buffer + offset + i, 0, 32);
if (count - i < 4) {
uint32_t padding = 0xffffffff;
memcpy(&padding, buffer + i, count - i);
w1 = buf_get_u32(&padding, 0, 32);
} else {
w1 = buf_get_u32(buffer + i, 0, 32);
}

result = kinetis_ftfx_command(bank, w0, w1, w2, &ftfx_fstat);



Loading…
Cancel
Save