diff --git a/drivers/jtaglib.c b/drivers/jtaglib.c index 606bef8..7a6ec30 100644 --- a/drivers/jtaglib.c +++ b/drivers/jtaglib.c @@ -655,7 +655,8 @@ static int read_words(device_t dev_base, const struct chipinfo_memory *m, struct jtdev *p = (struct jtdev*)dev_base; dbg_printc("read_words: ram: len=%d addr=%06x\n", len, addr); - if (len > 2 && !(len & 1)) { + /* USB ram cannot be accssed using the 'quick' routines */ + if (len > 2 && !(len & 1) && !!strcmp(m->name, "UsbRam")) { uint16_t* word = malloc((len>>1) * sizeof(*word)); if (!word) { pr_error("jtaglib: read_words: failed to allocate memory"); @@ -669,14 +670,12 @@ static int read_words(device_t dev_base, const struct chipinfo_memory *m, data[2*i+1] = word[i] >> 8; } free(word); - - return p->failed ? -1 : len; - } - - for (unsigned int index = 0; index < len; index += 2) { - unsigned int word = jtag_read_mem(p, 16, addr+index); - data[index ] = word & 0x00ff; - data[index+1] = (word >> 8) & 0x00ff; + } else { + for (unsigned int index = 0; index < len; index += 2) { + unsigned int word = jtag_read_mem(p, 16, addr+index); + data[index ] = word & 0x00ff; + data[index+1] = (word >> 8) & 0x00ff; + } } return p->failed ? -1 : len; @@ -688,7 +687,8 @@ static int write_words(device_t dev_base, const struct chipinfo_memory *m, if (m->type != CHIPINFO_MEMTYPE_FLASH) { dbg_printc("write_words: ram: len=%d addr=%06x\n", len, addr); - if ((len > 2) && !(len & 1)) { + /* USB ram cannot be accssed using the 'quick' routines */ + if ((len > 2) && !(len & 1) && !!strcmp(m->name, "UsbRam")) { uint16_t* word = malloc((len>>1) * sizeof(*word)); if (!word) { pr_error("jtaglib: write_words: failed to allocate memory");