You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

113 lines
3.1 KiB

  1. #
  2. # OpenOCD Target Configuration for eMAG ARMv8 Processor
  3. #
  4. # Copyright (c) 2019-2021, Ampere Computing LLC
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License as
  8. # published by the Free Software Foundation; either version 2 of
  9. # the License, or (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program;
  18. #
  19. #
  20. #
  21. # Configure defaults for target
  22. # Can be overriden in board configuration file
  23. #
  24. if { [info exists CHIPNAME] } {
  25. set _CHIPNAME $CHIPNAME
  26. } else {
  27. set _CHIPNAME emag
  28. }
  29. if { [info exists NUMCORES] } {
  30. set _NUMCORES $NUMCORES
  31. } else {
  32. set _NUMCORES 32
  33. }
  34. if { [info exists ENDIAN] } {
  35. set _ENDIAN $ENDIAN
  36. } else {
  37. set _ENDIAN little
  38. }
  39. if { [info exists CPUTAPID ] } {
  40. set _CPUTAPID $CPUTAPID
  41. } else {
  42. set _CPUTAPID 0x4BA00477
  43. }
  44. #
  45. # Configure JTAG TAP
  46. #
  47. jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0x3 -expected-id $_CPUTAPID
  48. set _TAPNAME $_CHIPNAME.cpu
  49. set _DAPNAME ${_TAPNAME}_dap
  50. set _APNUM 1
  51. dap create $_DAPNAME -chain-position $_TAPNAME
  52. $_DAPNAME apsel $_APNUM
  53. # Create the DAP AP0 MEM-AP AHB-AP target
  54. target create AHB mem_ap -endian $_ENDIAN -dap $_DAPNAME -ap-num 0
  55. # Create the DAP AP1 MEM-AP APB-AP target
  56. target create APB mem_ap -endian $_ENDIAN -dap $_DAPNAME -ap-num 1
  57. #
  58. # Configure target CPUs
  59. #
  60. # Build string used to enable smp mode
  61. set _SMP_STR "target smp"
  62. for {set _i 0} {$_i < $_NUMCORES} {incr _i} {
  63. # Format a string to reference which CPU target to use
  64. set _TARGETNAME [format "${_TAPNAME}_%02d" $_i]
  65. # Create and configure Cross Trigger Interface (CTI) - required for halt and resume
  66. set _CTINAME $_TARGETNAME.cti
  67. cti create $_CTINAME -dap $_DAPNAME -ap-num $_APNUM -baseaddr [expr {0xFC020000 + ($_i << 20)}]
  68. # Create the target
  69. target create $_TARGETNAME aarch64 -endian $_ENDIAN -dap $_DAPNAME -ap-num $_APNUM -cti $_CTINAME -coreid $_i
  70. set _SMP_STR "$_SMP_STR $_TARGETNAME"
  71. # Clear CTI output/input enables that are not configured by OpenOCD for aarch64
  72. $_TARGETNAME configure -event examine-start [subst {
  73. $_CTINAME write INEN0 0x00000000
  74. $_CTINAME write INEN1 0x00000000
  75. $_CTINAME write INEN2 0x00000000
  76. $_CTINAME write INEN3 0x00000000
  77. $_CTINAME write INEN4 0x00000000
  78. $_CTINAME write INEN5 0x00000000
  79. $_CTINAME write INEN6 0x00000000
  80. $_CTINAME write INEN7 0x00000000
  81. $_CTINAME write INEN8 0x00000000
  82. $_CTINAME write OUTEN2 0x00000000
  83. $_CTINAME write OUTEN3 0x00000000
  84. $_CTINAME write OUTEN4 0x00000000
  85. $_CTINAME write OUTEN5 0x00000000
  86. $_CTINAME write OUTEN6 0x00000000
  87. $_CTINAME write OUTEN7 0x00000000
  88. $_CTINAME write OUTEN8 0x00000000
  89. }]
  90. # Enable OpenOCD HWTHREAD RTOS feature for GDB thread (CPU) selection support
  91. # This feature presents CPU cores ("hardware threads") in an SMP system as threads to GDB
  92. $_TARGETNAME configure -rtos hwthread
  93. }
  94. eval $_SMP_STR