kx.cfg 2.6 KB

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