May 10, 2022

FPGA - xc3sprog

There is a nasty problem with setting up the "cable drivers" when I install Xilinx ISE. The ISE does generate a bitstream file (with extension ".bit"). If I just had a tool to download that to my device, I would be in business.
xc3sprog promises to be that tool.

Build it

They tell you up front that it needs usb.h and ftdi.h For some reason, ftdi.h leads to problems on my Fedora system, but we will get to that.
git clone https://github.com/matrix-io/xc3sprog.git
cd xc3sprog
mkdir build
cmake ..
Cmake warns about all kinds of things. Most of those warnings are things the developers should be worrying about and taking care of. Those warnings can be suppressed via -Wno-dev Once that switch is added, we see the show stopper errors:
cmake -Wno-dev ..
-- Checking for module 'libftdi'
--   Package 'libftdi', required by 'virtual:world', not found
-- Could NOT find LIBFTDI (missing: LIBFTDI_LIBRARIES LIBFTDI_INCLUDE_DIR)
-- Checking for module 'libftd2xx'
--   Package 'libftd2xx', required by 'virtual:world', not found
-- Could NOT find LIBFTD2XX (missing: LIBFTD2XX_INCLUDE_DIR)
-- Configuring done
Now this is odd, because I did install the Fedora packages via:
dnf install libftdi-devel
dnf install libftdi-c++-devel
Using locate to look for ftdi.h, we see:
/usr/include/libftdi1/ftdi.h
That does seem like an obscure location for this important file. I'll just note in passing that on Ubuntu, xc3sprog is simply available via apt-get as a standard package.

The trick now is understanding cmake sufficiently to clue it in to the bizarre location of the include file on my Fedora system.

Sniffing around a bit, I find out that ftdi.h is provided by libftdi-devel-1.5-2.fc35.x86_64 Given the package name, I find out that it also provides /usr/lib64/libftdi1.so

So heaven only knows why we have ftdi1 rather than ftdi. As much as I am tempted to make links in /usr/include and /usr/lib64, I resist that temptation and focus on the cmake files that come with xc3sprog. The file to attack seems to be:

Findlibftdi.cmake
I will also note, for the record, that my Fedora system has a directory /usr/lib64/cmake/libftdi1 that has some unknown jive related to cmake.

My hacking on the Findlibftdi.cmake file works (at least cmake runs cleanly now), but when I type make I get:

wiringPi.h: No such file or directory
In the file CMakeLists.txt I find the line:
option(USE_WIRINGPI "Use WiringPi" ON)
I change this to OFF and try again.
Now I do get lots of warnings (these guys don't get any awards for clean programming), but it does seem to build now.

I get brave and type "make install". I need to make /usr/local/bin writeable by tom, then:

-- Install configuration: ""
-- Installing: /usr/local/bin/xc3sprog
-- Installing: /usr/local/bin/xc2c_warp
-- Installing: /usr/local/bin/readdna
-- Installing: /usr/local/bin/bitparse
-- Installing: /usr/local/bin/jedecparse
-- Installing: /usr/local/bin/srecparse
-- Installing: /usr/local/bin/detectchain

Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org