xref: /btstack/port/stm32-l073rz-nucleo-em9304/ozone.jdebug (revision ca3a66ce2844f09aa36ec91baf32aac86d1d571f)
1
2/*********************************************************************
3*
4*       OnProjectLoad
5*
6* Function description
7*   Project load routine. Required.
8*
9**********************************************************************
10*/
11void OnProjectLoad (void) {
12  //
13  // Dialog-generated settings
14  //
15  Project.SetDevice ("STM32L073RZ");
16  Project.SetHostIF ("USB", "");
17  Project.SetTargetIF ("SWD");
18  Project.SetTIFSpeed ("50 MHz");
19  Project.AddSvdFile ("$(InstallDir)/Config/CPU/Cortex-M4F.svd");
20  //
21  // User settings
22  //
23  File.Open ("$(ProjectDir)/EXAMPLE.elf");
24}
25
26/*********************************************************************
27*
28*      TargetReset
29*
30* Function description
31*   Replaces the default target device reset routine. Optional.
32*
33* Notes
34*   This example demonstrates the usage when
35*   debugging a RAM program on a Cortex-M target device
36*
37**********************************************************************
38*/
39//void TargetReset (void) {
40//
41//  unsigned int SP;
42//  unsigned int PC;
43//  unsigned int VectorTableAddr;
44//
45//  Exec.Reset();
46//
47//  VectorTableAddr = Elf.GetBaseAddr();
48//
49//  if (VectorTableAddr != 0xFFFFFFFF) {
50//
51//    Util.Log("Resetting Program.");
52//
53//    SP = Target.ReadU32(VectorTableAddr);
54//    Target.SetReg("SP", SP);
55//
56//    PC = Target.ReadU32(VectorTableAddr + 4);
57//    Target.SetReg("PC", PC);
58//  }
59//}
60
61/*********************************************************************
62*
63*       BeforeTargetReset
64*
65* Function description
66*   Event handler routine. Optional.
67*
68**********************************************************************
69*/
70//void BeforeTargetReset (void) {
71//}
72
73/*********************************************************************
74*
75*       AfterTargetReset
76*
77* Function description
78*   Event handler routine.
79*    - Sets the PC register to program reset value.
80*    - Sets the SP register to program reset value on Cortex-M.
81*
82**********************************************************************
83*/
84void AfterTargetReset (void) {
85  unsigned int SP;
86  unsigned int PC;
87  unsigned int VectorTableAddr;
88
89  VectorTableAddr = Elf.GetBaseAddr();
90
91  if (VectorTableAddr == 0xFFFFFFFF) {
92    Util.Log("Project file error: failed to get program base");
93  } else {
94    SP = Target.ReadU32(VectorTableAddr);
95    Target.SetReg("SP", SP);
96
97    PC = Target.ReadU32(VectorTableAddr + 4);
98    Target.SetReg("PC", PC);
99  }
100}
101
102/*********************************************************************
103*
104*       DebugStart
105*
106* Function description
107*   Replaces the default debug session startup routine. Optional.
108*
109**********************************************************************
110*/
111//void DebugStart (void) {
112//}
113
114/*********************************************************************
115*
116*       TargetConnect
117*
118* Function description
119*   Replaces the default target IF connection routine. Optional.
120*
121**********************************************************************
122*/
123//void TargetConnect (void) {
124//}
125
126/*********************************************************************
127*
128*       BeforeTargetConnect
129*
130* Function description
131*   Event handler routine. Optional.
132*
133**********************************************************************
134*/
135//void BeforeTargetConnect (void) {
136//}
137
138/*********************************************************************
139*
140*       AfterTargetConnect
141*
142* Function description
143*   Event handler routine. Optional.
144*
145**********************************************************************
146*/
147//void AfterTargetConnect (void) {
148//}
149
150/*********************************************************************
151*
152*       TargetDownload
153*
154* Function description
155*   Replaces the default program download routine. Optional.
156*
157**********************************************************************
158*/
159//void TargetDownload (void) {
160//}
161
162/*********************************************************************
163*
164*       BeforeTargetDownload
165*
166* Function description
167*   Event handler routine. Optional.
168*
169**********************************************************************
170*/
171//void BeforeTargetDownload (void) {
172//}
173
174/*********************************************************************
175*
176*      AfterTargetDownload
177*
178* Function description
179*   Event handler routine.
180*    - Sets the PC register to program reset value.
181*    - Sets the SP register to program reset value on Cortex-M.
182*
183**********************************************************************
184*/
185void AfterTargetDownload (void) {
186  unsigned int SP;
187  unsigned int PC;
188  unsigned int VectorTableAddr;
189
190  VectorTableAddr = Elf.GetBaseAddr();
191
192  if (VectorTableAddr == 0xFFFFFFFF) {
193    Util.Log("Project file error: failed to get program base");
194  } else {
195    SP = Target.ReadU32(VectorTableAddr);
196    Target.SetReg("SP", SP);
197
198    PC = Target.ReadU32(VectorTableAddr + 4);
199    Target.SetReg("PC", PC);
200  }
201}
202
203/*********************************************************************
204*
205*       BeforeTargetDisconnect
206*
207* Function description
208*   Event handler routine. Optional.
209*
210**********************************************************************
211*/
212//void BeforeTargetDisconnect (void) {
213//}
214
215/*********************************************************************
216*
217*       AfterTargetDisconnect
218*
219* Function description
220*   Event handler routine. Optional.
221*
222**********************************************************************
223*/
224//void AfterTargetDisconnect (void) {
225//}
226
227/*********************************************************************
228*
229*       AfterTargetHalt
230*
231* Function description
232*   Event handler routine. Optional.
233*
234**********************************************************************
235*/
236//void AfterTargetHalt (void) {
237//}
238