May 16, 2022

Xilinx Zynq - XC7Z010 - JTAG

I have a Pico RP2040 and intend to use it as a USB to JTAG "dongle" for my ebaz. A Pico rp2040 is surprisingly cheap -- $4, so I bought several (sellers had a limit of 3). Following the article, I do:
git clone https://github.com/kholia/xvc-pico.git
cd xvc-pico/firmware

Now I grab my brand new pico (from Adafruit) along with a micro-USB cable and plug it into my linux system. I see this in the log file:

May 16 10:25:23 trona kernel: usb 3-1: new full-speed USB device number 10 using xhci_hcd
May 16 10:25:23 trona kernel: usb 3-1: New USB device found, idVendor=2e8a, idProduct=0003, bcdDevice= 1.00
May 16 10:25:23 trona kernel: usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
May 16 10:25:23 trona kernel: usb 3-1: Product: RP2 Boot
May 16 10:25:23 trona kernel: usb 3-1: Manufacturer: Raspberry Pi
May 16 10:25:23 trona kernel: usb-storage 3-1:1.0: USB Mass Storage device detected
May 16 10:25:24 trona kernel: scsi 10:0:0:0: Direct-Access     RPI      RP2              2    PQ: 0 ANSI: 2
May 16 10:25:24 trona kernel: sd 10:0:0:0: [sdd] 262144 512-byte logical blocks: (134 MB/128 MiB)
May 16 10:25:24 trona kernel: sd 10:0:0:0: [sdd] Write Protect is off
May 16 10:25:24 trona kernel: sdd: sdd1
No need to hold down the boot button. My desktop pops up a new icon "RP1-RP2". I click on this, it mounts the drive, and I am ready for more as follows:
cd xvc-pico/firmware
cp dirtyJtag.uf2 /run/media/tom/RPI-RP2
sync
Just doing the copy seems to have launched it. Now in my logs I see:
May 16 10:29:49 trona kernel: usb 3-1: USB disconnect, device number 11
May 16 10:29:49 trona kernel: usb 3-1: new full-speed USB device number 12 using xhci_hcd
May 16 10:29:50 trona kernel: usb 3-1: New USB device found, idVendor=1209, idProduct=c0ca, bcdDevice= 1.10
May 16 10:29:50 trona kernel: usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
May 16 10:29:50 trona kernel: usb 3-1: Product: NotDirtyJTAG
May 16 10:29:50 trona kernel: usb 3-1: Manufacturer: Dhiru, Jean THOMAS
This persists after an unplug/replug, so I would say my pico is now setup to be an xvc protocol JTAG gadget. That was certainly easy enough.

There is more to be done. In particular a host side daemon needs to be run called "xvcd-pico". There are nice notes on the github page about this, as well as about adding this as a virtual cable to the Vivado "hardware manager".

Daemon process

cd /u1/Projects/EBAZ/xvc-pico/daemon
cmake .
make install
This places the "xvcd-pico" executable in /usr/local/bin

A peek at the code reveals that this runs a TCP service on port 2542.

See also:

Cable and voltages

The Pico runs at 3.3 volts, what about the Zynq? Looking at the schematic, the JTAG signal lines are pulled up to Vcc (3.3 volts) using 4.7K resistors. With the exception of pin 2, which is wired directly to Vcc (so I will not connect this pin). The Ebaz has no connection for the JTAG reset (which they say is optional).

Try it

I have a header soldered onto my EBAZ and a matching connector soldered up to the pico. I connect a USB cable to the pico, power up my EBAZ and:
[tom@trona daemon]$ xvcd-pico
XVCPI is listening now!
This looks promising. I launch Vivado 2021.2. I am going to work up a simple project, calling it ebaz_1. The idea will be simply to turn on the red LED. I have never seen it come on, and it is not on now.

I loaded the board files for the Ebaz. I select boards, and manufacturer "miner.ebang.com.cn" and find the EBAZ4205 Development board. I create a source file "red.v", giving it a single output port, "red". I add the line:

assign red = 0;

Just "red = 0;" is incorrect.

Now I add a constraint file "red.xdc" and put one line in it:

set_property -dict { PACKAGE_PIN W14   IOSTANDARD LVCMOS33 } [get_ports {red}];
set_property -dict { PACKAGE_PIN W13   IOSTANDARD LVCMOS33 } [get_ports {green}];
Now it is "Run Synthesis", "Run Implementation", "Generate Bitsream" and then open Hardware Manager.

Now it is not clear what to do and I fish around quite a bit before I figure it out. Right click on "locahost (0)" and you get a menu. Select "Add Xilinx Virtual Cable". Enter "localhost" in the popup this yields. It already has port 2542 properly selected. This ends up showing:

arm_dap_0 (0)
xc7z010_1 (0)
Click "Program device" and it works!!. The red LED comes on (and the green LED is now out). I have no idea what the PS side of the chip is doing.

I continue on to revise my verilog to also turn on the green LED. And I add a line to the constraint file for the green LED (as shown above).

The final verilog (pretty simple):

module red(
    output red, output green
    );
    assign red = 0;
    assign green = 0;
endmodule
Note that I assign zero values to turn on the LED. The schematic gives no details, but odds are the FPGA is sinking current from the LED, but who knows really.

Once I have the bitstream, I can just click "Program device". And now, both red and green LED come on!.

As a final experiment, I close Vivado and power cycle the Ebaz. Now I restart Vivado and open the "ebaz_1" project. I go straight to "open Hardware Manager". Autoconnect doesn't work, I have to add the Xilinx Virtual Cable every time.

This is a nice accomplishment. 5-17-2022


General notes (background)

One way to get a bitstream into a Zynq FPGA is using JTAG. This in fact might be quite convenient it you wanted to be doing many rapid trial and error type debugging sessions.

But what JTAG can we use along with something like Vivado?

I am not sure that I will rush out and buy a Pi Pico, but this article does discuss the XVC-Pico project where "XVC" stands for Xilinx Virtual Cable, which sounds like something to learn about or at least be aware of. On the other hand, a Pico is only a $4 item, so I ordered 3 of them.

Another approach is the following:

He uses a FT2232H board and performs the hackery above. Given that the Pico is $4 and a FT2232 is $15, it would seem that the Pico is a better solution. However with the FT2232 you do get a dual device, i.e. JTAG and serial terminal via one cable.

Many fancy FPGA development boards have a built in JTAG and serial gizmo via a single USB cable.

Other stuff


Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org