stm32f2x.cfg 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. # SPDX-License-Identifier: GPL-2.0-or-later
  2. # script for stm32f2x family
  3. #
  4. # stm32 devices support both JTAG and SWD transports.
  5. #
  6. source [find target/swj-dp.tcl]
  7. source [find mem_helper.tcl]
  8. if { [info exists CHIPNAME] } {
  9. set _CHIPNAME $CHIPNAME
  10. } else {
  11. set _CHIPNAME stm32f2x
  12. }
  13. set _ENDIAN little
  14. # Work-area is a space in RAM used for flash programming
  15. # By default use 64kB
  16. if { [info exists WORKAREASIZE] } {
  17. set _WORKAREASIZE $WORKAREASIZE
  18. } else {
  19. set _WORKAREASIZE 0x10000
  20. }
  21. # JTAG speed should be <= F_CPU/6. F_CPU after reset is 8MHz, so use F_JTAG = 1MHz
  22. #
  23. # Since we may be running of an RC oscilator, we crank down the speed a
  24. # bit more to be on the safe side. Perhaps superstition, but if are
  25. # running off a crystal, we can run closer to the limit. Note
  26. # that there can be a pretty wide band where things are more or less stable.
  27. adapter speed 1000
  28. adapter srst delay 100
  29. if {[using_jtag]} {
  30. jtag_ntrst_delay 100
  31. }
  32. #jtag scan chain
  33. if { [info exists CPUTAPID] } {
  34. set _CPUTAPID $CPUTAPID
  35. } else {
  36. if { [using_jtag] } {
  37. # See STM Document RM0033
  38. # Section 32.6.3 - corresponds to Cortex-M3 r2p0
  39. set _CPUTAPID 0x4ba00477
  40. } {
  41. set _CPUTAPID 0x2ba01477
  42. }
  43. }
  44. swj_newdap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
  45. dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
  46. if {[using_jtag]} {
  47. jtag newtap $_CHIPNAME bs -irlen 5
  48. }
  49. set _TARGETNAME $_CHIPNAME.cpu
  50. target create $_TARGETNAME cortex_m -endian $_ENDIAN -dap $_CHIPNAME.dap
  51. $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
  52. set _FLASHNAME $_CHIPNAME.flash
  53. flash bank $_FLASHNAME stm32f2x 0 0 0 0 $_TARGETNAME
  54. flash bank $_CHIPNAME.otp stm32f2x 0x1fff7800 0 0 0 $_TARGETNAME
  55. reset_config srst_nogate
  56. if {![using_hla]} {
  57. # if srst is not fitted use SYSRESETREQ to
  58. # perform a soft reset
  59. cortex_m reset_config sysresetreq
  60. }
  61. $_TARGETNAME configure -event examine-end {
  62. # DBGMCU_CR |= DBG_STANDBY | DBG_STOP | DBG_SLEEP
  63. mmw 0xE0042004 0x00000007 0
  64. # Stop watchdog counters during halt
  65. # DBGMCU_APB1_FZ |= DBG_IWDG_STOP | DBG_WWDG_STOP
  66. mmw 0xE0042008 0x00001800 0
  67. }
  68. tpiu create $_CHIPNAME.tpiu -dap $_CHIPNAME.dap -ap-num 0 -baseaddr 0xE0040000
  69. lappend _telnet_autocomplete_skip _proc_pre_enable_$_CHIPNAME.tpiu
  70. proc _proc_pre_enable_$_CHIPNAME.tpiu {_targetname} {
  71. targets $_targetname
  72. # Set TRACE_IOEN; TRACE_MODE is set to async; when using sync
  73. # change this value accordingly to configure trace pins
  74. # assignment
  75. mmw 0xE0042004 0x00000020 0
  76. }
  77. $_CHIPNAME.tpiu configure -event pre-enable "_proc_pre_enable_$_CHIPNAME.tpiu $_TARGETNAME"