wrote a method to try and fake the vin
[goodfet] / client / GoodFETARM9.py
1 #!/usr/bin/env python
2 # GoodFET ARM9 Client Library
3
4 # Contributions and bug reports welcome.
5 #
6 # todo:
7 #  * full cycle debugging.. halt to resume
8 #  * ensure correct PC handling
9 #  * flash manipulation (probably need to get the specific chip for this one)
10 #  * set security (chip-specific)
11
12 import sys, binascii, struct, time
13 import atlasutils.smartprint as asp
14 from GoodFET import GoodFET
15 from GoodFETARM7 import *
16 from intelhex import IntelHex
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 class GoodFETARM9(GoodFETARM7):
40     def start(self):
41         GoodFETARM7.start(self)
42         self.ARMsetSCANsize(5)
43
44     def ARMreadMem(self, adr, wordcount=0):
45         """ Only works in ARM mode currently
46         WARNING: Addresses must be word-aligned!
47         """
48         regs = self.ARMget_registers()
49         self.ARMset_registers([0xdeadbeef for x in xrange(14)], 0xe)
50         output = []
51         count = wordcount
52         while (wordcount > 0):
53             count = (wordcount, 0xe)[wordcount>0xd]
54             bitmask = LDM_BITMASKS[count]
55             self.ARMset_register(14,adr)
56             self.ARMdebuginstr(ARM_INSTR_LDMIA_R14_r0_rx | bitmask ,0)
57             self.ARM_nop(1)
58             #FIXME: do we need the extra nop here?
59             self.ARMrestart()
60             self.ARMwaitDBG()
61             output.extend([self.ARMget_register(x) for x in xrange(count)])
62             wordcount -= count
63             adr += count*4
64             #print hex(adr)
65         # FIXME: handle the rest of the wordcount here.
66         self.ARMset_registers(regs,0xe)
67         return output