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.
 
 
 
 
 
 

111 lines
2.9 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 [format "%s.cpu" $_CHIPNAME]
  28. target create $_TARGETNAME arm7tdmi -endian $_ENDIAN -chain-position $_TARGETNAME -variant arm7tdmi-s_r4
  29. # at CPU CLK <32kHz this must be disabled
  30. arm7_9 fast_memory_access enable
  31. arm7_9 dcc_downloads enable
  32. flash bank ecosflash 0x01000000 0x200000 2 2 0 ecos/at91eb40a.elf
  33. $_TARGETNAME configure -event reset-init {
  34. # Set up chip selects & timings
  35. mww 0xFFE00000 0x0100273D
  36. mww 0xFFE00004 0x08002125
  37. mww 0xFFEe0008 0x02002125
  38. mww 0xFFE0000c 0x03002125
  39. mww 0xFFE00010 0x40000000
  40. mww 0xFFE00014 0x50000000
  41. mww 0xFFE00018 0x60000000
  42. mww 0xFFE0001c 0x70000000
  43. mww 0xFFE00020 0x00000001
  44. mww 0xFFE00024 0x00000000
  45. # remap
  46. mww 0xFFFFF124 0xFFFFFFFF
  47. mww 0xffff0010 0x100
  48. mww 0xffff0034 0x100
  49. #disable 16x5x UART interrupts
  50. mww 0x08020004 0
  51. }
  52. # required for usable performance. Used for lots of
  53. # other things than flash programming.
  54. $_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x00020000 -work-area-size 0x20000 -work-area-backup 0
  55. jtag_khz 16000
  56. proc production_info {} {
  57. return "Serial number is official MAC number. Format XXXXXXXXXXXX"
  58. }
  59. # There is no return value from this procedure. If it is
  60. # successful it does not throw an exception
  61. #
  62. # Progress messages are output via puts
  63. proc production {firmwarefile serialnumber} {
  64. if {[string length $serialnumber]!=12} {
  65. puts "Invalid serial number"
  66. return
  67. }
  68. puts "Power cycling target"
  69. power off
  70. sleep 3000
  71. power on
  72. sleep 1000
  73. reset init
  74. flash write_image erase $firmwarefile 0x1000000 bin
  75. verify_image $firmwarefile 0x1000000 bin
  76. # Big endian... weee!!!!
  77. puts "Setting MAC number to $serialnumber"
  78. flash fillw [expr 0x1030000-0x8] "0x[string range $serialnumber 2 3][string range $serialnumber 0 1]0000" 1
  79. 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
  80. puts "Production successful"
  81. }
  82. proc production_test {} {
  83. power on
  84. sleep 1000
  85. target_request debugmsgs enable
  86. reset run
  87. sleep 25000
  88. target_request debugmsgs disable
  89. return "See IP address above..."
  90. }