NXP_iMX8QX_Connect_CortexM4.JLinkScript 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*********************************************************************
  2. * (c) SEGGER Microcontroller GmbH & Co. KG *
  3. * The Embedded Experts *
  4. * www.segger.com *
  5. **********************************************************************
  6. -------------------------- END-OF-HEADER -----------------------------
  7. */
  8. /*********************************************************************
  9. *
  10. * ResetTarget
  11. */
  12. void ResetTarget(void) {
  13. //
  14. // This device requires a special reset as default reset does not work for this device.
  15. // TBD
  16. //
  17. }
  18. /*********************************************************************
  19. *
  20. * InitTarget
  21. */
  22. void InitTarget(void) {
  23. int v;
  24. int Ctrl;
  25. int CSGPR_ADDR;
  26. int DP_REG_CTRL_STAT;
  27. int DP_REG_SELECT;
  28. int APBAP_REG_CTRL;
  29. int APBAP_REG_ADDR;
  30. int APBAP_REG_DATA;
  31. CSGPR_ADDR = 0x80070000;
  32. DP_REG_CTRL_STAT = 1;
  33. DP_REG_SELECT = 2;
  34. APBAP_REG_CTRL = 0;
  35. APBAP_REG_ADDR = 1;
  36. APBAP_REG_DATA = 3;
  37. Report("***************************************************");
  38. Report("J-Link script: iMX8QX Cortex-M4 core0 J-Link script");
  39. Report("***************************************************");
  40. JLINK_CORESIGHT_Configure("IRPre=0;DRPre=0;IRPost=0;DRPost=0;IRLenDevice=4");
  41. CPU = CORTEX_M4; // Pre-select that we have a Cortex-M4 connected
  42. JTAG_AllowTAPReset = 0; // J-Link is allowed to use a TAP reset for JTAG-chain auto-detection
  43. //
  44. // Power-up complete DAP
  45. //
  46. Ctrl = 0
  47. | (1 << 30) // System power-up
  48. | (1 << 28) // Debug popwer-up
  49. | (1 << 5) // Clear STICKYERR
  50. ;
  51. JLINK_CORESIGHT_WriteDP(DP_REG_CTRL_STAT, Ctrl);
  52. //
  53. // Select AHB-AP and configure it
  54. //
  55. JLINK_CORESIGHT_WriteDP(DP_REG_SELECT, (0 << 4) | (4 << 24));
  56. JLINK_CORESIGHT_WriteAP(APBAP_REG_CTRL, (2 << 0) | (1 << 31));
  57. // Kick off M4_0
  58. JLINK_CORESIGHT_WriteAP(APBAP_REG_ADDR, CSGPR_ADDR);
  59. v = JLINK_CORESIGHT_ReadAP(APBAP_REG_DATA);
  60. v |= 1 << 6;
  61. JLINK_CORESIGHT_WriteAP(APBAP_REG_ADDR, CSGPR_ADDR);
  62. JLINK_CORESIGHT_WriteAP(APBAP_REG_DATA, v);
  63. // Wait 100ms to make sure M4_0 wakeup
  64. SYS_Sleep(100);
  65. //
  66. // Manually configure which APs are present on the CoreSight device
  67. //
  68. JTAG_SetDeviceId(0, 0x5BA00477); // 4-bits IRLen
  69. CORESIGHT_AddAP(0, CORESIGHT_AHB_AP); // AXI-AP
  70. CORESIGHT_AddAP(1, CORESIGHT_AHB_AP); // SCU-AP
  71. CORESIGHT_AddAP(2, CORESIGHT_AHB_AP); // CM4-0-AP
  72. CORESIGHT_AddAP(3, CORESIGHT_AHB_AP); // CM0+
  73. CORESIGHT_AddAP(4, CORESIGHT_APB_AP); // APB-AP for CA53
  74. CORESIGHT_IndexAHBAPToUse = 2;
  75. }
  76. /*********************************************************************
  77. *
  78. * SetupTarget
  79. */
  80. void SetupTarget(void)
  81. {
  82. // Configure LMEM Parity/ECC Control Register
  83. //
  84. // Note: ECC Multi-bit IRQ should be disabled
  85. // prior to list/dump of locations that
  86. // have not been written to avoid vectoring
  87. // to the NMI
  88. //
  89. // 31:22 RESERVED
  90. // 21 Enable Cache Parity IRQ
  91. // 20 Enable Cache Parity Report
  92. // 19:17 RESERVED
  93. // 16 Enable RAM Parity Reporting
  94. // 15:10 RESERVED
  95. // 9 Enable RAM ECC 1-bit IRQ
  96. // 8 Enable RAM ECC 1-bit Report
  97. // 7:2 RESERVED
  98. // 1 Enable RAM ECC Multi-bit IRQ
  99. // 0 Enable RAM ECC Multi-bit
  100. JLINK_MEM_WriteU32(0xE0080480, 0x0);
  101. }