Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save FrancisGuo/20c2c6df8e9f72fe295b785798e2fb41 to your computer and use it in GitHub Desktop.
Save FrancisGuo/20c2c6df8e9f72fe295b785798e2fb41 to your computer and use it in GitHub Desktop.
FT2232 to Digilent JTag for Xilinx FPGAs (ISE/Vivado)

The Digilent JTag uses FT2232, but its configuration EEPROM contains secrete data needed to be recoginzed by Xilinx ISE/Vivado. The following method only works on linux (tested on Ubuntu16.04), but the patched FT2232 doggle also works on Windows.

DONT use FT_Prog on the programmed FT2232 or offical Digilent cables, as it can trash the firmware! The correct eeprom contains secrete data that cannot be handled correctly by FT_Prog.

  1. Install softwares: sudo apt-get install libftdi1
  2. Download the zip file (digilent_eeprom.zip) from the link at the end of this page and unzip it. If the link/file is not accessable, see the following for their content.
  3. Backup the original content of the EEPROM: sudo ftdi_eeprom --read-eeprom flash_digilent.conf
  4. Flash the EEPROM: $ sudo ftdi_eeprom --flash-eeprom flash_digilent.conf

flash_digilent.conf:

vendor_id=0x0403
product_id=0x6010

flash_raw=true

filename="digilent_eeprom.raw"	# Filename, leave empty to skip file writing

hexdump of digilent_eeprom.raw: digilent_eeprom.raw is a binary file!

rikka@rikka-virtual-machine:~$ hexdump -C digilent_eeprom.raw 
00000000  01 01 03 04 10 60 00 07  80 2f 08 00 00 00 9a 12  |.....`.../......|
00000010  ac 34 e0 1a 00 00 00 00  56 00 01 00 c7 92 6a 35  |.4......V.....j5|
00000020  51 01 80 30 4a 74 61 67  53 6d 74 31 00 00 00 00  |Q..0JtagSmt1....|
00000030  00 00 00 00 00 44 69 67  69 6c 65 6e 74 20 4a 54  |.....Digilent JT|
00000040  41 47 2d 53 4d 54 31 00  00 00 00 00 00 00 00 00  |AG-SMT1.........|
00000050  00 00 01 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000060  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000090  00 00 00 00 00 00 00 00  00 00 12 03 44 00 69 00  |............D.i.|
000000a0  67 00 69 00 6c 00 65 00  6e 00 74 00 34 03 44 00  |g.i.l.e.n.t.4.D.|
000000b0  69 00 67 00 69 00 6c 00  65 00 6e 00 74 00 20 00  |i.g.i.l.e.n.t. .|
000000c0  41 00 64 00 65 00 70 00  74 00 20 00 55 00 53 00  |A.d.e.p.t. .U.S.|
000000d0  42 00 20 00 44 00 65 00  76 00 69 00 63 00 65 00  |B. .D.e.v.i.c.e.|
000000e0  1a 03 32 00 31 00 30 00  32 00 30 00 33 00 38 00  |..2.1.0.2.0.3.8.|
000000f0  35 00 39 00 32 00 38 00  39 00 02 03 00 00 7b 6e  |5.9.2.8.9.....{n|
00000100

Patch the second interface to become a UART Compile (gcc xxx.c -o xxx) the following code and run it. It will patch the EEPROM file (digilent_eeprom.raw) and recalculate the checksum. After patching, follow mentioned procedure to flash the patched EEPROM. Now interface A is JTag (Digilent & Xilinx compatible) and interface B is UART which can be used for debug purposes.

Changes: byte0x01: 0x01 -> 0x08, byte0xFE: 0x7B->0xFB, byte0xFF: 0x6E->0x6A

#include <stdio.h>
#include <stdint.h>

int main()
{
    uint8_t buf[256];
    int size = sizeof(buf);
    unsigned short checksum, value;
    FILE * pFile;
    pFile = fopen("digilent_eeprom.raw", "rw+b");
    fread(buf, 1, 256, pFile);
    
    buf[1] = 0x08;

    // calculate checksum
    checksum = 0xAAAA;

    for (int i = 0; i < size/2-1; i++)
    {
        value = buf[i*2];
        value += buf[(i*2)+1] << 8;

        checksum = value^checksum;
        checksum = (checksum << 1) | (checksum >> 15);
    }

    printf("%02x, %02x\n", buf[size-2], buf[size-1]);

    buf[size-2] = checksum & 0xFF;
    buf[size-1] = (checksum >> 8 ) & 0xFF;

    fseek(pFile, 0, SEEK_SET);
    fwrite(buf, 1, 256, pFile);

    fclose(pFile);
    return 0;
}

References:

http://jumpstartengineering.com/embedded_systems/jtag/changing-ft2232h-based-device-parameters/

https://github.com/sprhawk/libftdi/blob/3e078e16d4909044b00de1c610e7904e40a614d9/src/ftdi.c#L3076

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment