This is an automated email from Gerrit. Ake Rehnman ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/4264
-- gerrit commit 0467b0e3ada58fd69a5474f13fdee7334bca1ab6 Author: Ake Rehnman <[email protected]> Date: Tue Oct 24 19:34:47 2017 +0200 Bug in stm8_write_flash preventing flashing of small blocks Change-Id: I3e7ec4851f617ddf077ee3284c38c9b9aa81e7d7 Signed-off-by: Ake Rehnman <[email protected]> diff --git a/src/target/stm8.c b/src/target/stm8.c index 2eb0618..b8d2684 100644 --- a/src/target/stm8.c +++ b/src/target/stm8.c @@ -176,6 +176,7 @@ static int stm8_adapter_write_memory(struct target *target, int ret; struct hl_interface_s *adapter = target_to_adapter(target); + LOG_DEBUG("%s, addr=%6.6x size=%x count=%x", __func__, addr, size, count); ret = adapter->layout->api->write_mem(adapter->handle, addr, size, count, buf); if (ret != ERROR_OK) @@ -678,30 +679,21 @@ static int stm8_write_flash(struct target *target, int type, bytecnt = count*size; - if (blocksize_param == 0x80) - blocksize_param = 0x7f; - else if (blocksize_param == 0x40) - blocksize_param = 0x3f; - else - blocksize_param = 0; - while (bytecnt) { - if ((bytecnt >= 128) && blocksize_param - && ((address & blocksize_param) == 0)) { + if ((bytecnt >= blocksize_param) && ((address & (blocksize_param-1)) == 0)) { stm8_write_u8(target, FLASH_CR2, PRG + opt); stm8_write_u8(target, FLASH_NCR2, ~(PRG + opt)); - blocksize = 128; + blocksize = blocksize_param; } else if ((bytecnt >= 4) && ((address & 0x3) == 0)) { stm8_write_u8(target, FLASH_CR2, WPRG + opt); stm8_write_u8(target, FLASH_NCR2, ~(WPRG + opt)); blocksize = 4; - } else { - if (blocksize != 1) { - stm8_write_u8(target, FLASH_CR2, opt); - stm8_write_u8(target, FLASH_NCR2, ~opt); - blocksize = 1; - } + } else + if (blocksize != 1) { + stm8_write_u8(target, FLASH_CR2, opt); + stm8_write_u8(target, FLASH_NCR2, ~opt); + blocksize = 1; } res = stm8_adapter_write_memory(target, address, 1, blocksize, buffer); -- ------------------------------------------------------------------------------ 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
