SPI is
one of the two most frequently used serial protocols used to communicate
electronic devices inside the same system.
This protocol is commonly used for flash memories.
SPI base:
This plug-in can be used with the following software:
We think it can be used with other software and/or operating systems, but the above
mentioned combinations were verified. You'll find information about how to configure
each software following the above links.
As the FT2232H internally supports SPI, and the above mentioned software can be
configured (or at least fooled ...) this plug-in doesn't need additional electronics.
The configuration depicted in the following schematic was
successfully used in all cases.
There is no standard SPI connector, so we decided to implement this plug-in using
flying leads:
flashrom:
Flashrom is a free software project. It's used to read, write and/or verify flash memories. Its main use is to flash BIOSes. All the test were conducted using Debian GNU/Linux. UrJTAG can be compiled for other UNIXes and Windows, but we didn't verify it. The flashrom version used was v0.9.7+r1782. The test were conducted using Micron M25P10-A and N25Q032A, and Winbond W25X40 memories. Flashrom have support for FT2232H cables, so you just need to select ft2232_spi as programmer (-p option). To select the channel you just need to add ,port=X, i.e. -p ft2232_spi,port=B slects MILK's channel B.
flashrom + patch:
Various FPGAs support configuration from an SPI memory. In the case of the Lattice iCE40 FPGAs this is the most common methode, because it doesn't have a JTAG port. For this reason implementations based on iCE40 usually have an SPI connector for configuration. In this case we have a special use for flashrom. Lamentably this scenario have some important issues that prevent the use of flashrom without any changes, the most relevant are:
- We need to control the FPGA reset line in order to keep it reseted while we configure
the memory.
- The FPGA puts the memory to sleep after reading its configuration.
We must wake-up it.
- It's wise to disable the SPI CS line after configuring the FPGA. This is because the
FPGA will need to control this line in order to read its configuration.
- We could want to read the CDONE state to know if the FPGA properly read the configuration.
This is optional because not all iCE40 board allow it.
To comply with the above mentioned requisites we needed to modify flashrom.
We used version v0.9.9-r1954 as base for the following changes:
patch.
A precompiled version for systems running Debian GNU/Linux on modern
Intel platforms (64 bits) can be downloaded from:
flashrom Debian 64 bits.
After applying this patch flashrom adds a new FT2232H cable named ice40.
Using this cable a MILK cable connected to an SPI base
plug-in can be used to configure SPI memories connected to an iCE40 FPGA.
For this you must indicate -p ft2232_spi:type=ice40,port=A, for
channel A, or -p ft2232_spi:type=ice40,port=B, for channel B.
Important notice: the lines of the plug-in are the ones found in the
"Lattice iCE40" table of the schematic.
The most important differences when compared to a generic SPI case are:
- The CS line is replaced by GPIO0.
- We must control the CRESET_B line using GPIO3.
- We can optionally connect GPIO2 to the CDONE line of the FPGA.
In this case we can add ,cdone=1 to the -p command line
option.
Using this method we configured an iCE40 iCE Blink kit in 6 seconds, much less than 1 minute
6 seconds needed using Lattice Diamond Programmer.
AVRDUDE:
AVRDUDE is a free software project. Its name stands for "AVR Downloader/UploaDEr". It can be used to configure AVR CPUs (i.e. the ATmega commonly used on Arduino) and also do in-circuit debug. All the test were conducted using Debian GNU/Linux. AVRDUDE can be compiled for other UNIXes and Windows, but we didn't verify it. The AVRDUDE version used was v6.1. The test were conducted using ATmega32. MILK can be used with the SPI base plug-in and the connections indicated in the "avrftdi" table of the schematic. For this you just need to select avrftdi as programmer (-c avrftdi). Note that this assumes we are using channel A. To use channel B you must edit /etc/avrdude.conf and change the usbdev value on the id="avrftdi" section.
Lattice Diamond Programmer:
The Lattice Diammond suite is used to develop using Lattice
FPGAs. The tools used to configure the FPGA can be independently downloaded as the
Diamond Programmer.
This tool is available for Linux and Windows, but all the tests were conducted using Linux.
Modern versions of Lattice Diamond Programmer have FT2232H support. You just need to select HW-USB-2B (FTDI)
as cable. The tool have options to select any of the two channels.
Even when this tool can be used to configure various devices, using SPI or JTAG, wll the tests
were conducted using iCE40 boards. So we only verified the cable as SPI.
In this case the connections are the same explained in the flashrom + patch section.
Detailed instructions on how to use the tool can be found in Lattice manuals and in the
development kit manuals.
An interesting detail we found is that this tool takes around one minute to detect the FPGA
and memory, which is quite annoying. We also noticed that the graphic tool isn't the same
than the command line tool. In our case the command line tool failed to detect which clock
can be used for the SPI, falling to a very low clock (15 kHz aprox.) making it unusable.
Lattice technical support couldn't help as to solve this issue.
|