summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-04-15 15:17:44 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-04-15 15:17:44 +0000
commitc25722804890aad8f6bbe66fc296e36fbd7c0f65 (patch)
treea38fef792b13ac9ee4f667b06d745ccba7af7c3f /src
parent0bc7d2c692d1236b45423e30cb6da1aac4f2aa4d (diff)
downloadopenocd+libswd-c25722804890aad8f6bbe66fc296e36fbd7c0f65.tar.gz
openocd+libswd-c25722804890aad8f6bbe66fc296e36fbd7c0f65.tar.bz2
openocd+libswd-c25722804890aad8f6bbe66fc296e36fbd7c0f65.tar.xz
openocd+libswd-c25722804890aad8f6bbe66fc296e36fbd7c0f65.zip
Nico Coesel <ncoesel@dealogic.nl> Chip width / bus width bug in cfi driver
git-svn-id: svn://svn.berlios.de/openocd/trunk@1459 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src')
-rw-r--r--src/flash/cfi.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/flash/cfi.c b/src/flash/cfi.c
index be5bfb7d..deb9cfe0 100644
--- a/src/flash/cfi.c
+++ b/src/flash/cfi.c
@@ -1589,7 +1589,7 @@ int cfi_intel_write_words(struct flash_bank_s *bank, u8 *word, u32 wordcount, u3
u8 command[8];
/* Calculate buffer size and boundary mask */
- u32 buffersize = 1UL << cfi_info->max_buf_write_size;
+ u32 buffersize = (1UL << cfi_info->max_buf_write_size) * (bank->bus_width / bank->chip_width);
u32 buffermask = buffersize-1;
u32 bufferwsize;
@@ -1609,6 +1609,9 @@ int cfi_intel_write_words(struct flash_bank_s *bank, u8 *word, u32 wordcount, u3
return ERROR_FLASH_OPERATION_FAILED;
}
+ bufferwsize/=(bank->bus_width / bank->chip_width);
+
+
/* Check for valid size */
if (wordcount > bufferwsize)
{
@@ -1725,7 +1728,7 @@ int cfi_spansion_write_words(struct flash_bank_s *bank, u8 *word, u32 wordcount,
cfi_spansion_pri_ext_t *pri_ext = cfi_info->pri_ext;
/* Calculate buffer size and boundary mask */
- u32 buffersize = 1UL << cfi_info->max_buf_write_size;
+ u32 buffersize = (1UL << cfi_info->max_buf_write_size) * (bank->bus_width / bank->chip_width);
u32 buffermask = buffersize-1;
u32 bufferwsize;
@@ -1745,6 +1748,8 @@ int cfi_spansion_write_words(struct flash_bank_s *bank, u8 *word, u32 wordcount,
return ERROR_FLASH_OPERATION_FAILED;
}
+ bufferwsize/=(bank->bus_width / bank->chip_width);
+
/* Check for valid size */
if (wordcount > bufferwsize)
{
@@ -1946,7 +1951,8 @@ int cfi_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
{
if (retval == ERROR_TARGET_RESOURCE_NOT_AVAILABLE)
{
- u32 buffersize = 1UL << cfi_info->max_buf_write_size;
+ //adjust buffersize for chip width
+ u32 buffersize = (1UL << cfi_info->max_buf_write_size) * (bank->bus_width / bank->chip_width);
u32 buffermask = buffersize-1;
u32 bufferwsize;
@@ -1959,6 +1965,8 @@ int cfi_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
LOG_ERROR("Unsupported chip width %d", bank->chip_width);
return ERROR_FLASH_OPERATION_FAILED;
}
+
+ bufferwsize/=(bank->bus_width / bank->chip_width);
/* fall back to memory writes */
while (count >= bank->bus_width)