openFPGALoader icon indicating copy to clipboard operation
openFPGALoader copied to clipboard

Which USB<->JTAG interface is the easiest/best/preferred to implement?

Open harbaum opened this issue 5 months ago • 3 comments

I am working with the Tang Nano 20k. This doesn't use a real ft2232 but instead runs some emulation of the ft2232 on a bl616 risc-v CPU. Now this chip is pretty powerful and i'd like to use it for other purposes as well. So I need to replace its firmware which can easily be done. The Tang Nano 20k even has the "Update" button for this purpose. But doing so makes the board loose its ability to load the FPGA.

Sipeed (the maker of the Tang Nano 20k) will not allow to distribute the source code of the ft2232 emulation, so it's not possible to include this functionality into some custom extended firmware for the Tang Nano 20k. One solution is to restore the original firmware whenever the FPGA (or its flash) is to be updated and then flash the custom firmware again afterwards. This works but is a pain to use ...

What I am now searching for is a replacement solution for the FPGA-loader part inside the BL616 MCU on the Tang Nano 20k. I don't like the ft2232 emulation that much as it re-uses the FTDI USB vendor ID and potentially violates FTDIs rights.

So here's my question: What is the USB/JTAG protocol that you guys think is the one to implement? There is e.g. a CDC ACM example for the BL616 CPU and all the JTAG pins are also accessible. But I'd need something in between these two parts. Which protocol should one implement on top of CDC ACM (or anything else, but CDC ACM seems to be a good choice) to be able to use openFPGAloader to upload code to the Tang Nano 20k?

I am doing this under Linux. But if openFPGAloader would use CDC ACM (as opposed to libusb directly), then this should imho work nicely under other OSs as well without the need to use tools like Zadig under Windows oder give special libusb permissions under Linux.

For context: I am using this in my MiSTeryNano project (https://github.com/harbaum/MiSTeryNano). This implements an Atari ST in the FPGA and I am currently running support functions (USB host for keyboard and mice, file system handling for the SD card etc) on a seperate BL616 MCU. But I'd like to use the on-board MCU instead.

harbaum avatar Jan 18 '24 07:01 harbaum

CDC ACM is for emulate serial interface no? My first idea is dirtyJTAG but this protocol is slower than ftdi.

trabucayre avatar Jan 18 '24 07:01 trabucayre

Yes, CDC ACM emulates a serial interface. The advantage is that it's a USB standard protocol and doesn't need any special drivers. It'll give you a COM port under windows and a /dev/ttyACM under Linux. And MacOS also has a standard way to deal with it.

Speed is imho no issue.

harbaum avatar Jan 18 '24 07:01 harbaum

DirtyJTAG is a vendor class device and also seems to use a custom protocol on USB side and would require libusb (and zadig on windows) etc. While this is not a no-go I think it would be more end-user friendly to use something that runs over a regular COM/tty.

harbaum avatar Jan 18 '24 07:01 harbaum