jtaglib: properly handle USB ram (cannot use quick memory access routines here)
This commit is contained in:
parent
c801faeb80
commit
cf8b986772
|
@ -655,7 +655,8 @@ static int read_words(device_t dev_base, const struct chipinfo_memory *m,
|
||||||
struct jtdev *p = (struct jtdev*)dev_base;
|
struct jtdev *p = (struct jtdev*)dev_base;
|
||||||
|
|
||||||
dbg_printc("read_words: ram: len=%d addr=%06x\n", len, addr);
|
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));
|
uint16_t* word = malloc((len>>1) * sizeof(*word));
|
||||||
if (!word) {
|
if (!word) {
|
||||||
pr_error("jtaglib: read_words: failed to allocate memory");
|
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;
|
data[2*i+1] = word[i] >> 8;
|
||||||
}
|
}
|
||||||
free(word);
|
free(word);
|
||||||
|
} else {
|
||||||
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;
|
||||||
for (unsigned int index = 0; index < len; index += 2) {
|
data[index+1] = (word >> 8) & 0x00ff;
|
||||||
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;
|
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) {
|
if (m->type != CHIPINFO_MEMTYPE_FLASH) {
|
||||||
dbg_printc("write_words: ram: len=%d addr=%06x\n", len, addr);
|
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));
|
uint16_t* word = malloc((len>>1) * sizeof(*word));
|
||||||
if (!word) {
|
if (!word) {
|
||||||
pr_error("jtaglib: write_words: failed to allocate memory");
|
pr_error("jtaglib: write_words: failed to allocate memory");
|
||||||
|
|
Loading…
Reference in New Issue