4 # (C) 2009 Travis Goodspeed <travis at radiantmachines.com>
5 # (C) 2011 Dave Huseby <dave at linuxprogrammer.org>
7 # This code is being rewritten and refactored. You've been warned!
12 from GoodFETJTAG import GoodFETJTAG
13 from intelhex import IntelHex
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]
24 #Initailize FET and set baud rate
25 client = GoodFETJTAG()
32 if sys.argv[1] == "reset":
35 elif sys.argv[1] == "chain":
36 length = client.detect_chain_length()
37 print "\tChain length: %d" % length
39 elif sys.argv[1] == "chipid":
41 print "missing argument"
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())
47 elif sys.argv[1] == "ir":
48 width = client.detect_ir_width()
49 print "\tIR width: %d" % width
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())