Update JTAG chain detect
This commit is contained in:
parent
fc6f3fb8e1
commit
d3410e0e30
27
src/jtag.cpp
27
src/jtag.cpp
|
|
@ -151,7 +151,7 @@ Jtag::Jtag(const cable_t &cable, const jtag_pins_conf_t *pin_conf,
|
|||
throw std::runtime_error("Error: memory allocation failed");
|
||||
memset(_tms_buffer, 0, _tms_buffer_size);
|
||||
|
||||
detectChain(5);
|
||||
detectChain(32);
|
||||
}
|
||||
|
||||
Jtag::~Jtag()
|
||||
|
|
@ -159,13 +159,13 @@ Jtag::~Jtag()
|
|||
free(_tms_buffer);
|
||||
delete _jtag;
|
||||
}
|
||||
int Jtag::detectChain(int max_dev)
|
||||
int Jtag::detectChain(unsigned max_dev)
|
||||
{
|
||||
char message[256];
|
||||
unsigned char rx_buff[4];
|
||||
uint8_t rx_buff[4];
|
||||
/* WA for CH552/tangNano: write is always mandatory */
|
||||
unsigned char tx_buff[4] = {0xff, 0xff, 0xff, 0xff};
|
||||
unsigned int tmp;
|
||||
uint8_t tx_buff[4] = {0xff, 0xff, 0xff, 0xff};
|
||||
uint32_t tmp;
|
||||
|
||||
/* cleanup */
|
||||
_devices_list.clear();
|
||||
|
|
@ -177,10 +177,10 @@ int Jtag::detectChain(int max_dev)
|
|||
if (_verbose)
|
||||
printInfo("Raw IDCODE:");
|
||||
|
||||
for (int i = 0; i < max_dev; i++) {
|
||||
for (unsigned i = 0; i < max_dev; ++i) {
|
||||
read_write(tx_buff, rx_buff, 32, (i == max_dev-1)?1:0);
|
||||
tmp = 0;
|
||||
for (int ii=0; ii < 4; ii++)
|
||||
for (int ii = 0; ii < 4; ++ii)
|
||||
tmp |= (rx_buff[ii] << (8 * ii));
|
||||
|
||||
if (_verbose) {
|
||||
|
|
@ -188,12 +188,22 @@ int Jtag::detectChain(int max_dev)
|
|||
printInfo(message);
|
||||
}
|
||||
|
||||
if (tmp == 0) {
|
||||
throw std::runtime_error("TDO is stuck at 0");
|
||||
}
|
||||
if (tmp == 0xffffffff) {
|
||||
if (_verbose) {
|
||||
snprintf(message, sizeof(message), "Fetched TDI, end-of-chain");
|
||||
printInfo(message);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* search IDCODE in fpga_list and misc_dev_list
|
||||
* since most device have idcode with high nibble masked
|
||||
* we start to search sub IDCODE
|
||||
* if IDCODE has no match: try the same with version unmasked
|
||||
*/
|
||||
if (tmp != 0 && tmp != 0xffffffff) {
|
||||
bool found = false;
|
||||
/* ckeck highest nibble to prevent confusion between Cologne Chip
|
||||
* GateMate and Efinix Trion T4/T8 devices
|
||||
|
|
@ -219,7 +229,6 @@ int Jtag::detectChain(int max_dev)
|
|||
throw std::runtime_error(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
go_test_logic_reset();
|
||||
flushTMS(true);
|
||||
return _devices_list.size();
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class Jtag {
|
|||
* vector with irlength
|
||||
* \return number of devices found
|
||||
*/
|
||||
int detectChain(int max_dev);
|
||||
int detectChain(unsigned int max_dev);
|
||||
|
||||
/*!
|
||||
* \brief return list of devices in the chain
|
||||
|
|
|
|||
Loading…
Reference in New Issue