This is an automated email from Gerrit. Angus Gratton (g...@projectgus.com) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/1965
-- gerrit commit afbf452ecbb05a5adff602594437da5765b70720 Author: Angus Gratton <g...@projectgus.com> Date: Wed Feb 12 22:32:47 2014 +1100 AT91SAM4L: Fix bug when writing to flash at a non-zero offset, add debug output for flash page writes The offset wasn't being considered in the "full page" write codepath, so any writes at an offset were actually written out starting from page 0. Change-Id: I5e70a1f35f144b3edd1ce6d9df9af9b5da6cf194 Signed-off-by: Angus Gratton <g...@projectgus.com> diff --git a/src/flash/nor/at91sam4l.c b/src/flash/nor/at91sam4l.c index d3bdbfe..2b4d76a 100644 --- a/src/flash/nor/at91sam4l.c +++ b/src/flash/nor/at91sam4l.c @@ -499,6 +499,8 @@ static int sam4l_write_page(struct sam4l_info *chip, struct target *target, { int res; + LOG_DEBUG("sam4l_write_page address=%08" PRIx32, address); + /* Clear the page buffer before we write to it */ res = sam4l_flash_command(target, SAM4L_FCMD_CPB, -1); if (res != ERROR_OK) { @@ -535,6 +537,8 @@ static int sam4l_write_page_partial(struct sam4l_info *chip, if (!pg) return ERROR_FAIL; + LOG_DEBUG("sam4l_write_page_partial address=%08" PRIx32 " nb=%08" PRIx32, address, nb); + assert(page_offset + nb < chip->page_size); assert((address % chip->page_size) == 0); @@ -563,6 +567,8 @@ static int sam4l_write(struct flash_bank *bank, uint8_t *buffer, uint32_t nb = 0; struct sam4l_info *chip = (struct sam4l_info *)bank->driver_priv; + LOG_DEBUG("sam4l_write offset=%08" PRIx32 " count=%08" PRIx32, offset, count); + if (bank->target->state != TARGET_HALTED) { LOG_ERROR("Target not halted"); @@ -605,14 +611,14 @@ static int sam4l_write(struct flash_bank *bank, uint8_t *buffer, for (int i = 0; i < np; i++) { if (count >= chip->page_size) { res = sam4l_write_page(chip, bank->target, - bank->base + (i * chip->page_size), + bank->base + offset, buffer + (i * chip->page_size)); /* Advance one page */ offset += chip->page_size; count -= chip->page_size; } else { res = sam4l_write_page_partial(chip, bank, - bank->base + (i * chip->page_size), + bank->base + offset, buffer + (i * chip->page_size), 0, count); /* We're done after this. */ offset += count; -- ------------------------------------------------------------------------------ Managing the Performance of Cloud-Based Applications Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. Read the Whitepaper. http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk _______________________________________________ OpenOCD-devel mailing list OpenOCD-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openocd-devel