jtag_scan: Reworked IR length and device count scanning when irlens is not given
This commit is contained in:
parent
9f35763199
commit
190c45b450
|
@ -118,26 +118,36 @@ int jtag_scan(const uint8_t *irlens)
|
||||||
|
|
||||||
DEBUG_INFO("Scanning out IRs\n");
|
DEBUG_INFO("Scanning out IRs\n");
|
||||||
/* IEEE 1149.1 requires the first bit to be a 1, but not all devices conform (see #1130 on GH) */
|
/* IEEE 1149.1 requires the first bit to be a 1, but not all devices conform (see #1130 on GH) */
|
||||||
if (!jtag_proc.jtagtap_next(0, 1))
|
if (!jtag_proc.jtagtap_next(false, true))
|
||||||
DEBUG_WARN("jtag_scan: Sanity check failed: IR[0] shifted out as 0\n");
|
DEBUG_WARN("jtag_scan: Sanity check failed: IR[0] shifted out as 0\n");
|
||||||
|
|
||||||
jtag_devs[0].ir_len = 1; j = 1;
|
jtag_devs[0].ir_len = 1;
|
||||||
while((jtag_dev_count <= JTAG_MAX_DEVS) &&
|
size_t device = 0;
|
||||||
(jtag_devs[jtag_dev_count].ir_len <= JTAG_MAX_IR_LEN)) {
|
for (size_t prescan = 1; device <= JTAG_MAX_DEVS && jtag_devs[device].ir_len <= JTAG_MAX_IR_LEN;) {
|
||||||
if(jtag_proc.jtagtap_next(0, 1)) {
|
/* If we read out a '1' from TDO, we're at the end of the current device and the start of the next */
|
||||||
if(jtag_devs[jtag_dev_count].ir_len == 1) break;
|
if (jtag_proc.jtagtap_next(false, true)) {
|
||||||
jtag_devs[++jtag_dev_count].ir_len = 1;
|
/* If the device was not actually a new device, exit */
|
||||||
jtag_devs[jtag_dev_count].ir_prescan = j;
|
if (jtag_devs[device].ir_len == 1)
|
||||||
jtag_devs[jtag_dev_count].jd_dev = jtag_dev_count;
|
break;
|
||||||
} else jtag_devs[jtag_dev_count].ir_len++;
|
++device;
|
||||||
j++;
|
/* Set up the next device */
|
||||||
|
jtag_devs[device].ir_len = 1;
|
||||||
|
jtag_devs[device].ir_prescan = prescan;
|
||||||
|
jtag_devs[device].jd_dev = device;
|
||||||
|
} else
|
||||||
|
/* Otherwise we have another bit in this device's IR */
|
||||||
|
++jtag_devs[device].ir_len;
|
||||||
|
++prescan;
|
||||||
}
|
}
|
||||||
if(jtag_dev_count > JTAG_MAX_DEVS) {
|
jtag_dev_count = device;
|
||||||
|
|
||||||
|
if (jtag_dev_count > JTAG_MAX_DEVS) {
|
||||||
DEBUG_WARN("jtag_scan: Maximum device count exceeded\n");
|
DEBUG_WARN("jtag_scan: Maximum device count exceeded\n");
|
||||||
jtag_dev_count = -1;
|
jtag_dev_count = -1;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(jtag_devs[jtag_dev_count].ir_len > JTAG_MAX_IR_LEN) {
|
|
||||||
|
if (jtag_devs[jtag_dev_count].ir_len > JTAG_MAX_IR_LEN) {
|
||||||
DEBUG_WARN("jtag_scan: Maximum IR length exceeded\n");
|
DEBUG_WARN("jtag_scan: Maximum IR length exceeded\n");
|
||||||
jtag_dev_count = -1;
|
jtag_dev_count = -1;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue