Project

General

Profile

Files » test-lesia.py

Alexis Jeandet, 30/03/2014 05:35 PM

 
1
APBUARTBASEADD=lppmonEngine.getEnumDeviceBaseAddress(1,0x0c,0)
2
APBTIMERBASEADD=lppmonEngine.getEnumDeviceBaseAddress(1,0x11,0)
3
APBIRQCTRLRBASEADD=lppmonEngine.getEnumDeviceBaseAddress(1,0x0d,0)
4

    
5
def hex2(n):
6
    return "0x%x"%(n&0xffffffff)
7

    
8
def run_leon():
9
	AHBUART0.Write(0x90000020, [0])
10

    
11

    
12
def load_leon():
13

    
14

    
15
	# Force a debug break
16
	print "Force a debug break"
17
	AHBUART0.Write(0x90000000, [0x0000002f]) #Write DSU Control Reg
18
	AHBUART0.Write(0x90000020, [0x0000ffff]) #
19

    
20
	#  Clear ASR registers
21
	print "Clear ASR registers"
22
	AHBUART0.Write(0x90400040, [0x00000000, 0x00000000, 0x00000000])
23
	AHBUART0.Write(0x90400024, [0x00000002]) # ASIDiagAccReg
24

    
25
	AHBUART0.Write(0x90400060, [0x00000000, 0x00000000, 0x00000000, 0x00000000,   0x00000000, 0x00000000, 0x00000000, 0x00000000])
26
	AHBUART0.Write(0x90400048, [0x00000000])
27
	AHBUART0.Write(0x9040004C, [0x00000000])
28
	AHBUART0.Write(0x90400040, [0x00008000])
29

    
30

    
31
	#mem config
32
	print "Configure memory controller"
33
	AHBUART0.Write(0x80000000, [0x000002FF,0x00000E60,0x00000])
34

    
35
	AHBUART0.Write(0x90400060, [0x00000000, 0x00000000, 0x00000000, 0x00000000])
36
	AHBUART0.Write(0x90000024, [0x0000FFFF]) 
37

    
38

    
39
	for i in range(0,512,4):
40
	    AHBUART0.Write(0x90300000+i, [0])
41

    
42
	AHBUART0.Write(0x90400000, [0x00000000,0xF34010E0,0x00000002,0x40000000,0x40000000,0x40000004,0x1000000])
43

    
44
	AHBUART0.Write(0x90300020, [0, 0, 0, 0, 0, 0, 0x400FFFF0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0])
45

    
46
	AHBUART0.Write(0x90000000, [0x000002EF])
47

    
48
	#  Disable interrupts
49
	print "Disable interrupts"
50
	AHBUART0.Write(APBIRQCTRLRBASEADD+0x040, [0x00000000]) # IntrMask
51
	AHBUART0.Write(APBIRQCTRLRBASEADD+0x080, [0xFFFE0000]) # IntrMask
52
	AHBUART0.Write(APBIRQCTRLRBASEADD,[0x00000000, 0x00000000]) # IntrLevel & IntrPend
53

    
54
	#Set up timer
55
	print "Set up timer"
56
	AHBUART0.Write(APBTIMERBASEADD+0x014, [0xffffffff]) # Timer1 Reload
57
	AHBUART0.Write(APBTIMERBASEADD+4, [0x00000018])     # Scaler reload
58
	AHBUART0.Write(APBTIMERBASEADD+0x018, [0x00000007]) # Timer1 Control
59

    
60
	print "Load elf File"
61
	dsu3plugin0.loadFile()
62

    
63

    
64

    
65

    
66

    
67

    
68
proxy.loadSysDriver("/home/jeandet/.lppmon/plugins/libahbuartplugin_d.so","AHBUART0")
69
print "try to connect to leon"
70
attempts = 0
71
while attempts < 4:
72
	if AHBUART0.open("/dev/ttyUSB0",115200):
73
		proxy.loadSysDriverToParent("/home/jeandet/.lppmon/plugins/libdsu3plugin_d.so","dsu3plugin0","AHBUART0")
74
		dsu3plugin0.openFile("/home/jeandet/Documents/prog/sparc/hello/main")
75
		load_leon()
76
		run_leon()
77
		break
78
	else:
79
		print "failed to connect to board"
80

    
81

    
82

    
83

    
84

    
85

    
86

    
87

    
88

    
89

    
90

    
91

    
92

    
93

    
94

    
95

    
96

    
97

    
98

    
99

    
(2-2/11)