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.
 
 
 
 
 
 

118 lines
3.0 KiB

  1. #Script for ZY1000
  2. #Atmel ties SRST & TRST together, at which point it makes
  3. #no sense to use TRST, but use TMS instead.
  4. #
  5. #The annoying thing with tying SRST & TRST together is that
  6. #there is no way to halt the CPU *before and during* the
  7. #SRST reset, which means that the CPU will run a number
  8. #of cycles before it can be halted(as much as milliseconds).
  9. reset_config srst_only srst_pulls_trst
  10. if { [info exists CHIPNAME] } {
  11. set _CHIPNAME $CHIPNAME
  12. } else {
  13. set _CHIPNAME zy1000
  14. }
  15. if { [info exists ENDIAN] } {
  16. set _ENDIAN $ENDIAN
  17. } else {
  18. set _ENDIAN little
  19. }
  20. #jtag scan chain
  21. if { [info exists CPUTAPID ] } {
  22. set _CPUTAPID $CPUTAPID
  23. } else {
  24. set _CPUTAPID 0x1f0f0f0f
  25. }
  26. jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
  27. set _TARGETNAME $_CHIPNAME.cpu
  28. target create $_TARGETNAME arm7tdmi -endian $_ENDIAN -chain-position $_TARGETNAME
  29. # at CPU CLK <32kHz this must be disabled
  30. arm7_9 fast_memory_access enable
  31. arm7_9 dcc_downloads enable
  32. set _FLASHNAME $_CHIPNAME.flash
  33. flash bank $_FLASHNAME cfi 0x01000000 0x200000 2 2 $_TARGETNAME
  34. $_TARGETNAME configure -event reset-init {
  35. # Set up chip selects & timings
  36. mww 0xFFE00000 0x0100273D
  37. mww 0xFFE00004 0x08002125
  38. mww 0xFFEe0008 0x02002125
  39. mww 0xFFE0000c 0x03002125
  40. mww 0xFFE00010 0x40000000
  41. mww 0xFFE00014 0x50000000
  42. mww 0xFFE00018 0x60000000
  43. mww 0xFFE0001c 0x70000000
  44. mww 0xFFE00020 0x00000001
  45. mww 0xFFE00024 0x00000000
  46. # remap
  47. mww 0xFFFFF124 0xFFFFFFFF
  48. mww 0xffff0010 0x100
  49. mww 0xffff0034 0x100
  50. #disable 16x5x UART interrupts
  51. mww 0x08020004 0
  52. }
  53. $_TARGETNAME configure -event gdb-attach {
  54. # Without this gdb-attach will first time as probe will fail
  55. reset init
  56. }
  57. # required for usable performance. Used for lots of
  58. # other things than flash programming.
  59. $_TARGETNAME configure -work-area-phys 0x00020000 -work-area-size 0x20000 -work-area-backup 0
  60. adapter_khz 16000
  61. proc production_info {} {
  62. return "Serial number is official MAC number. Format XXXXXXXXXXXX"
  63. }
  64. # There is no return value from this procedure. If it is
  65. # successful it does not throw an exception
  66. #
  67. # Progress messages are output via puts
  68. proc production {firmwarefile serialnumber} {
  69. if {[string length $serialnumber]!=12} {
  70. echo "Invalid serial number"
  71. return
  72. }
  73. echo "Power cycling target"
  74. power off
  75. sleep 3000
  76. power on
  77. sleep 1000
  78. reset init
  79. flash write_image erase $firmwarefile 0x1000000 bin
  80. verify_image $firmwarefile 0x1000000 bin
  81. # Big endian... weee!!!!
  82. echo "Setting MAC number to $serialnumber"
  83. flash fillw [expr 0x1030000-0x8] "0x[string range $serialnumber 2 3][string range $serialnumber 0 1]0000" 1
  84. flash fillw [expr 0x1030000-0x4] "0x[string range $serialnumber 10 11][string range $serialnumber 8 9][string range $serialnumber 6 7][string range $serialnumber 4 5]" 1
  85. echo "Production successful"
  86. }
  87. proc production_test {} {
  88. power on
  89. sleep 1000
  90. target_request debugmsgs enable
  91. reset run
  92. sleep 25000
  93. target_request debugmsgs disable
  94. return "See IP address above..."
  95. }