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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

k20dx32_flash.cfg 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. # FreeScale Kinetis K20 devices with 32kB Flash and 8kB Local On-Chip SRAM,
  2. # Nemuisan's Special for MK20DN32VFT5,MK20DX32VFT5,MK10DN32VFT5,MK10DX32VFT5
  3. # 0.8.0 has no these procs
  4. proc using_jtag {} {
  5. set _TRANSPORT [ transport select ]
  6. expr { [ string first "jtag" $_TRANSPORT ] != -1 }
  7. }
  8. proc using_swd {} {
  9. set _TRANSPORT [ transport select ]
  10. expr { [ string first "swd" $_TRANSPORT ] != -1 }
  11. }
  12. proc using_hla {} {
  13. set _TRANSPORT [ transport select ]
  14. expr { [ string first "hla" $_TRANSPORT ] != -1 }
  15. }
  16. source [find target/swj-dp.tcl]
  17. if { [info exists CHIPNAME] } {
  18. set _CHIPNAME $CHIPNAME
  19. } else {
  20. set _CHIPNAME k20
  21. }
  22. if { [info exists ENDIAN] } {
  23. set _ENDIAN $ENDIAN
  24. } else {
  25. set _ENDIAN little
  26. }
  27. if { [info exists CPUTAPID] } {
  28. set _CPUTAPID $CPUTAPID
  29. } else {
  30. if { [using_jtag] } {
  31. set _CPUTAPID 0x4BA00477
  32. } {
  33. # this is the SW-DP tap id not the jtag tap id
  34. set _CPUTAPID 0x2BA01477
  35. }
  36. }
  37. # Work-area is a space in RAM used for flash programming
  38. # By default use 8kB
  39. if { [info exists WORKAREASIZE] == 0 } {
  40. set _WORKAREASIZE 0x2000
  41. }
  42. # Select "srst_only", Nemuisan said so!
  43. echo "Kinetis MUST need Hardware SRST Control to Recover Secure-State!"
  44. adapter_nsrst_delay 200
  45. reset_config srst_only
  46. swj_newdap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID
  47. set _TARGETNAME $_CHIPNAME.cpu
  48. target create $_TARGETNAME cortex_m -chain-position $_TARGETNAME
  49. # It is important that "kinetis mdm check_security" is called for
  50. # 'examine-end' event and not 'eximine-start'. Calling it in 'examine-start'
  51. # causes "kinetis mdm check_security" to fail the first time openocd
  52. # calls it when it tries to connect after the CPU has been power-cycled.
  53. $_CHIPNAME.cpu configure -event examine-end {
  54. kinetis mdm check_security
  55. # Uncomment when gone into s*ck'n secured state!
  56. # kinetis mdm mass_erase
  57. }
  58. # K20 has minimun 8kB of SRAM and starts at 1FFFF000.
  59. $_TARGETNAME configure -work-area-phys 0x1FFFF000 -work-area-size $_WORKAREASIZE -work-area-backup 0 -rtos auto
  60. # MK20DN32VFT5,MK20DX32VFT5,MK10DN32VFT5,MK10DX32VFT5 has 32kB of flash memory.
  61. flash bank $_CHIPNAME.pflash kinetis 0x00000000 0x8000 0 4 $_TARGETNAME
  62. proc mt_flash {IMGFILE} {
  63. flash write_image erase $IMGFILE
  64. reset run
  65. halt
  66. verify_image $IMGFILE
  67. reset run
  68. shutdown
  69. }
  70. proc mt_flash_bin {IMGFILE OFFSET} {
  71. flash write_image erase $IMGFILE $OFFSET bin
  72. reset run
  73. halt
  74. verify_image $IMGFILE $OFFSET bin
  75. reset run
  76. shutdown
  77. }
  78. proc mt_flash_hex {IMGFILE} {
  79. flash write_image erase $IMGFILE 0 ihex
  80. reset run
  81. halt
  82. verify_image $IMGFILE 0 ihex
  83. reset run
  84. shutdown
  85. }
  86. proc mt_flash_srec {IMGFILE} {
  87. flash write_image erase $IMGFILE 0 s19
  88. reset run
  89. halt
  90. verify_image $IMGFILE 0 s19
  91. reset run
  92. shutdown
  93. }
  94. proc mass_erase {} {
  95. kinetis mdm mass_erase
  96. }
  97. proc eraser {} {
  98. # Verbose procedure confirmed erase routine
  99. flash info 0
  100. # CAUTION! "flash erase_sector 0 0 last" goes into secure state!!!
  101. # USE "mass_erase" command instead of
  102. # flash erase_sector 0 0 last
  103. mass_erase
  104. shutdown
  105. }
  106. #debug_level 3
  107. # HLA doesn't have cortex_m commands
  108. if {![using_hla]} {
  109. # if srst is not fitted use SYSRESETREQ to
  110. # perform a soft reset
  111. cortex_m reset_config sysresetreq
  112. }
  113. adapter_khz 1000
  114. reset_config srst_only srst_nogate connect_assert_srst
  115. gdb_target_description disable
  116. init
  117. reset init