stm32wbax.cfg 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. # SPDX-License-Identifier: GPL-2.0-or-later
  2. # script for stm32wbax family
  3. #
  4. # stm32wba 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 stm32wbax
  12. }
  13. # Work-area is a space in RAM used for flash programming
  14. # By default use 64kB
  15. if { [info exists WORKAREASIZE] } {
  16. set _WORKAREASIZE $WORKAREASIZE
  17. } else {
  18. set _WORKAREASIZE 0x10000
  19. }
  20. #jtag scan chain
  21. if { [info exists CPUTAPID] } {
  22. set _CPUTAPID $CPUTAPID
  23. } else {
  24. if { [using_jtag] } {
  25. set _CPUTAPID 0x6ba00477
  26. } else {
  27. # SWD IDCODE (single drop, arm)
  28. set _CPUTAPID 0x6ba02477
  29. }
  30. }
  31. swj_newdap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
  32. dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
  33. if {[using_jtag]} {
  34. jtag newtap $_CHIPNAME bs -irlen 5
  35. }
  36. set _TARGETNAME $_CHIPNAME.cpu
  37. target create $_TARGETNAME cortex_m -endian little -dap $_CHIPNAME.dap -ap-num 1
  38. $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
  39. flash bank $_CHIPNAME.flash stm32l4x 0x08000000 0 0 0 $_TARGETNAME
  40. flash bank $_CHIPNAME.otp stm32l4x 0x0FF90000 0 0 0 $_TARGETNAME
  41. # Common knowledges tells JTAG speed should be <= F_CPU/6.
  42. # F_CPU after reset is MSI 4MHz, so use F_JTAG = 500 kHz to stay on
  43. # the safe side.
  44. #
  45. # Note that there is a pretty wide band where things are
  46. # more or less stable, see http://openocd.zylin.com/#/c/3366/
  47. adapter speed 500
  48. adapter srst delay 100
  49. if {[using_jtag]} {
  50. jtag_ntrst_delay 100
  51. }
  52. reset_config srst_nogate
  53. if {![using_hla]} {
  54. # if srst is not fitted use SYSRESETREQ to
  55. # perform a soft reset
  56. cortex_m reset_config sysresetreq
  57. }
  58. $_TARGETNAME configure -event reset-init {
  59. # CPU comes out of reset with HSION | HSIRDY.
  60. # Use HSI 16 MHz clock, compliant even with VOS == 2.
  61. # 1 WS compliant with VOS == 2 and 16 MHz.
  62. mmw 0x40022000 0x00000001 0x0000000E ;# FLASH_ACR: Latency = 1
  63. mmw 0x56020C00 0x00000100 0x00000000 ;# RCC_CR |= HSION
  64. mmw 0x56020C1C 0x00000000 0x00000002 ;# RCC_CFGR1: SW=HSI16
  65. # Boost JTAG frequency
  66. adapter speed 4000
  67. }
  68. $_TARGETNAME configure -event reset-start {
  69. # Reset clock is HSI (16 MHz)
  70. adapter speed 2000
  71. }
  72. $_TARGETNAME configure -event examine-end {
  73. # Enable debug during low power modes (uses more power)
  74. # DBGMCU_CR |= DBG_STANDBY | DBG_STOP
  75. mmw 0xE0042004 0x00000006 0
  76. # Stop watchdog counters during halt
  77. # DBGMCU_APB1LFZR |= DBG_IWDG_STOP | DBG_WWDG_STOP
  78. mmw 0xE0042008 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. }
  85. $_CHIPNAME.tpiu configure -event pre-enable "_proc_pre_enable_$_CHIPNAME.tpiu $_TARGETNAME"