stellaris.cfg 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. # SPDX-License-Identifier: GPL-2.0-or-later
  2. # TI/Luminary Stellaris LM3S chip family
  3. # Some devices have errata in returning their device class.
  4. # DEVICECLASS is provided as a manual override
  5. # Manual setting of a device class of 0xff is not allowed
  6. global _DEVICECLASS
  7. if { [info exists DEVICECLASS] } {
  8. set _DEVICECLASS $DEVICECLASS
  9. } else {
  10. set _DEVICECLASS 0xff
  11. }
  12. # Luminary chips support both JTAG and SWD transports.
  13. # Adapt based on what transport is active.
  14. source [find target/swj-dp.tcl]
  15. # For now we ignore the SPI and UART options, which
  16. # are usable only for ISP style initial flash programming.
  17. if { [info exists CHIPNAME] } {
  18. set _CHIPNAME $CHIPNAME
  19. } else {
  20. set _CHIPNAME lm3s
  21. }
  22. # CPU TAP ID 0x1ba00477 for early Sandstorm parts
  23. # CPU TAP ID 0x2ba00477 for later SandStorm parts, e.g. lm3s811 Rev C2
  24. # CPU TAP ID 0x3ba00477 for Cortex-M3 r1p2 (on Fury, DustDevil)
  25. # CPU TAP ID 0x4ba00477 for Cortex-M3 r2p0 (on Tempest, Firestorm)
  26. # CPU TAP ID 0x4ba00477 for Cortex-M4 r0p1 (on Blizzard)
  27. # ... we'll ignore the JTAG version field, rather than list every
  28. # chip revision that turns up.
  29. if { [info exists CPUTAPID] } {
  30. set _CPUTAPID $CPUTAPID
  31. } else {
  32. set _CPUTAPID 0x0ba00477
  33. }
  34. # SWD DAP, and JTAG TAP, take same params for now;
  35. # ... even though SWD ignores all except TAPID, and
  36. # JTAG shouldn't need anything more then irlen. (and TAPID).
  37. swj_newdap $_CHIPNAME cpu -irlen 4 -irmask 0xf \
  38. -expected-id $_CPUTAPID -ignore-version
  39. dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
  40. if { [info exists WORKAREASIZE] } {
  41. set _WORKAREASIZE $WORKAREASIZE
  42. } else {
  43. # default to 2K working area
  44. set _WORKAREASIZE 0x800
  45. }
  46. set _TARGETNAME $_CHIPNAME.cpu
  47. target create $_TARGETNAME cortex_m -dap $_CHIPNAME.dap
  48. # 8K working area at base of ram, not backed up
  49. #
  50. # NOTE: you may need or want to reconfigure the work area;
  51. # some parts have just 6K, and you may want to use other
  52. # addresses (at end of mem not beginning) or back it up.
  53. $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE
  54. # JTAG speed ... slow enough to work with a 12 MHz RC oscillator;
  55. # LM3S parts don't support RTCK
  56. #
  57. # NOTE: this may be increased by a reset-init handler, after it
  58. # configures and enables the PLL. Or you might need to decrease
  59. # this, if you're using a slower clock.
  60. adapter speed 500
  61. source [find mem_helper.tcl]
  62. proc reset_peripherals {family} {
  63. source [find chip/ti/lm3s/lm3s.tcl]
  64. echo "Resetting Core Peripherals"
  65. # Disable the PLL and the system clock divider (nop if disabled)
  66. mmw $SYSCTL_RCC 0 $SYSCTL_RCC_USESYSDIV
  67. mmw $SYSCTL_RCC2 $SYSCTL_RCC2_BYPASS2 0
  68. # RCC and RCC2 to their reset values
  69. mww $SYSCTL_RCC [expr {0x078e3ad0 | ([mrw $SYSCTL_RCC] & $SYSCTL_RCC_MOSCDIS)}]
  70. mww $SYSCTL_RCC2 0x07806810
  71. mww $SYSCTL_RCC 0x078e3ad1
  72. # Reset the deep sleep clock configuration register
  73. mww $SYSCTL_DSLPCLKCFG 0x07800000
  74. # Reset the clock gating registers
  75. mww $SYSCTL_RCGC0 0x00000040
  76. mww $SYSCTL_RCGC1 0
  77. mww $SYSCTL_RCGC2 0
  78. mww $SYSCTL_SCGC0 0x00000040
  79. mww $SYSCTL_SCGC1 0
  80. mww $SYSCTL_SCGC2 0
  81. mww $SYSCTL_DCGC0 0x00000040
  82. mww $SYSCTL_DCGC1 0
  83. mww $SYSCTL_DCGC2 0
  84. # Reset the remaining SysCtl registers
  85. mww $SYSCTL_PBORCTL 0
  86. mww $SYSCTL_IMC 0
  87. mww $SYSCTL_GPIOHBCTL 0
  88. mww $SYSCTL_MOSCCTL 0
  89. mww $SYSCTL_PIOSCCAL 0
  90. mww $SYSCTL_I2SMCLKCFG 0
  91. # Reset the peripherals
  92. mww $SYSCTL_SRCR0 0xffffffff
  93. mww $SYSCTL_SRCR1 0xffffffff
  94. mww $SYSCTL_SRCR2 0xffffffff
  95. mww $SYSCTL_SRCR0 0
  96. mww $SYSCTL_SRCR1 0
  97. mww $SYSCTL_SRCR2 0
  98. # Clear any pending SysCtl interrupts
  99. mww $SYSCTL_MISC 0xffffffff
  100. # Wait for any pending flash operations to complete
  101. while {[expr {[mrw $FLASH_FMC] & 0xffff}] != 0} { sleep 1 }
  102. while {[expr {[mrw $FLASH_FMC2] & 0xffff}] != 0} { sleep 1 }
  103. # Reset the flash controller registers
  104. mww $FLASH_FMA 0
  105. mww $FLASH_FCIM 0
  106. mww $FLASH_FCMISC 0xffffffff
  107. mww $FLASH_FWBVAL 0
  108. }
  109. $_TARGETNAME configure -event reset-start {
  110. adapter speed 500
  111. #
  112. # When nRST is asserted on most Stellaris devices, it clears some of
  113. # the debug state. The ARMv7M and Cortex-M3 TRMs say that's wrong;
  114. # and OpenOCD depends on those TRMs. So we won't use SRST on those
  115. # chips. (Only power-on reset should affect debug state, beyond a
  116. # few specified bits; not the chip's nRST input, wired to SRST.)
  117. #
  118. # REVISIT current errata specs don't seem to cover this issue.
  119. # Do we have more details than this email?
  120. # https://lists.berlios.de/pipermail
  121. # /openocd-development/2008-August/003065.html
  122. #
  123. global _DEVICECLASS
  124. if {$_DEVICECLASS != 0xff} {
  125. set device_class $_DEVICECLASS
  126. } else {
  127. set device_class [expr {([mrw 0x400fe000] >> 16) & 0xff}]
  128. }
  129. if {$device_class == 0 || $device_class == 1 ||
  130. $device_class == 3 || $device_class == 5 || $device_class == 0xa} {
  131. if {![using_hla]} {
  132. # Sandstorm, Fury, DustDevil, Blizzard and Snowflake are able to use NVIC SYSRESETREQ
  133. cortex_m reset_config sysresetreq
  134. }
  135. } else {
  136. if {![using_hla]} {
  137. # Tempest and Firestorm default to using NVIC VECTRESET
  138. # peripherals will need resetting manually, see proc reset_peripherals
  139. cortex_m reset_config vectreset
  140. }
  141. # reset peripherals, based on code in
  142. # http://www.ti.com/lit/er/spmz573a/spmz573a.pdf
  143. reset_peripherals $device_class
  144. }
  145. }
  146. # flash configuration ... autodetects sizes, autoprobed
  147. flash bank $_CHIPNAME.flash stellaris 0 0 0 0 $_TARGETNAME