You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

90 lines
2.1 KiB

  1. # script for stm32f1x family
  2. #
  3. # stm32 devices support both JTAG and SWD transports.
  4. #
  5. source [find target/swj-dp.tcl]
  6. source [find mem_helper.tcl]
  7. if { [info exists CHIPNAME] } {
  8. set _CHIPNAME $CHIPNAME
  9. } else {
  10. set _CHIPNAME stm32f1x
  11. }
  12. set _ENDIAN little
  13. # Work-area is a space in RAM used for flash programming
  14. # By default use 4kB (as found on some STM32F100s)
  15. if { [info exists WORKAREASIZE] } {
  16. set _WORKAREASIZE $WORKAREASIZE
  17. } else {
  18. set _WORKAREASIZE 0x1000
  19. }
  20. # Allow overriding the Flash bank size
  21. if { [info exists FLASH_SIZE] } {
  22. set _FLASH_SIZE $FLASH_SIZE
  23. } else {
  24. # autodetect size
  25. set _FLASH_SIZE 0
  26. }
  27. #jtag scan chain
  28. if { [info exists CPUTAPID] } {
  29. set _CPUTAPID $CPUTAPID
  30. } else {
  31. if { [using_jtag] } {
  32. # See STM Document RM0008 Section 26.6.3
  33. set _CPUTAPID 0x3ba00477
  34. } {
  35. # this is the SW-DP tap id not the jtag tap id
  36. set _CPUTAPID 0x1ba01477
  37. }
  38. }
  39. swj_newdap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
  40. dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
  41. if {[using_jtag]} {
  42. jtag newtap $_CHIPNAME bs -irlen 5
  43. }
  44. set _TARGETNAME $_CHIPNAME.cpu
  45. target create $_TARGETNAME cortex_m -endian $_ENDIAN -dap $_CHIPNAME.dap
  46. $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
  47. # flash size will be probed
  48. set _FLASHNAME $_CHIPNAME.flash
  49. flash bank $_FLASHNAME stm32f1x 0x08000000 $_FLASH_SIZE 0 0 $_TARGETNAME
  50. # JTAG speed should be <= F_CPU/6. F_CPU after reset is 8MHz, so use F_JTAG = 1MHz
  51. adapter speed 1000
  52. adapter srst delay 100
  53. if {[using_jtag]} {
  54. jtag_ntrst_delay 100
  55. }
  56. reset_config srst_nogate
  57. if {![using_hla]} {
  58. # if srst is not fitted use SYSRESETREQ to
  59. # perform a soft reset
  60. cortex_m reset_config sysresetreq
  61. }
  62. $_TARGETNAME configure -event examine-end {
  63. # DBGMCU_CR |= DBG_WWDG_STOP | DBG_IWDG_STOP |
  64. # DBG_STANDBY | DBG_STOP | DBG_SLEEP
  65. mmw 0xE0042004 0x00000307 0
  66. }
  67. $_TARGETNAME configure -event trace-config {
  68. # Set TRACE_IOEN; TRACE_MODE is set to async; when using sync
  69. # change this value accordingly to configure trace pins
  70. # assignment
  71. mmw 0xE0042004 0x00000020 0
  72. }