ozone_scons.jdebug 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. /*********************************************************************
  2. * (c) SEGGER Microcontroller GmbH *
  3. * The Embedded Experts *
  4. * www.segger.com *
  5. **********************************************************************
  6. File : ozone_scons.jdebug
  7. Created : 2 Dec 2024 10:53
  8. Ozone Version : V3.38b
  9. */
  10. /*********************************************************************
  11. *
  12. * OnProjectLoad
  13. *
  14. * Function description
  15. * Project load routine. Required.
  16. *
  17. **********************************************************************
  18. */
  19. void OnProjectLoad (void) {
  20. //
  21. // Dialog-generated settings
  22. //
  23. Project.AddPathSubstitute ("./", "$(ProjectDir)");
  24. Project.AddPathSubstitute ("./", "$(ProjectDir)");
  25. Project.SetDevice ("R9A07G084M04");
  26. Project.SetHostIF ("USB", "");
  27. Project.SetTargetIF ("SWD");
  28. Project.SetTIFSpeed ("50 MHz");
  29. Project.AddSvdFile ("$(InstallDir)/Config/CPU/Cortex-R52_AArch32.svd");
  30. Project.AddSvdFile ("$(InstallDir)/Config/CPU/Cortex-R52_AArch32.svd");
  31. //
  32. // User settings
  33. //
  34. File.Open ("$(ProjectDir)/rtthread.elf");
  35. }
  36. /*********************************************************************
  37. *
  38. * OnStartupComplete
  39. *
  40. * Function description
  41. * Called when program execution has reached/passed
  42. * the startup completion point. Optional.
  43. *
  44. **********************************************************************
  45. */
  46. //void OnStartupComplete (void) {
  47. //}
  48. /*********************************************************************
  49. *
  50. * TargetReset
  51. *
  52. * Function description
  53. * Replaces the default target device reset routine. Optional.
  54. *
  55. * Notes
  56. * This example demonstrates the usage when
  57. * debugging an application in RAM on a Cortex-M target device.
  58. *
  59. **********************************************************************
  60. */
  61. void TargetReset (void) {
  62. //
  63. // unsigned int SP;
  64. // unsigned int PC;
  65. // unsigned int VectorTableAddr;
  66. //
  67. // VectorTableAddr = Elf.GetBaseAddr();
  68. // //
  69. // // Set up initial stack pointer
  70. // //
  71. // if (VectorTableAddr != 0xFFFFFFFF) {
  72. // SP = Target.ReadU32(VectorTableAddr);
  73. // Target.SetReg("SP", SP);
  74. // }
  75. // //
  76. // // Set up entry point PC
  77. // //
  78. // PC = Elf.GetEntryPointPC();
  79. //
  80. // if (PC != 0xFFFFFFFF) {
  81. // Target.SetReg("PC", PC);
  82. // } else if (VectorTableAddr != 0xFFFFFFFF) {
  83. // PC = Target.ReadU32(VectorTableAddr + 4);
  84. // Target.SetReg("PC", PC);
  85. // } else {
  86. // Util.Error("Project file error: failed to set entry point PC", 1);
  87. // }
  88. }
  89. /*********************************************************************
  90. *
  91. * BeforeTargetReset
  92. *
  93. * Function description
  94. * Event handler routine. Optional.
  95. *
  96. **********************************************************************
  97. */
  98. //void BeforeTargetReset (void) {
  99. //}
  100. /*********************************************************************
  101. *
  102. * AfterTargetReset
  103. *
  104. * Function description
  105. * Event handler routine. Optional.
  106. * The default implementation initializes SP and PC to reset values.
  107. **
  108. **********************************************************************
  109. */
  110. void AfterTargetReset (void) {
  111. _SetupTarget();
  112. }
  113. /*********************************************************************
  114. *
  115. * DebugStart
  116. *
  117. * Function description
  118. * Replaces the default debug session startup routine. Optional.
  119. *
  120. **********************************************************************
  121. */
  122. //void DebugStart (void) {
  123. //}
  124. /*********************************************************************
  125. *
  126. * TargetConnect
  127. *
  128. * Function description
  129. * Replaces the default target IF connection routine. Optional.
  130. *
  131. **********************************************************************
  132. */
  133. //void TargetConnect (void) {
  134. //}
  135. /*********************************************************************
  136. *
  137. * BeforeTargetConnect
  138. *
  139. * Function description
  140. * Event handler routine. Optional.
  141. *
  142. **********************************************************************
  143. */
  144. //void BeforeTargetConnect (void) {
  145. //}
  146. /*********************************************************************
  147. *
  148. * AfterTargetConnect
  149. *
  150. * Function description
  151. * Event handler routine. Optional.
  152. *
  153. **********************************************************************
  154. */
  155. //void AfterTargetConnect (void) {
  156. //}
  157. /*********************************************************************
  158. *
  159. * TargetDownload
  160. *
  161. * Function description
  162. * Replaces the default program download routine. Optional.
  163. *
  164. **********************************************************************
  165. */
  166. //void TargetDownload (void) {
  167. //}
  168. /*********************************************************************
  169. *
  170. * BeforeTargetDownload
  171. *
  172. * Function description
  173. * Event handler routine. Optional.
  174. *
  175. **********************************************************************
  176. */
  177. //void BeforeTargetDownload (void) {
  178. //}
  179. /*********************************************************************
  180. *
  181. * AfterTargetDownload
  182. *
  183. * Function description
  184. * Event handler routine. Optional.
  185. * The default implementation initializes SP and PC to reset values.
  186. *
  187. **********************************************************************
  188. */
  189. void AfterTargetDownload (void) {
  190. _SetupTarget();
  191. }
  192. /*********************************************************************
  193. *
  194. * BeforeTargetDisconnect
  195. *
  196. * Function description
  197. * Event handler routine. Optional.
  198. *
  199. **********************************************************************
  200. */
  201. //void BeforeTargetDisconnect (void) {
  202. //}
  203. /*********************************************************************
  204. *
  205. * AfterTargetDisconnect
  206. *
  207. * Function description
  208. * Event handler routine. Optional.
  209. *
  210. **********************************************************************
  211. */
  212. //void AfterTargetDisconnect (void) {
  213. //}
  214. /*********************************************************************
  215. *
  216. * AfterTargetHalt
  217. *
  218. * Function description
  219. * Event handler routine. Optional.
  220. *
  221. **********************************************************************
  222. */
  223. //void AfterTargetHalt (void) {
  224. //}
  225. /*********************************************************************
  226. *
  227. * BeforeTargetResume
  228. *
  229. * Function description
  230. * Event handler routine. Optional.
  231. *
  232. **********************************************************************
  233. */
  234. //void BeforeTargetResume (void) {
  235. //}
  236. /*********************************************************************
  237. *
  238. * OnSnapshotLoad
  239. *
  240. * Function description
  241. * Called upon loading a snapshot. Optional.
  242. *
  243. * Additional information
  244. * This function is used to restore the target state in cases
  245. * where values cannot simply be written to the target.
  246. * Typical use: GPIO clock needs to be enabled, before
  247. * GPIO is configured.
  248. *
  249. **********************************************************************
  250. */
  251. //void OnSnapshotLoad (void) {
  252. //}
  253. /*********************************************************************
  254. *
  255. * OnSnapshotSave
  256. *
  257. * Function description
  258. * Called upon saving a snapshot. Optional.
  259. *
  260. * Additional information
  261. * This function is usually used to save values of the target
  262. * state which can either not be trivially read,
  263. * or need to be restored in a specific way or order.
  264. * Typically use: Memory Mapped Registers,
  265. * such as PLL and GPIO configuration.
  266. *
  267. **********************************************************************
  268. */
  269. //void OnSnapshotSave (void) {
  270. //}
  271. /*********************************************************************
  272. *
  273. * OnError
  274. *
  275. * Function description
  276. * Called when an error ocurred. Optional.
  277. *
  278. **********************************************************************
  279. */
  280. //void OnError (void) {
  281. //}
  282. /*********************************************************************
  283. *
  284. * AfterProjectLoad
  285. *
  286. * Function description
  287. * After Project load routine. Optional.
  288. *
  289. **********************************************************************
  290. */
  291. //void AfterProjectLoad (void) {
  292. //}
  293. /*********************************************************************
  294. *
  295. * _SetupTarget
  296. *
  297. * Function description
  298. * Setup the target.
  299. * Called by AfterTargetReset() and AfterTargetDownload().
  300. *
  301. * Auto-generated function. May be overridden by Ozone.
  302. *
  303. **********************************************************************
  304. */
  305. void _SetupTarget(void) {
  306. //
  307. // this function is intentionally empty because both inital PC and
  308. // initial SP were chosen not to be set
  309. //
  310. U64 PC;
  311. U32 cpsr;
  312. int ElfClass;
  313. ElfClass = Elf.GetFileClass();
  314. //
  315. // Set up initial PC
  316. //
  317. PC = Elf.GetExprValue("system_init");
  318. if (PC != 0xFFFFFFFF) {
  319. if (ElfClass == ELF_CLASS_64) {
  320. //
  321. // AArch64
  322. //
  323. Target.SetReg("PC", PC);
  324. } else if (ElfClass == ELF_CLASS_32) {
  325. //
  326. // AArch32
  327. //
  328. Exec.Reset();
  329. Target.SetReg("CPSR", 0x01da);
  330. Target.SetReg("R15 (PC)", PC);
  331. } else {
  332. Util.Error("Project script error: failed to set initial PC", 1);
  333. }
  334. } else {
  335. Util.Error("Project script error: failed to set initial PC", 1);
  336. }
  337. }