diff options
author | Spencer Oliver <spen@spen-soft.co.uk> | 2012-12-07 11:08:33 +0000 |
---|---|---|
committer | Andreas Fritiofson <andreas.fritiofson@gmail.com> | 2012-12-30 11:36:40 +0000 |
commit | 9b045f62f4bac2411a7662d8b312637347aac73d (patch) | |
tree | 29164266a425c0d79dc3df3f3d33d12c52e0ec92 | |
parent | 80649fc3d5ce5da7c29cc645109f72e012187c72 (diff) | |
download | riscv-openocd-9b045f62f4bac2411a7662d8b312637347aac73d.zip riscv-openocd-9b045f62f4bac2411a7662d8b312637347aac73d.tar.gz riscv-openocd-9b045f62f4bac2411a7662d8b312637347aac73d.tar.bz2 |
flash: stm32lx fallback to slow memory writes when no working area
The current stm32lx driver will fail if no working area is
provided - fallback to using slow writes if this is the case.
Change-Id: I92b1535fec4aebc855c63ce2c54b10f168f3c07e
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/1007
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
-rw-r--r-- | src/flash/nor/stm32lx.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/flash/nor/stm32lx.c b/src/flash/nor/stm32lx.c index 6d7efb8..ce41f94 100644 --- a/src/flash/nor/stm32lx.c +++ b/src/flash/nor/stm32lx.c @@ -399,10 +399,16 @@ static int stm32lx_write(struct flash_bank *bank, uint8_t *buffer, } if (halfpages_number) { - retval = stm32lx_write_half_pages(bank, buffer, offset, 128 - * halfpages_number); - if (retval != ERROR_OK) - return ERROR_FAIL; + retval = stm32lx_write_half_pages(bank, buffer, offset, 128 * halfpages_number); + if (retval == ERROR_TARGET_RESOURCE_NOT_AVAILABLE) { + /* attempt slow memory writes */ + LOG_WARNING("couldn't use block writes, falling back to single memory accesses"); + halfpages_number = 0; + words_remaining = (count / 4); + } else { + if (retval != ERROR_OK) + return ERROR_FAIL; + } } bytes_written = 128 * halfpages_number; |