Skip to content


Added support for enumerating TAPs that do not support the IDCODE ins…
Browse files Browse the repository at this point in the history
  • Loading branch information
azonenberg committed Jul 20, 2018
1 parent 3d48bb4 commit 1d75b77
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions JtagInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void JtagInterface::InitializeChain()
if(PeekBit(temp, m_irtotal))
//LogDebug("Found %zu total IR bits\n", m_irtotal);
LogTrace("Found %zu total IR bits\n", m_irtotal);

//Shift zeros into everyone's DR
Expand All @@ -258,32 +258,37 @@ void JtagInterface::InitializeChain()
//LogDebug("Found %d total devices\n", (int) m_devicecount);
LogTrace("Found %d total devices\n", (int) m_devicecount);

//Now we know how many devices we have! Reset the TAP

//Shift out the ID codes and reset the scan chain
//Shift out the ID codes and reset the scan chain.
for(size_t i=0; i<m_devicecount; i++)
unsigned int idcode;
ShiftData(false, lots_of_zeros, (unsigned char*)&idcode, 32);
ShiftData(false, lots_of_zeros, (unsigned char*)&m_idcodes[0], 32*m_devicecount);

//LogNotice("IDCODE = %08x\n", idcode);
//Crunch things
size_t idcode_bits = 0;
for(size_t i=0; i<m_devicecount; i++)
uint32_t idcode = 0;
for(size_t j=0; j<32; j++)
PokeBit((uint8_t*)&idcode, j, PeekBit((uint8_t*)&m_idcodes[0], idcode_bits+j));

//ID code should always begin with a one
//If we get a zero it's a bypass register
//TODO: Support devices not implementing IDCODE
//Skip chips with bad IDCODEs
if(!(idcode & 0x1))
LogError("Invalid IDCODE %08x at index %zu.\n", idcode, i);
throw JtagExceptionWrapper(
"Devices without IDCODE are not supported.",
LogWarning("Invalid IDCODE %08x at index %zu, ignoring...\n", idcode, i);
idcode_bits ++;

idcode_bits += 32;
m_idcodes[i] = idcode;


//Crack ID codes
Expand Down

0 comments on commit 1d75b77

Please sign in to comment.