{"id":13781187,"url":"https://github.com/mrjimenez/JTAG","last_synced_at":"2025-05-11T14:34:45.456Z","repository":{"id":36262589,"uuid":"40567024","full_name":"mrjimenez/JTAG","owner":"mrjimenez","description":"JTAG library for Arduino","archived":false,"fork":false,"pushed_at":"2025-01-15T21:18:19.000Z","size":139,"stargazers_count":136,"open_issues_count":10,"forks_count":22,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-04-18T21:26:22.853Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://eeandcs.blogspot.com/2015/08/jtagxsvf-library-for-arduino.html","language":"Assembly","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrjimenez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["mrjimenez"]}},"created_at":"2015-08-11T21:53:29.000Z","updated_at":"2025-04-02T10:05:26.000Z","dependencies_parsed_at":"2024-01-15T20:47:23.167Z","dependency_job_id":"bcb7e1f7-e723-4eff-b94b-dda023307878","html_url":"https://github.com/mrjimenez/JTAG","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrjimenez%2FJTAG","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrjimenez%2FJTAG/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrjimenez%2FJTAG/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrjimenez%2FJTAG/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrjimenez","download_url":"https://codeload.github.com/mrjimenez/JTAG/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253580320,"owners_count":21930923,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T18:01:23.757Z","updated_at":"2025-05-11T14:34:45.448Z","avatar_url":"https://github.com/mrjimenez.png","language":"Assembly","funding_links":["https://github.com/sponsors/mrjimenez"],"categories":["Libraries"],"sub_categories":[],"readme":"# The JTAG Library for Arduino\n\nThis library has four interesting things.\n\nFirst, it is a JTAG test access point (TAP) manipulation library. The code\ntries to be processor agnostic as much as possible, so that it can be used in\nthe future in other platforms. JTAG is a powerful interface, there are many\nthings that you can do besides programming devices. For example, you can do\nboundary scan tests, and even debug and take complete control of some hardware.\n\nSecond, it is a XSVF file player. That way, it is possible to program CPLDs and\nFPGAs through the JTAG port.\n\nThird, there is a XSVF disassembler written in python, so that you can learn\nwhat is happening in the XSVF file you are using to program your device.\n\nAnd finally, there is a XSVF assembler, also written in python, so that you can\nrecompile or write your own XSVF programs yourself in a maintainable and\ndocumented way, since the grammar supports comments.\n\nRemember that Arduino compatible devices are usually powered with 5 Volts,\nwhile most CPLDs and FPGAs will use a 3.3 Volts interface. In my original\nproject, I have used 3 voltage dividers for TCK, TMS and TDI. Each divider\nconsisted of one 330 Ohms resistor in series with a 180 Ohms resistor. One leg\nof the 330 Ohms resistor goes to the ground, one leg of the 180 Ohms resistor\ngoes to the Arduino. Where two legs meet, this is where you should connect your\nJTAG cable.\n\nThose seem to be a bit low values for a voltage divider, but consider the fact\nthat you will most likely have around 100 Ohms impedance in your JTAG\nhomemade cable, and higher resistor values will most likely create reflections\non your signals that will ruin the operation of the JTAG TAP.\n\nTDO and VREF can be tied straight to the arduino pins, but I suggest using a\n100 Ohms resistor on TDO, just to be sure to make reflections low. The big\nproblem here is not TDO itself, but the crosstalk that can happen between TDO\nand TCK in your target board. Trust me, I've been there.\n\nUsing VREF is important so that your Arduino knows your JTAG cable it is actually\nconnected to something. Also, VREF could be used to power buffers to convert\nthe Arduino signals to the right voltage level without the resistors I\nmentioned before.\n\nThe pin configuration I used was this:\n\n| Signal | Arduino pin |\n|:-------|:-----------:|\n| TMS    |  8 |\n| TDI    |  9 |\n| TDO    | 10 |\n| TCK    | 11 |\n| VREF   | 12 |\n\n## Before using this software\n\nYou will need:\n\n1. An Arduino compatible board, along with some way to program it (PC with USB\n   and Arduino IDE or some other hardware device).\n\n1. Python with the library pyserial installed.\n\n1. The proper connection, be it a cable or a few loose wire jumpers.\n\n1. A CPLD, FPGA or any other JTAG interface board to connect to. It is worth\n   mentioning that [Dangerous Prototypes](http://dangerousprototypes.com/)\n   has two very interesting CPLD boards. I have personally used a XC2C64A\n   breakout board. They also have a similar breakout board for the XC9572XL.\n\n## Installing the library\n\nThis software has been tested under the Arduino IDE version 1.6.5, but should\nwork fine with version 1.0. The library should be unpacked to the \"libraries\"\ndirectory inside your Arduino \"sketches\" directory.\n\n## Compiling\n\nOne quick suggestion: in order to get the most of the USB bandwidth, it is\npossible to increase the size of the receive buffer of the Arduino. I have also\nchanged the default compiler optimization level. I added a file called\n\"platform.local.txt\" to the folder \"~/arduino-1.6.5/hardware/arduino/avr\" that\nhad the following:\n\n```config\nname=Arduino 256S AVR Boards\nversion=1.6.7\n\n# AVR compile variables\n# ---------------------\n\n# This can be overridden in boards.txt\nbuild.extra_flags=\n\n# These can be overridden in platform.local.txt\ncompiler.c.extra_flags=-DSERIAL_BUFFER_SIZE=256 -DSERIAL_RX_BUFFER_SIZE=256 -O2\ncompiler.c.elf.extra_flags=\ncompiler.S.extra_flags=\ncompiler.cpp.extra_flags=-DSERIAL_BUFFER_SIZE=256 -DSERIAL_RX_BUFFER_SIZE=256 -O2\ncompiler.ar.extra_flags=\ncompiler.objcopy.eep.extra_flags=\ncompiler.elf2hex.extra_flags=\n```\n\nThe best information about the location of the file \"platform.local.txt\" I\nfound was [here](https://github.com/arduino/Arduino/wiki/Boards-Manager-FAQ).\n\nAnother suggestion: if speed is really an issue, instead of using\n\"JTAGPortArduino\", use \"JTAGPortAVR\". Take a look at PlayXSVFJTAVR.{cpp,h}.\nJTAGPortAVR uses the same pin configuration I have mentioned before, but since\nall the pins are on AVR's PORTB, all pins are written at once, so the JTAG port\ncode is more efficient.\n\n## Using it to play XSVF\n\n1. The example sketch \"JTAGTest\" has been used in all my tests. Upload it to\n   your Arduino board. Now you have a XSVF JTAG player.\n2. Inside the folder libraries/JTAG/extras/python, there is a python script\n   called xsvf. It has some command line parameters, but the default ones\n   should be ok. You can use it to send more than one file in a sequence to\n   your board. For example, suppose you are in a command prompt in the\n   libraries/JTAG folder. Then, the following command will send the following\n   four XSVF files to your Arduino board:\n\n```bash\n   ./extras/python/xsvf extras/xsvf/XC2C64A/{idcode.xsvf,blank_check.xsvf,erase.xsvf,VHDL-CPLDIntro3LEDinverse.xsvf}\n```\n\n   Help is available for the command line parameters:\n\n```bash\n   $ ./extras/python/xsvf --help\n   usage: xsvf [-h] [-c {upload,disasm}] [-v] [-p PORT] [-b BAUD]\n                     fileName [fileName ...]\n\n   XSVF file processor.\n\n   positional arguments:\n      fileName              XSVF file names. (type FileType('rb'))\n\n   optional arguments:\n      -h, --help            show this help message and exit\n      -c {upload,disasm}, --command {upload,disasm}\n                           command to execute. (default=upload)\n      -v, --version         show program's version number and exit\n      -p PORT, --port PORT  Serial port device name (default=/dev/ttyACM0)\n      -b BAUD, --baud BAUD  BAUD rate (type int, default=115200)\n\n   Parameters can be in a file, one per line, using @\"file name\"\n```\n\n1. In subfolders of the folder \"extras/xsvf\" you can find several XSVF files\n   that you can use to test your hardware. Notice that you MUST use a XSVF file\n   generated for your particular hardware. You can generate XSVF files with the\n   software \"impact\", which comes with the Xilinx bundle.\n2. A failure in the execution of \"blank_check.xsvf\" means that the CPLD is not\n   blank. The same file should be successful after the execution of\n   \"erase.xsvf\".\n\n## Interesting links\n\n1. [Generating an SVF, XSVF, or STAPL File with Impact](http://www.xilinx.com/support/documentation/sw_manuals/xilinx11/pp_p_process_generate_svf_file.htm)\n2. [Executing XSVF/SVF Files with Impact](http://www.xilinx.com/itp/xilinx10/isehelp/pim_p_executing_xsvf_svf.htm)\n3. [A JTAG/XSVF Library for Arduino](http://eeandcs.blogspot.com.br/2015/08/jtagxsvf-library-for-arduino.html)\n4. [A XSVF Assembler/Disassembler in python](http://eeandcs.blogspot.com.br/2015/09/a-xsvf-assemblerdisassembler-in-python.html)\n5. [SVF on Wikipedia](https://en.wikipedia.org/wiki/Serial_Vector_Format)\n6. [JTAG on Wikipedia](https://en.wikipedia.org/wiki/Joint_Test_Action_Group)\n7. [fpga4fun](http://www.fpga4fun.com/JTAG.html)\n8. [Rohit Dureja's JTAG Simplified](https://rohitdureja.wordpress.com/category/cpldfpga/)\n9. [Nice JTAG TAP Controller State Diagram in SVF](https://de.wikipedia.org/wiki/Datei:JTAG_TAP_Controller_State_Diagram.svg)\n10. YouTube video: [Como programar CPLD Xilinx con Arduino](https://youtu.be/x5eW9H1GoeA)\n\n## Credits\n\nI have used Xilinx [XAPP503 - SVF and XSVF File Formats for Xilinx Devices](http://www.xilinx.com/support/documentation/application_notes/xapp503.pdf),\nappendix B as the reference for XSVF.\n\nThis software is actually a major rewrite of code and ideas inspired on many\nother projects. As far as I could trace it:\n\n1. [Mike Tsao's JTAGWhisperer](https://github.com/sowbug/JTAGWhisperer/).\n\n1. [Ben's XSVF-Player](https://github.com/ben0109/XSVF-Player/).\n\n1. [Clifford Wolf's libxsvf](http://www.clifford.at/libxsvf/). Definitely worth taking a look.\n\n1. [Karl Hans Janke's jtagbang](http://www.khjk.org/log/2013/aug/jtagbang.html).\n\n## About me\n\n[My blog is here](http://eeandcs.blogspot.com.br/).\n\nYou may contact me on github.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrjimenez%2FJTAG","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrjimenez%2FJTAG","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrjimenez%2FJTAG/lists"}