Telos B port is now working, and the CC2420 driver is coming together.
[goodfet] / client / GoodFETXSCALE.py
1 #!/usr/bin/env python
2 # GoodFET XScale JTAG Client
3
4 import sys, binascii, struct
5
6 # Standard verbs
7 READ  = 0x00
8 WRITE = 0x01
9 PEEK  = 0x02
10 POKE  = 0x03
11 SETUP = 0x10
12 START = 0x20
13 STOP  = 0x21
14 CALL  = 0x30
15 EXEC  = 0x31
16 NOK   = 0x7E
17 OK    = 0x7F
18
19 # XSCALE JTAG verbs
20 GET_CHIP_ID         = 0xF1
21
22 from GoodFETJTAG import GoodFETJTAG
23 from intelhex import IntelHex
24
25 class GoodFETXSCALE(GoodFETJTAG):
26
27     """A GoodFET variant for use with XScale processors."""
28
29     XSCALEAPP=0x15;
30     APP=XSCALEAPP;
31  
32     def setup(self):
33         """Move the FET into the JTAG ARM application."""
34         print "Initializing XScale..."
35         self.writecmd(self.APP, SETUP, 0, self.data)
36
37     def start(self):
38         """Start debugging."""
39         print "Staring debug..."
40         self.writecmd(self.APP, START, 0, self.data)
41
42     def stop(self):
43         """Stop debugging."""
44         print "Stopping debug..."
45         self.writecmd(self.APP, STOP, 0, self.data)
46
47     def get_id(self):
48         """Get the Chip ID."""
49         
50         # send the get chip ID command
51         self.writecmd(self.APP, GET_CHIP_ID, 0, [])
52
53         # get the response
54         ident = struct.unpack("<L", "".join(self.data[0:4]))[0]
55
56         version = ident >> 28
57         part_number = (ident >> 12) & 0x10
58         manufacturer = ident & 0xFFF
59
60         print "XScale ID --\n\tmfg: %x\n\tpart: %x\n\tver: %x\n\t(%x)" % (version, part_number, manufacturer, ident)
61
62         return ident
63     
64