stm32f0x.cfg 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # SPDX-License-Identifier: GPL-2.0-or-later
  2. # script for stm32f0x family
  3. #
  4. # stm32 devices support SWD transports only.
  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 stm32f0x
  12. }
  13. set _ENDIAN little
  14. # Work-area is a space in RAM used for flash programming
  15. # By default use 4kB
  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. # See STM Document RM0091
  33. # Section 29.5.3
  34. set _CPUTAPID 0x0bb11477
  35. }
  36. swj_newdap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
  37. dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
  38. set _TARGETNAME $_CHIPNAME.cpu
  39. target create $_TARGETNAME cortex_m -endian $_ENDIAN -dap $_CHIPNAME.dap
  40. $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
  41. # flash size will be probed
  42. set _FLASHNAME $_CHIPNAME.flash
  43. flash bank $_FLASHNAME stm32f1x 0x08000000 $_FLASH_SIZE 0 0 $_TARGETNAME
  44. # adapter speed should be <= F_CPU/6. F_CPU after reset is 8MHz, so use F_JTAG = 1MHz
  45. adapter speed 1000
  46. adapter srst delay 100
  47. reset_config srst_nogate
  48. if {![using_hla]} {
  49. # if srst is not fitted use SYSRESETREQ to
  50. # perform a soft reset
  51. cortex_m reset_config sysresetreq
  52. }
  53. proc stm32f0x_default_reset_start {} {
  54. # Reset clock is HSI (8 MHz)
  55. adapter speed 1000
  56. }
  57. proc stm32f0x_default_examine_end {} {
  58. # Enable debug during low power modes (uses more power)
  59. mmw 0x40015804 0x00000006 0 ;# DBGMCU_CR |= DBG_STANDBY | DBG_STOP
  60. # Stop watchdog counters during halt
  61. mmw 0x40015808 0x00001800 0 ;# DBGMCU_APB1_FZ |= DBG_IWDG_STOP | DBG_WWDG_STOP
  62. }
  63. proc stm32f0x_default_reset_init {} {
  64. # Configure PLL to boost clock to HSI x 6 (48 MHz)
  65. mww 0x40021004 0x00100000 ;# RCC_CFGR = PLLMUL[2]
  66. mmw 0x40021000 0x01000000 0 ;# RCC_CR[31:16] |= PLLON
  67. mww 0x40022000 0x00000011 ;# FLASH_ACR = PRFTBE | LATENCY[0]
  68. sleep 10 ;# Wait for PLL to lock
  69. mmw 0x40021004 0x00000002 0 ;# RCC_CFGR |= SW[1]
  70. # Boost JTAG frequency
  71. adapter speed 8000
  72. }
  73. # Default hooks
  74. $_TARGETNAME configure -event examine-end { stm32f0x_default_examine_end }
  75. $_TARGETNAME configure -event reset-start { stm32f0x_default_reset_start }
  76. $_TARGETNAME configure -event reset-init { stm32f0x_default_reset_init }