Please check whether your JTAG interface hardware design is similar as the following

If the test fails to measure the length of the instruction register, then an error, Error measuring IR length, is thrown.
The error might be due to one or more of the following reasons:
• TRST stuck low: This may hold the target JTAG logic in reset, preventing any shifts to occur.
• TMS disconnected or stuck: This may prevent the target from making any JTAG state changes.
• TCK disconnected or stuck: This may prevent any state changes or clocking of data.
• TDI disconnected or stuck: This may prevent the test pattern data from getting into the target.
• TDO disconnected or stuck: This may prevent the test pattern data from getting out of the target.
If the test fails, then it is possible that there is a physical connection problem with the JTAG pins, or the JTAG frequency is too high.