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.
 
 
 
 
 
 

82 lines
1.8 KiB

  1. # script for stm32l
  2. if { [info exists CHIPNAME] } {
  3. set _CHIPNAME $CHIPNAME
  4. } else {
  5. set _CHIPNAME stm32l
  6. }
  7. if { [info exists ENDIAN] } {
  8. set _ENDIAN $ENDIAN
  9. } else {
  10. set _ENDIAN little
  11. }
  12. # Work-area is a space in RAM used for flash programming
  13. # By default use 14kB
  14. if { [info exists WORKAREASIZE] } {
  15. set _WORKAREASIZE $WORKAREASIZE
  16. } else {
  17. set _WORKAREASIZE 0x3800
  18. }
  19. # JTAG speed should be <= F_CPU/6.
  20. # F_CPU after reset is 2MHz, so use F_JTAG max = 333kHz
  21. adapter_khz 100
  22. adapter_nsrst_delay 100
  23. jtag_ntrst_delay 100
  24. #jtag scan chain
  25. if { [info exists CPUTAPID] } {
  26. set _CPUTAPID $CPUTAPID
  27. } else {
  28. # See STM Document RM0038
  29. # Section 24.6.3
  30. set _CPUTAPID 0x4ba00477
  31. }
  32. jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
  33. if { [info exists BSTAPID] } {
  34. # FIXME this never gets used to override defaults...
  35. set _BSTAPID $BSTAPID
  36. } else {
  37. # See STM Document RM0038
  38. # Section 24.6.2
  39. set _BSTAPID 0x06416041
  40. }
  41. jtag newtap $_CHIPNAME bs -irlen 5 -expected-id $_BSTAPID
  42. set _TARGETNAME $_CHIPNAME.cpu
  43. target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
  44. $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
  45. # flash size will be probed
  46. set _FLASHNAME $_CHIPNAME.flash
  47. flash bank $_FLASHNAME stm32lx 0x08000000 0 0 0 $_TARGETNAME
  48. # if srst is not fitted use SYSRESETREQ to
  49. # perform a soft reset
  50. cortex_m3 reset_config sysresetreq
  51. proc stm32l_enable_HSI {} {
  52. # Enable HSI as clock source
  53. echo "STM32L: Enabling HSI"
  54. # Set HSION in RCC_CR
  55. mww 0x40023800 0x00000101
  56. # Set HSI as SYSCLK
  57. mww 0x40023808 0x00000001
  58. # Increase JTAG speed
  59. adapter_khz 2000
  60. }
  61. $_TARGETNAME configure -event reset-init {
  62. stm32l_enable_HSI
  63. }