summaryrefslogtreecommitdiff
path: root/src/flash
diff options
context:
space:
mode:
authorkc8apf <kc8apf@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-05-22 17:49:28 +0000
committerkc8apf <kc8apf@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-05-22 17:49:28 +0000
commitaaa6dd927fce6ffe081046347280665ebc1f5782 (patch)
treecbbaceb9421051b1aed1976dbe7895ad309003e2 /src/flash
parentc48ad46aa37a3ababe605f0d284aff830abed67d (diff)
downloadopenocd_libswd-aaa6dd927fce6ffe081046347280665ebc1f5782.tar.gz
openocd_libswd-aaa6dd927fce6ffe081046347280665ebc1f5782.tar.bz2
openocd_libswd-aaa6dd927fce6ffe081046347280665ebc1f5782.tar.xz
openocd_libswd-aaa6dd927fce6ffe081046347280665ebc1f5782.zip
Author: Raúl Sánchez Siles <rsanchezs@infoglobal.es>
- Fix multi-byte reads on x16 devices used as x8 git-svn-id: svn://svn.berlios.de/openocd/trunk@1886 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/flash')
-rw-r--r--src/flash/cfi.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/flash/cfi.c b/src/flash/cfi.c
index 7ae58f10..dca9bef5 100644
--- a/src/flash/cfi.c
+++ b/src/flash/cfi.c
@@ -204,9 +204,18 @@ static u8 cfi_get_u8(flash_bank_t *bank, int sector, u32 offset)
static u16 cfi_query_u16(flash_bank_t *bank, int sector, u32 offset)
{
target_t *target = bank->target;
+ cfi_flash_bank_t *cfi_info = bank->driver_priv;
u8 data[CFI_MAX_BUS_WIDTH * 2];
- target->type->read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 2, data);
+ if(cfi_info->x16_as_x8)
+ {
+ u8 i;
+ for(i=0;i<2;i++)
+ target->type->read_memory(target, flash_address(bank, sector, offset+i), bank->bus_width, 1,
+ &data[i*bank->bus_width] );
+ }
+ else
+ target->type->read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 2, data);
if (bank->target->endianness == TARGET_LITTLE_ENDIAN)
return data[0] | data[bank->bus_width] << 8;
@@ -217,9 +226,18 @@ static u16 cfi_query_u16(flash_bank_t *bank, int sector, u32 offset)
static u32 cfi_query_u32(flash_bank_t *bank, int sector, u32 offset)
{
target_t *target = bank->target;
+ cfi_flash_bank_t *cfi_info = bank->driver_priv;
u8 data[CFI_MAX_BUS_WIDTH * 4];
- target->type->read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 4, data);
+ if(cfi_info->x16_as_x8)
+ {
+ u8 i;
+ for(i=0;i<4;i++)
+ target->type->read_memory(target, flash_address(bank, sector, offset+i), bank->bus_width, 1,
+ &data[i*bank->bus_width] );
+ }
+ else
+ target->type->read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 4, data);
if (bank->target->endianness == TARGET_LITTLE_ENDIAN)
return data[0] | data[bank->bus_width] << 8 | data[bank->bus_width * 2] << 16 | data[bank->bus_width * 3] << 24;