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.

load.py 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/usr/bin/env python
  2. import argparse
  3. import tempfile
  4. import os
  5. import subprocess
  6. header_template = \
  7. """
  8. source [find interface/ftdi/digilent_jtag_smt2.cfg]
  9. adapter_khz 10000
  10. set PL_TAPID 0x03727093
  11. set SMP 1
  12. source {cfg_dir}/zynq-7000.cfg
  13. source {cfg_dir}/xilinx-tcl.cfg
  14. source {cfg_dir}/ps7_init.tcl
  15. reset_config srst_only srst_push_pull
  16. set XC7_JSHUTDOWN 0x0d
  17. set XC7_JPROGRAM 0x0b
  18. set XC7_JSTART 0x0c
  19. set XC7_BYPASS 0x3f
  20. proc xc7_program {{tap}} {{
  21. global XC7_JSHUTDOWN XC7_JPROGRAM XC7_JSTART XC7_BYPASS
  22. irscan $tap $XC7_JSHUTDOWN
  23. irscan $tap $XC7_JPROGRAM
  24. runtest 60000
  25. #JSTART prevents this from working...
  26. #irscan $tap $XC7_JSTART
  27. runtest 2000
  28. irscan $tap $XC7_BYPASS
  29. runtest 2000
  30. }}
  31. pld device virtex2 zynq.tap 1
  32. init
  33. xc7_program zynq.tap
  34. xilinx_ps7_init
  35. # Disable MMU
  36. targets $_TARGETNAME_1
  37. arm mcr 15 0 1 0 0 [expr [arm mrc 15 0 1 0 0] & ~0xd]
  38. targets $_TARGETNAME_0
  39. arm mcr 15 0 1 0 0 [expr [arm mrc 15 0 1 0 0] & ~0xd]
  40. """
  41. def get_argparser():
  42. parser = argparse.ArgumentParser()
  43. parser.add_argument("action", nargs="*",
  44. default="gateware firmware run stop".split())
  45. return parser
  46. def main():
  47. args = get_argparser().parse_args()
  48. with tempfile.NamedTemporaryFile(delete=False) as f:
  49. cfg_file = f.name
  50. cfg_dir = os.path.dirname(os.path.realpath(__file__))
  51. header = header_template.format(cfg_dir=cfg_dir)
  52. f.write(header.encode())
  53. if "firmware" in args.action:
  54. f.write(b"load_image misoc_zedboard_zedboard/software/runtime/runtime.bin 0x100000 bin\n")
  55. if "gateware" in args.action:
  56. f.write(b"pld load 0 misoc_zedboard_zedboard/gateware/top.bit\n")
  57. if "run" in args.action:
  58. f.write(b"targets $_TARGETNAME_1\nreg pc 0x100000\n")
  59. f.write(b"targets $_TARGETNAME_0\nresume 0x100000\n")
  60. if "stop" in args.action:
  61. f.write(b"sleep 2000\n")
  62. f.write(b"targets $_TARGETNAME_0\nhalt\nreg\n")
  63. # f.write(b"targets $_TARGETNAME_1\nhalt\nreg\n")
  64. if not ("noexit" in args.action):
  65. f.write(b"exit\n")
  66. subprocess.run(["openocd", "-f", cfg_file])
  67. if __name__=="__main__":
  68. main()