This is an automated email from Gerrit. Christopher Head ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/4463
-- gerrit commit 97d09e15c355d4cf22f6e22bcb71d798f846c788 Author: Christopher Head <[email protected]> Date: Mon Mar 12 11:21:01 2018 -0700 flash/nor/stm32f2x: check CR/SR outside loop When writing to Flash without using an algorithm, writing the programming control bits to CR and reading the status from SR before and after every word takes a lot of time. However, it is not necessary: one can write to CR once before programming many words. The error bits in SR are cumulative and can be checked after a large chunk is written. The busy bit in SR is mostly redundant since subsequent bus accesses stall (resulting in a DAP WAIT) rather than failing. Therefore, just write CR once, bulk-write the memory, and then check SR at the end. Change-Id: I845961eeb6435a1ee9482750411946f3c5dfb60c Signed-off-by: Christopher Head <[email protected]> diff --git a/src/flash/nor/stm32f2x.c b/src/flash/nor/stm32f2x.c index b0992b4..5fdd7fe 100644 --- a/src/flash/nor/stm32f2x.c +++ b/src/flash/nor/stm32f2x.c @@ -760,16 +760,13 @@ static int stm32x_write(struct flash_bank *bank, const uint8_t *buffer, Double word access in case of x64 parallelism Wait for the BSY bit to be cleared */ - while (words_remaining > 0) { - uint16_t value; - memcpy(&value, buffer + bytes_written, sizeof(uint16_t)); - + if (words_remaining > 0) { retval = target_write_u32(target, stm32x_get_flash_reg(bank, STM32_FLASH_CR), FLASH_PG | FLASH_PSIZE_16); if (retval != ERROR_OK) return retval; - retval = target_write_u16(target, address, value); + retval = target_write_memory(target, address, 2, words_remaining, buffer); if (retval != ERROR_OK) return retval; @@ -777,9 +774,9 @@ static int stm32x_write(struct flash_bank *bank, const uint8_t *buffer, if (retval != ERROR_OK) return retval; - bytes_written += 2; - words_remaining--; - address += 2; + bytes_written += words_remaining * 2; + words_remaining = 0; + address += words_remaining * 2; } if (bytes_remaining) { -- ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
