jtag_scan: Reworked and cleaned up how scan works when irlens is specified

This commit is contained in:
dragonmux 2022-07-27 10:27:04 +01:00 committed by Piotr Esden-Tempski
parent b258730499
commit 9f35763199
1 changed files with 14 additions and 12 deletions

View File

@ -92,24 +92,26 @@ int jtag_scan(const uint8_t *irlens)
DEBUG_WARN("Given list of IR lengths, skipping probe\n"); DEBUG_WARN("Given list of IR lengths, skipping probe\n");
DEBUG_INFO("Change state to Shift-IR\n"); DEBUG_INFO("Change state to Shift-IR\n");
jtagtap_shift_ir(); jtagtap_shift_ir();
j = 0;
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 = 0; device <= JTAG_MAX_DEVS && jtag_devs[device].ir_len <= JTAG_MAX_IR_LEN;
uint32_t irout; ++device) {
if(*irlens == 0) if (irlens[device] == 0)
break; break;
jtag_proc.jtagtap_tdi_tdo_seq((uint8_t*)&irout, 0, ones, *irlens);
uint32_t irout = 0;
jtag_proc.jtagtap_tdi_tdo_seq((uint8_t*)&irout, 0, ones, irlens[device]);
/* 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 (!(irout & 1)) if (!(irout & 1))
DEBUG_WARN("check failed: IR[0] != 1\n"); DEBUG_WARN("check failed: IR[0] != 1\n");
jtag_devs[jtag_dev_count].ir_len = *irlens; jtag_devs[device].ir_len = irlens[device];
jtag_devs[jtag_dev_count].ir_prescan = j; jtag_devs[device].ir_prescan = prescan;
jtag_devs[jtag_dev_count].jd_dev = jtag_dev_count; jtag_devs[device].jd_dev = device;
j += *irlens; prescan += irlens[device];
irlens++;
jtag_dev_count++;
} }
jtag_dev_count = device;
} else { } else {
DEBUG_INFO("Change state to Shift-IR\n"); DEBUG_INFO("Change state to Shift-IR\n");
jtagtap_shift_ir(); jtagtap_shift_ir();