goodfet.mcpcan's sniff verb now supports setting a data rate.
[goodfet] / client / goodfet.jtag
1 #!/usr/bin/env python
2 # GoodFET Basic JTAG
3
4 # (C) 2009 Travis Goodspeed <travis at radiantmachines.com>
5 # (C) 2011 Dave Huseby <dave at linuxprogrammer.org>
6 #
7 # This code is being rewritten and refactored.  You've been warned!
8
9 import sys;
10 import binascii;
11
12 from GoodFETJTAG import GoodFETJTAG
13 from intelhex import IntelHex
14
15 if len(sys.argv) == 1:
16     print "Usage: %s verb [objects]\n" % sys.argv[0]
17     print "%s reset -- resets the target device" % sys.argv[0]
18     print "%s chain -- detects JTAG chain length" % sys.argv[0]
19     print "%s chipid <chip #> -- gets the chip ID of the chip specified" % sys.argv[0]
20     print "%s ir -- detects the total bits in the IR register" % sys.argv[0]
21     print "%s detect -- detects chain length and gets chip IDs" % sys.argv[0]
22     sys.exit();
23
24 #Initailize FET and set baud rate
25 client = GoodFETJTAG()
26 client.serInit()
27
28 #Connect to target
29 client.setup()
30
31
32 if sys.argv[1] == "reset":
33     client.reset_target()
34
35 elif sys.argv[1] == "chain":
36     length = client.detect_chain_length()
37     print "\tChain length: %d" % length
38
39 elif sys.argv[1] == "chipid":
40     if len(sys.argv) < 3:
41         print "missing argument"
42         sys.exit()
43     idx = int(sys.argv[2])
44     id = client.get_device_id(idx)
45     print "\tDevice %d ID: 0x%s" % (idx, hex(id)[2:].zfill(8).upper())
46
47 elif sys.argv[1] == "ir":
48     width = client.detect_ir_width()
49     print "\tIR width: %d" % width
50
51 elif sys.argv[1] == "detect":
52     length = client.detect_chain_length()
53     print "\tChain length: %d" % length
54     for i in range(0, length):
55         id = client.get_device_id(i)
56         print "\tDevice %d ID: 0x%s" % (i, hex(id)[2:].zfill(8).upper())
57