16 Oct 2017

FPGAs: Papilio One

One of the first FPGA boards I bought is the Papilio One from Gadget Factory. What I like about the Papilio project is its creator's (Jack Gassett) focus on learning and openness. In addition to Jack's guides and tutorials, a fellow named Mike Field (aka Hamster) wrote a free "Introduction to Spartan FPGA" book based around the Papilio and the LogicStart MegaWing (also from Gadget Factory). Then, along came Álvaro Lopes who created the ZPUino which is a 32-bit Arduino-type soft CPU for the Papilio, complete with Wishbone peripherals and an Arduino-style library and IDE. Also, Make's FPGA book uses the Papilio (among other boards) for some of its projects.

After you've installed Xilinx's ISE, Jack provides a great guide to creating your first VHDL project for the Papilio One. His guide uses a slightly older version of ISE so there are some differences between his guide and what you'll find in ISE 14.7, but nothing that can't be figured out. Generating the bitfile completes successfully for me. Now to upload it to the device.

To upload a bitfile to the Papilio One requires the use of the Papilio-Loader program. Clone the project to your local machine. The cmdline version of the loader program (which is all I'm interested in) is found in the papilio-prog subdirectory; therefore move to that location. Since the papilio uses an FTDI chip for serial communications (via USB), you'll need to install the FTDI devel package; on openSUSE its name is "libftdi1-devel". The build system for papilio-prog is the autotools, and it requires pkg-config to be installed (you'll need to figure out how to do that on your system). After the pkg-config package is installed, you'll need to find where it installed its pkg.m4 file. For me this file was installed to /usr/share/aclocal/pkg.m4. With this information I need to edit the top-level Makefile.am to include the path leading up to the pkg.m4 file:

diff --git a/papilio-prog/Makefile.am b/papilio-prog/Makefile.am
index a0ef45a..a31e9c3 100644
--- a/papilio-prog/Makefile.am
+++ b/papilio-prog/Makefile.am

@@ -1,3 +1,4 @@
+ACLOCAL_AMFLAGS = -I /usr/share/aclocal
 bin_PROGRAMS = papilio-prog

 papilio_prog_SOURCES = butterfly.cpp \

I also modified the top-level configure.ac as follows:
diff --git a/papilio-prog/configure.ac b/papilio-prog/configure.ac
index 230add6..35b428a 100644
--- a/papilio-prog/configure.ac
+++ b/papilio-prog/configure.ac

@@ -14,7 +14,7 @@ if test -n "$host_alias" ; then
        AC_DEFINE([WINDOWS], 1, [Cross-compiling for windows])
        LIBS="$LIBS -L. -lftd2xx -static-libgcc -static-libstdc++"
 else
-       PKG_CHECK_MODULES([libftdi1], [libftdi >= 0.19],
+       PKG_CHECK_MODULES([libftdi1], [libftdi1 >= 0.19],
                [CPPFLAGS="$CPPFLAGS $libftdi1_CFLAGS";
                LIBS="$LIBS $libftdi1_LIBS"])
 fi

With those adjustments in place, building was a simple matter of:

$ ./autogen.sh
Generating build system...
$ ./configure
...
$ make
...

Install the resulting papilio-prog to someplace in your $PATH. Plug the Papilio-One into your computer via a USB cable (you only need to connect the USB cable for both communication and power, no need to plug anything into the power barrel jack).

When the papilio is plugged in, you should find an extra USB device on your system:
$ lsusb
...
Bus 001 Device 067: ID 0403:6010 Future Technology Devices International, Ltd FT2232C Dual USB-UART/FIFO IC
...

Then, once you've located your bitfile, you can perform the following to upload it to your device:
# papilio-prog -f Webpack_Quickstart.bit
Using built-in device list
JTAG chainpos: 0 Device IDCODE = 0x41c22093     Desc: XC3S500E
Created from NCD file: Webpack_Quickstart.ncd;UserID=0xFFFFFFFF
Target device: 3s500evq100
Created: 2017/09/30 00:55:28
Bitstream length: 2270208 bits

Uploading "Webpack_Quickstart.bit".

Note that I'm running papilio-prog as root. If I wanted to get fancy I could create a udev rule to set this device's file mode to 0666.

When I plug my papilio into my machine, the following shows up in my system logs:
kernel: usb 1-4.4.4: new full-speed USB device number 69 using xhci_hcd
kernel: usb 1-4.4.4: New USB device found, idVendor=0403, idProduct=6010
kernel: usb 1-4.4.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
kernel: usb 1-4.4.4: Product: Dual RS232
kernel: usb 1-4.4.4: Manufacturer: FTDI
kernel: ftdi_sio 1-4.4.4:1.0: FTDI USB Serial Device converter detected
kernel: usb 1-4.4.4: Detected FT2232C
kernel: usb 1-4.4.4: FTDI USB Serial Device converter now attached to ttyUSB1
kernel: ftdi_sio 1-4.4.4:1.1: FTDI USB Serial Device converter detected
kernel: usb 1-4.4.4: Detected FT2232C
kernel: usb 1-4.4.4: FTDI USB Serial Device converter now attached to ttyUSB2
mtp-probe[24662]: checking bus 1, device 69: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4.4/1-4.4.4"
mtp-probe[24662]: bus: 1, device: 69 was not an MTP device
As you can see, two USB devices get created. The second one can be used for serial logging. The test bitfile provided for the Papilio One demonstrates this feature: Papilio One 500K QuickStart bit file. Opening up a terminal emulator (e.g. minicom) on the second USB device (9600 8N1) will show what is being logged over the serial port.



My final verdict for this board is positive! The Spartan 3E is an older chip, but there is a 500k version (which is a pretty good size for a beginner). The tools install and work on Linux. It's possible to upload bitfiles to the board using Linux. The price of the board is reasonable. Plus, there are lots of learning materials targeted at this board specifically.





No comments: