This is an automated email from Gerrit. Christopher Kilgour ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/738
-- gerrit commit 23eaf581fd401686756aca7e0c5cfcc54823ba8a Author: Christopher Kilgour <[email protected]> Date: Sat Jul 7 16:47:06 2012 -0700 kinetis: ensure flash writes are not truncated The number if longwords or "sections" (Freescale term) written for a Kinetis flash write (4, 8, or 16 bytes depending on the part density/granularity) are now rounded up to ensure there are no truncations when the desired write is not a multiple of the minimum write size. Change-Id: I8db40a8769d8ac5393a46cbf4e5ff0df82faf916 Signed-off-by: Christopher Kilgour <[email protected]> diff --git a/src/flash/nor/kinetis.c b/src/flash/nor/kinetis.c index cf36104..8bac13d 100644 --- a/src/flash/nor/kinetis.c +++ b/src/flash/nor/kinetis.c @@ -352,21 +352,23 @@ static int kinetis_write(struct flash_bank *bank, uint8_t *buffer, unsigned prog_section_bytes = kinfo->sector_size >> 8; for (i = 0; i < count; i += kinfo->sector_size) { uint8_t ftfx_fstat; + uint32_t section_count; wc = kinfo->sector_size / 4; + /* If remaining bytes are less than the full + sector, determine the number of full-words + to program */ if ((count - i) < kinfo->sector_size) { - wc = count - i; - wc /= 4; + wc = (count - i + 3) / 4; } LOG_DEBUG("write section @ %08X with length %d", offset + i, wc * 4); /* write data to flexram */ - result = - target_write_memory(bank->target, 0x14000000, 4, wc, - buffer + i); + result = target_write_memory(bank->target, 0x14000000, 4, wc, + buffer + i); if (result != ERROR_OK) { LOG_ERROR("target_write_memory failed"); @@ -375,8 +377,9 @@ static int kinetis_write(struct flash_bank *bank, uint8_t *buffer, } /* execute section command */ + section_count = ((wc * 4) + prog_section_bytes - 1) / prog_section_bytes; w0 = (0x0b << 24) | (bank->base + offset + i); - w1 = ((wc * 4 / prog_section_bytes) << 16); + w1 = section_count << 16; result = kinetis_ftfx_command(bank, w0, w1, w2, &ftfx_fstat); -- ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
