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
2.5 KiB

  1. #
  2. # NXP (former Freescale) Kinetis Kx series devices
  3. # Also used for Cortex-M4 equipped members of KVx and KE1xF series
  4. #
  5. source [find target/swj-dp.tcl]
  6. if { [info exists CHIPNAME] } {
  7. set _CHIPNAME $CHIPNAME
  8. } else {
  9. set _CHIPNAME kx
  10. }
  11. # Work-area is a space in RAM used for flash programming
  12. # By default use 4kB
  13. if { [info exists WORKAREASIZE] } {
  14. set _WORKAREASIZE $WORKAREASIZE
  15. } else {
  16. set _WORKAREASIZE 0x1000
  17. }
  18. if { [info exists CPUTAPID] } {
  19. set _CPUTAPID $CPUTAPID
  20. } else {
  21. if { [using_jtag] } {
  22. set _CPUTAPID 0x4ba00477
  23. } {
  24. set _CPUTAPID 0x2ba01477
  25. }
  26. }
  27. swj_newdap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
  28. dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
  29. set _TARGETNAME $_CHIPNAME.cpu
  30. target create $_TARGETNAME cortex_m -dap $_CHIPNAME.dap
  31. $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
  32. set _FLASHNAME $_CHIPNAME.pflash
  33. flash bank $_FLASHNAME kinetis 0 0 0 0 $_TARGETNAME
  34. kinetis create_banks
  35. adapter speed 1000
  36. reset_config srst_nogate
  37. if {[using_hla]} {
  38. echo ""
  39. echo "!!!!!!!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!!!!!"
  40. echo " Kinetis MCUs have a MDM-AP dedicated mainly to MCU security related functions."
  41. echo " A high level adapter (like a ST-Link) you are currently using cannot access"
  42. echo " the MDM-AP, so commands like 'mdm mass_erase' are not available in your"
  43. echo " configuration. Also security locked state of the device will not be reported."
  44. echo " Expect problems connecting to a blank device without boot ROM."
  45. echo ""
  46. echo " Be very careful as you can lock the device though there is no way to unlock"
  47. echo " it without mass erase. Don't set write protection on the first block."
  48. echo "!!!!!!!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!!!!!"
  49. echo ""
  50. } else {
  51. # Detect secured MCU or boot lock-up in RESET/WDOG loop
  52. $_TARGETNAME configure -event examine-fail {
  53. kinetis mdm check_security
  54. }
  55. # During RESET/WDOG loop the target is sometimes falsely examined
  56. $_TARGETNAME configure -event examine-end {
  57. kinetis mdm check_security
  58. }
  59. # if srst is not fitted use SYSRESETREQ to
  60. # perform a soft reset
  61. cortex_m reset_config sysresetreq
  62. }
  63. # Disable watchdog not to disturb OpenOCD algorithms running on MCU
  64. # (e.g. armv7m_checksum_memory() in verify_image)
  65. # Flash driver also disables watchdog before FTFA flash programming.
  66. $_TARGETNAME configure -event reset-init {
  67. kinetis disable_wdog
  68. }