stm32wbx.cfg 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. # SPDX-License-Identifier: GPL-2.0-or-later
  2. # script for stm32wbx family
  3. #
  4. # stm32wb 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 stm32wbx
  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 scan chain
  22. if { [info exists CPUTAPID] } {
  23. set _CPUTAPID $CPUTAPID
  24. } else {
  25. if { [using_jtag] } {
  26. set _CPUTAPID 0x6ba00477
  27. } else {
  28. # SWD IDCODE (single drop, arm)
  29. set _CPUTAPID 0x6ba02477
  30. }
  31. }
  32. swj_newdap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
  33. dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
  34. if {[using_jtag]} {
  35. jtag newtap $_CHIPNAME bs -irlen 5
  36. }
  37. set _TARGETNAME $_CHIPNAME.cpu
  38. target create $_TARGETNAME cortex_m -endian $_ENDIAN -dap $_CHIPNAME.dap
  39. $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
  40. flash bank $_CHIPNAME.flash stm32l4x 0x08000000 0 0 0 $_TARGETNAME
  41. flash bank $_CHIPNAME.otp stm32l4x 0x1fff7000 0 0 0 $_TARGETNAME
  42. # Common knowledges tells JTAG speed should be <= F_CPU/6.
  43. # F_CPU after reset is MSI 4MHz, so use F_JTAG = 500 kHz to stay on
  44. # the safe side.
  45. #
  46. # Note that there is a pretty wide band where things are
  47. # more or less stable, see http://openocd.zylin.com/#/c/3366/
  48. adapter speed 500
  49. adapter srst delay 100
  50. if {[using_jtag]} {
  51. jtag_ntrst_delay 100
  52. }
  53. reset_config srst_nogate
  54. if {![using_hla]} {
  55. # if srst is not fitted use SYSRESETREQ to
  56. # perform a soft reset
  57. cortex_m reset_config sysresetreq
  58. }
  59. $_TARGETNAME configure -event reset-init {
  60. # CPU comes out of reset with MSI_ON | MSI_RDY | MSI Range 4 MHz.
  61. # Configure system to use MSI 24 MHz clock, compliant with VOS default Range1.
  62. # 2 WS compliant with VOS=Range1 and 24 MHz.
  63. mmw 0x58004000 0x00000102 0 ;# FLASH_ACR |= PRFTBE | 2(Latency)
  64. mmw 0x58000000 0x00000091 0 ;# RCC_CR = MSI_ON | MSI Range 24 MHz
  65. # Boost JTAG frequency
  66. adapter speed 4000
  67. }
  68. $_TARGETNAME configure -event reset-start {
  69. # Reset clock is MSI (4 MHz)
  70. adapter speed 500
  71. }
  72. $_TARGETNAME configure -event examine-end {
  73. # Enable debug during low power modes (uses more power)
  74. # DBGMCU_CR |= DBG_STANDBY | DBG_STOP | DBG_SLEEP
  75. mmw 0xE0042004 0x00000007 0
  76. # Stop watchdog counters during halt
  77. # DBGMCU_APB1_FZR1 |= DBG_IWDG_STOP | DBG_WWDG_STOP
  78. mmw 0xE004203C 0x00001800 0
  79. }
  80. tpiu create $_CHIPNAME.tpiu -dap $_CHIPNAME.dap -ap-num 0 -baseaddr 0xE0040000
  81. lappend _telnet_autocomplete_skip _proc_pre_enable_$_CHIPNAME.tpiu
  82. proc _proc_pre_enable_$_CHIPNAME.tpiu {_targetname} {
  83. targets $_targetname
  84. # Set TRACE_IOEN; TRACE_MODE is set to async; when using sync
  85. # change this value accordingly to configure trace pins
  86. # assignment
  87. mmw 0xE0042004 0x00000020 0
  88. }
  89. $_CHIPNAME.tpiu configure -event pre-enable "_proc_pre_enable_$_CHIPNAME.tpiu $_TARGETNAME"