lpc1xxx.cfg 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. # SPDX-License-Identifier: GPL-2.0-or-later
  2. # Main file for NXP LPC1xxx/LPC40xx series Cortex-M0/0+/3/4F parts
  3. #
  4. # !!!!!!
  5. #
  6. # This file should not be included directly, rather by the lpc11xx.cfg,
  7. # lpc13xx.cfg, lpc17xx.cfg, etc. which set the needed variables to the
  8. # appropriate values.
  9. #
  10. # !!!!!!
  11. # LPC8xx chips support only SWD transport.
  12. # LPC11xx chips support only SWD transport.
  13. # LPC12xx chips support only SWD transport.
  14. # LPC11Uxx chips support only SWD transports.
  15. # LPC13xx chips support only SWD transports.
  16. # LPC17xx chips support both JTAG and SWD transports.
  17. # LPC40xx chips support both JTAG and SWD transports.
  18. # Adapt based on what transport is active.
  19. source [find target/swj-dp.tcl]
  20. if { [info exists CHIPNAME] } {
  21. set _CHIPNAME $CHIPNAME
  22. } else {
  23. error "CHIPNAME not set. Please do not include lpc1xxx.cfg directly, but the specific chip configuration file (lpc11xx.cfg, lpc13xx.cfg, lpc17xx.cfg, etc)."
  24. }
  25. if { [info exists CHIPSERIES] } {
  26. # Validate chip series is supported
  27. if { $CHIPSERIES != "lpc800" && $CHIPSERIES != "lpc1100" && $CHIPSERIES != "lpc1200" && $CHIPSERIES != "lpc1300" && $CHIPSERIES != "lpc1700" && $CHIPSERIES != "lpc4000" } {
  28. error "Unsupported LPC1xxx chip series specified."
  29. }
  30. set _CHIPSERIES $CHIPSERIES
  31. } else {
  32. error "CHIPSERIES not set. Please do not include lpc1xxx.cfg directly, but the specific chip configuration file (lpc11xx.cfg, lpc13xx.cfg, lpc17xx.cfg, etc)."
  33. }
  34. # After reset, the chip is clocked by an internal RC oscillator.
  35. # When board-specific code (reset-init handler or device firmware)
  36. # configures another oscillator and/or PLL0, set CCLK to match; if
  37. # you don't, then flash erase and write operations may misbehave.
  38. # (The ROM code doing those updates cares about core clock speed...)
  39. # CCLK is the core clock frequency in KHz
  40. if { [info exists CCLK] } {
  41. # Allow user override
  42. set _CCLK $CCLK
  43. } else {
  44. # LPC8xx/LPC11xx/LPC12xx/LPC13xx use a 12MHz one, LPC17xx uses a 4MHz one(except for LPC177x/8x,LPC407x/8x)
  45. if { $_CHIPSERIES == "lpc800" || $_CHIPSERIES == "lpc1100" || $_CHIPSERIES == "lpc1200" || $_CHIPSERIES == "lpc1300" } {
  46. set _CCLK 12000
  47. } elseif { $_CHIPSERIES == "lpc1700" || $_CHIPSERIES == "lpc4000" } {
  48. set _CCLK 4000
  49. }
  50. }
  51. if { [info exists CPUTAPID] } {
  52. # Allow user override
  53. set _CPUTAPID $CPUTAPID
  54. } else {
  55. # LPC8xx/LPC11xx/LPC12xx use a Cortex-M0/M0+ core, LPC13xx/LPC17xx use a Cortex-M3 core, LPC40xx use a Cortex-M4F core.
  56. if { $_CHIPSERIES == "lpc800" || $_CHIPSERIES == "lpc1100" || $_CHIPSERIES == "lpc1200" } {
  57. set _CPUTAPID 0x0bb11477
  58. } elseif { $_CHIPSERIES == "lpc1300" || $_CHIPSERIES == "lpc1700" || $_CHIPSERIES == "lpc4000" } {
  59. if { [using_jtag] } {
  60. set _CPUTAPID 0x4ba00477
  61. } {
  62. set _CPUTAPID 0x2ba01477
  63. }
  64. }
  65. }
  66. if { [info exists WORKAREASIZE] } {
  67. set _WORKAREASIZE $WORKAREASIZE
  68. } else {
  69. error "WORKAREASIZE is not set. The $CHIPNAME part is available in several Flash and RAM size configurations. Please set WORKAREASIZE."
  70. }
  71. swj_newdap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID
  72. dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
  73. set _TARGETNAME $_CHIPNAME.cpu
  74. target create $_TARGETNAME cortex_m -dap $_CHIPNAME.dap
  75. # The LPC11xx devices have 2/4/8kB of SRAM in the ARMv7-M "Code" area (at 0x10000000)
  76. # The LPC12xx devices have 4/8kB of SRAM in the ARMv7-M "Code" area (at 0x10000000)
  77. # The LPC11Uxx devices have 4/6/8kB of SRAM in the ARMv7-M "Code" area (at 0x10000000)
  78. # The LPC13xx devices have 4/8kB of SRAM in the ARMv7-M "Code" area (at 0x10000000)
  79. # The LPC17xx devices have 8/16/32/64kB of SRAM in the ARMv7-M "Code" area (at 0x10000000)
  80. # The LPC40xx devices have 16/32/64kB of SRAM in the ARMv7-ME "Code" area (at 0x10000000)
  81. $_TARGETNAME configure -work-area-phys 0x10000000 -work-area-size $_WORKAREASIZE
  82. # The LPC11xx devies have 8/16/24/32/48/56/64kB of flash memory (at 0x00000000)
  83. # The LPC12xx devies have 32/48/64/80/96/128kB of flash memory (at 0x00000000)
  84. # The LPC11Uxx devies have 16/24/32/40/48/64/96/128kB of flash memory (at 0x00000000)
  85. # The LPC13xx devies have 8/16/32kB of flash memory (at 0x00000000)
  86. # The LPC17xx devies have 32/64/128/256/512kB of flash memory (at 0x00000000)
  87. # The LPC40xx devies have 64/128/256/512kB of flash memory (at 0x00000000)
  88. #
  89. # All are compatible with the "lpc1700" variant of the LPC2000 flash driver
  90. # (same cmd51 destination boundary alignment, and all three support 256 byte
  91. # transfers).
  92. #
  93. # flash bank <name> lpc2000 <base> <size> 0 0 <target#> <variant> <clock> [calc checksum] [iap entry]
  94. set _IAP_ENTRY 0
  95. if { [info exists IAP_ENTRY] } {
  96. set _IAP_ENTRY $IAP_ENTRY
  97. }
  98. set _FLASHNAME $_CHIPNAME.flash
  99. flash bank $_FLASHNAME lpc2000 0x0 0 0 0 $_TARGETNAME \
  100. auto $_CCLK calc_checksum $_IAP_ENTRY
  101. if { $_CHIPSERIES == "lpc800" || $_CHIPSERIES == "lpc1100" || $_CHIPSERIES == "lpc1200" || $_CHIPSERIES == "lpc1300" } {
  102. # Do not remap 0x0000-0x0200 to anything but the flash (i.e. select
  103. # "User Flash Mode" where interrupt vectors are _not_ remapped,
  104. # and reside in flash instead).
  105. #
  106. # Table 8. System memory remap register (SYSMEMREMAP, address 0x4004 8000) bit description
  107. # Bit Symbol Value Description
  108. # 1:0 MAP System memory remap
  109. # 0x0 Boot Loader Mode. Interrupt vectors are re-mapped to Boot ROM.
  110. # 0x1 User RAM Mode. Interrupt vectors are re-mapped to Static RAM.
  111. # 0x2 User Flash Mode. Interrupt vectors are not re-mapped and reside in Flash.
  112. # 31:2 - - Reserved.
  113. $_TARGETNAME configure -event reset-init {
  114. mww 0x40048000 0x02
  115. }
  116. } elseif { $_CHIPSERIES == "lpc1700" || $_CHIPSERIES == "lpc4000" } {
  117. # Do not remap 0x0000-0x0020 to anything but the flash (i.e. select
  118. # "User Flash Mode" where interrupt vectors are _not_ remapped,
  119. # and reside in flash instead).
  120. #
  121. # See Table 612. Memory Mapping Control register (MEMMAP - 0x400F C040) bit description
  122. # Bit Symbol Value Description Reset
  123. # value
  124. # 0 MAP Memory map control. 0
  125. # 0 Boot mode. A portion of the Boot ROM is mapped to address 0.
  126. # 1 User mode. The on-chip Flash memory is mapped to address 0.
  127. # 31:1 - Reserved. The value read from a reserved bit is not defined. NA
  128. #
  129. # http://ics.nxp.com/support/documents/microcontrollers/?scope=LPC1768&type=user
  130. $_TARGETNAME configure -event reset-init {
  131. mww 0x400FC040 0x01
  132. }
  133. }
  134. # Run with *real slow* clock by default since the
  135. # boot rom could have been playing with the PLL, so
  136. # we have no idea what clock the target is running at.
  137. adapter speed 10
  138. # delays on reset lines
  139. adapter srst delay 200
  140. if {[using_jtag]} {
  141. jtag_ntrst_delay 200
  142. }
  143. # LPC8xx (Cortex-M0+ core) support SYSRESETREQ
  144. # LPC11xx/LPC12xx (Cortex-M0 core) support SYSRESETREQ
  145. # LPC13xx/LPC17xx (Cortex-M3 core) support SYSRESETREQ
  146. # LPC40xx (Cortex-M4F core) support SYSRESETREQ
  147. if {![using_hla]} {
  148. # if srst is not fitted use SYSRESETREQ to
  149. # perform a soft reset
  150. cortex_m reset_config sysresetreq
  151. }