Index: src/flash/cfi.c =================================================================== --- src/flash/cfi.c (révision 668) +++ src/flash/cfi.c (copie de travail) @@ -133,6 +133,14 @@ /* inline u32 flash_address(flash_bank_t *bank, int sector, u32 offset) */ __inline__ u32 flash_address(flash_bank_t *bank, int sector, u32 offset) { + if(bank->chip_width == 1) + { + if(offset == 0x2aa) + offset = 0x555; + else + offset *= 2; + } + /* while the sector list isn't built, only accesses to sector 0 work */ if (sector == 0) return bank->base + offset * bank->bus_width; @@ -222,29 +230,41 @@ u16 cfi_query_u16(flash_bank_t *bank, int sector, u32 offset) { + int bus_width; target_t *target = bank->target; u8 data[CFI_MAX_BUS_WIDTH * 2]; - target->type->read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 2, data); + if(bank->bus_width ==1) + bus_width = 2; + else + bus_width = bank->bus_width; + target->type->read_memory(target, flash_address(bank, sector, offset), bus_width, 2, data); + if (bank->target->endianness == TARGET_LITTLE_ENDIAN) - return data[0] | data[bank->bus_width] << 8; + return data[0] | data[bus_width] << 8; else - return data[bank->bus_width - 1] | data[(2 * bank->bus_width) - 1] << 8; + return data[bus_width - 1] | data[(2 * bus_width) - 1] << 8; } u32 cfi_query_u32(flash_bank_t *bank, int sector, u32 offset) { + int bus_width; target_t *target = bank->target; u8 data[CFI_MAX_BUS_WIDTH * 4]; - target->type->read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 4, data); + if(bank->bus_width ==1) + bus_width = 2; + else + bus_width = bank->bus_width; + target->type->read_memory(target, flash_address(bank, sector, offset), 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; + return data[0] | data[bus_width] << 8 | data[bus_width * 2] << 16 | data[bus_width * 3] << 24; else - return data[bank->bus_width - 1] | data[(2* bank->bus_width) - 1] << 8 | - data[(3 * bank->bus_width) - 1] << 16 | data[(4 * bank->bus_width) - 1] << 24; + return data[bus_width - 1] | data[(2* bus_width) - 1] << 8 | + data[(3 * bus_width) - 1] << 16 | data[(4 * bus_width) - 1] << 24; } void cfi_intel_clear_status_register(flash_bank_t *bank) @@ -1895,7 +1915,7 @@ { u8 manufacturer, device_id; target_read_u8(target, bank->base + 0x0, &manufacturer); - target_read_u8(target, bank->base + 0x1, &device_id); + target_read_u8(target, bank->base + 0x2, &device_id); cfi_info->manufacturer = manufacturer; cfi_info->device_id = device_id; }