jjtag is a framework for interfacing and managing
Joint Test Action Group (JTAG) IEEE-1149.1 controllers in Java.
jjtag development is hosted at the jjtag Java.net site.
Check the
files area for
precompiled downloads and the
CVS repository for the latest sources.
You may also browse the documentation.
A jjtag manual is on the works.
Usage examples
Using Scan to create boundary scan chains
The basic idea here is that you derive from Scan
providing the ranges(), fields()
and length() methods, and then the base class does all the work packing and
unpacking 'Bits' objects bitstreams automagically (well... actually
using Java reflection).
Example:
public class Scan1 extends Scan {
public static final int[] _ranges = {
31<<16 | 0,
32
};
public static final int
_length = 33,
_D = 0,
_BREAKPT = 1;
public static final String _fields[] = {
"D",
"BREAKPT",
};
public int D;
public int BREAKPT;
public int[] ranges() { return _ranges; }
public String[] fields() { return _fields; }
public int length() { return _length; }
public Scan1() { super(); }
public Scan1(int bp, int d) {
super();
BREAKPT = bp; D = d;
}
public Scan1(Bits b) { super(b); }
public Scan1(String s) { super(s); }
public static Bits asBits(int bp, int d) {
return (new Scan1(bp, d)).toBits();
}
public static String asString(int bp, int d) {
return (new Scan1(bp, d)).toString();
}
}
Using a JTAGWiggler to speak to an ARM7TDMI core
A more real-life example on how to use JTAGControllers.
If you want to use the JTAGWiggler interface in Windows,
you will need to install the GiveIO driver.
import static jjtag.JTAGTAP.*;
import jjtag.JTAGController;
import jjtag.Bits;
import jjtag.JTAGWiggler;
public class ARMICE {
// Instruction register size
public static final int IR_SIZE = 4;
// Instruction register values
public static final String
EXTEST = "0000", // External test
SCAN_N = "0010", // Select scan chain
SAMPLE_PRELOAD = "0011",
RESTART = "0100", // Restart core
CLAMP = "0101", // Clamp pins
HIGHZ = "0111", // HiZ pins
CLAMPZ = "1001", // Clamp, HiZ pins
INTEST = "1100", // Internal test
IDCODE = "1110", // Read ID code
BYPASS = "1111"; // Bypass core
// Scan chains
public static final String
SCAN0 = "0000", // Macrocell scan test
SCAN1 = "0001", // Debug
SCAN2 = "0010", // EmbeddedICE-RT registers
SCAN3 = "0011"; // External boundary-scan
/** JTAG controller */
JTAGController controller;
/** Constructor - we provide an
implementation-independent controller
*/
public ARMICE(JTAGController c) {
controller = c;
}
/* Some helper functions */
String shift(byte ir, String dr) {
controller.jump(ir);
return controller.tdi(dr);
}
String shiftIR(String b) {
return shift(SHIFT_IR, b);
}
String shiftDR(String b) {
return shift(SHIFT_DR, b);
}
void selectScan(String s) {
shiftIR(SCAN_N);
shiftDR(s);
shiftIR(INTEST);
controller.jump(RUN_TEST_IDLE);
}
String idcode() {
System.err.println(
"In " + description[controller.state]
+ ", TMS shift_ir"
);
controller.jump(SHIFT_IR);
System.err.println(
"In " + description[controller.state]
+ ", TDI idcode"
);
controller.tdi(IDCODE);
System.err.println(
"In " + description[controller.state]
+ ", TMS shift_dr"
);
controller.jump(SHIFT_DR);
System.err.println(
"In " + description[controller.state]
+ ", TDO idcode"
);
return controller.tdi(new Bits(0, 32)).toString();
}
public static void main(String[] args) throws Exception {
ARMICE ai = new ARMICE(new JTAGWiggler(0x378));
// reset the controller, set idle signal values
ai.controller.initialize();
// soft-reset the TAP, just in case
ai.controller.reset();
String
c = ai.idcode(),
ch = Integer.toHexString((int)Long.parseLong(c, 2));
System.out.println("IDCODE: " + c + ", " + ch);
System.out.println(
"Controller is in state: "
+ description[ai.controller.state]
);
}
}
|
|