On Tuesday 19 May 2009 12:54:31 Raúl Sánchez Siles wrote:
>   Hello:
>
>   This is my first try to implement the x16_as_x8 flash bank option. It is
> working for me as I would expect flash to work, but please consider this
> patchset as work in progress since it may still has some flaws.
>
>   Al patches touch just src/flash/cfi.c file and should apply in this order
> to trunk.
>
>   The patchset consists of 4 patches, whose interest areas I
> explain and comment below:
>

> 04-x16_as_x8-multibyte_read
>   · cfi_query_u16 and cfi_query_u32 function uses multibyte accesses, this
> is 2 or 4 byte read. This will fail in the x16_as_x8 case since this would
> lead reading, e.g.: addresses 0x0 and 0x1 instead of 0x0 and 0x2 in the
> 16bit case. Do a byte by byte read in the x16_as_x8 case.

-- 
Raúl Sánchez Siles

Departamento de Montaje

INFOGLOBAL, S. A.

* C/ Virgilio, 2. Ciudad de la Imagen.
28223 Pozuelo de Alarcón (Madrid), España
* T: +34 91 506 40 00
* F: +34 91 506 40 01


--- a/src/flash/cfi.c
+++ b/src/flash/cfi.c
@@ -222,9 +242,18 @@
 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, command_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;
@@ -235,9 +264,18 @@
 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, command_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;
_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to