stm32f1x.cfg 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. # SPDX-License-Identifier: GPL-2.0-or-later
  2. # script for stm32f1x 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 stm32f1x
  12. }
  13. set _ENDIAN little
  14. # Work-area is a space in RAM used for flash programming
  15. # By default use 4kB (as found on some STM32F100s)
  16. if { [info exists WORKAREASIZE] } {
  17. set _WORKAREASIZE $WORKAREASIZE
  18. } else {
  19. set _WORKAREASIZE 0x1000
  20. }
  21. # Allow overriding the Flash bank size
  22. if { [info exists FLASH_SIZE] } {
  23. set _FLASH_SIZE $FLASH_SIZE
  24. } else {
  25. # autodetect size
  26. set _FLASH_SIZE 0
  27. }
  28. #jtag scan chain
  29. if { [info exists CPUTAPID] } {
  30. set _CPUTAPID $CPUTAPID
  31. } else {
  32. if { [using_jtag] } {
  33. # See STM Document RM0008 Section 26.6.3
  34. set _CPUTAPID 0x3ba00477
  35. } {
  36. # this is the SW-DP tap id not the jtag tap id
  37. set _CPUTAPID 0x1ba01477
  38. }
  39. }
  40. swj_newdap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
  41. dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
  42. if {[using_jtag]} {
  43. jtag newtap $_CHIPNAME bs -irlen 5
  44. }
  45. set _TARGETNAME $_CHIPNAME.cpu
  46. target create $_TARGETNAME cortex_m -endian $_ENDIAN -dap $_CHIPNAME.dap
  47. $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
  48. # flash size will be probed
  49. set _FLASHNAME $_CHIPNAME.flash
  50. flash bank $_FLASHNAME stm32f1x 0x08000000 $_FLASH_SIZE 0 0 $_TARGETNAME
  51. # JTAG speed should be <= F_CPU/6. F_CPU after reset is 8MHz, so use F_JTAG = 1MHz
  52. adapter speed 1000
  53. adapter srst delay 100
  54. if {[using_jtag]} {
  55. jtag_ntrst_delay 100
  56. }
  57. reset_config srst_nogate
  58. if {![using_hla]} {
  59. # if srst is not fitted use SYSRESETREQ to
  60. # perform a soft reset
  61. cortex_m reset_config sysresetreq
  62. }
  63. $_TARGETNAME configure -event examine-end {
  64. # DBGMCU_CR |= DBG_WWDG_STOP | DBG_IWDG_STOP |
  65. # DBG_STANDBY | DBG_STOP | DBG_SLEEP
  66. mmw 0xE0042004 0x00000307 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"