- Om oss
- Plattformar och lösningar
- Utvecklingsverktyg och arbetsmetodik
Programming the SPI flash memory
2012-03-19Publicerad av Sven-Åke Andersson
After power-on, the FPGA on the Atlys board must be configured (or programmed) before it can perform any functions. The FPGA can be configured in three ways:
- A USB-connected PC can configure the board using the JTAG port any time power is on.
- A configuration file stored in the SPI Flash ROM can be automatically transferred to the FPGA at power-on.
A programming file can be transferred from a USB memory stick attached to the USB HID port.
Both Digilent and Xilinx freely distribute software that can be used to program the FPGA and the SPI ROM. Programming files are stored within the FPGA in SRAM-based memory cells. This data defines the FPGA’s logic functions and circuit connections, and it remains valid until it is erased by removing power or asserting the PROG_B input, or until it is overwritten by a new configuration file.
During FPGA programming, a .bit or .svf file is transferred from the PC directly to the FPGA using the USB-JTAG port. When programming the ROM, a .bit, .bin, or .mcs file is transferred to the ROM in a two-step process. First, the FPGA is programmed with a circuit that can program the SPI ROM, and then data is transferred to the ROM via the FPGA circuit (this complexity is hidden and a simple “program ROM” interface is shown). A programming file stored in the SPI ROM will remain until it is overwritten, regardless of power-cycle events.
Adept and iMPACT USB port
The Adept port is compatible with Xilinx's iMPACT programming software if the Digilent Plug-In for Xilinx Tools is installed on the host PC (download it free from the Digilent website’s software section). The plug-in automatically translates iMPACT-generated JTAG commands into formats compatible with the Digilent USB port, providing a seamless programming experience without leaving the Xilinx tool environment. Once the plug-in is installed, the "third party" programming option can be selected from the iMPACT tools menu, and iMPACT will work as if a Xilinx programming cable were being used. All Xilinx tools (iMPACT, ChipScope, EDK, etc.) can work with the plug-in, and they can be used in conjunction with Adept tools (like the power supply monitor).
For more information about installing the Adept plug-in see the FPGA design from scratch blogg (part 63).
Program the SPI flash
We have already seen how we can configure the FPGA using the Xilinx USB cable and the Xilinx configuration tool iMPACT. Now let's see how we can use the same setup to program the SPI flash memory. We will start by loading the FPGA configuration file to the SPI flash.
Generate a bit file for SPI load
We use the makefile found in the backend/par/run directory to generate the bit file using the command: make orpsoc_spiboot.bit. This command will be executed in the makefile:
bitgen -w -intstyle silent -g StartUpClk:CClk orpsoc.ncd orpsoc_spiboot.bit
Generate the SPI load file
We use the makefile found in the backend/par/run directory to generate the SPI load file using the command: make orpsoc.mcs. This command will be executed in the makefile:
promgen -spi -p mcs -w -o orpsoc.mcs -s 16384 -u 0 orpsoc_spiboot.bit
SPI flash memory on board
The N25Q128 from Numonyx is a 128 Mbit (16Mb x 8) serial Flash memory, with advanced write protection mechanisms. It is accessed by a high speed SPI-compatible bus and features the possibility to work in XIP (“eXecution in Place”) mode. The N25Q128 supports innovative, high-performance quad/dual I/O instructions, these new instructions allow to double or quadruple the transfer bandwidth for read and program operations.
Program the SPI flash
We will use iMPACT and create a new project.
We configure the device using JTAG.
The FPGA is identified and we have the following setup.
To program the SPI flash we right-click the SPI/BPI block and add the flash image file (orpsoc.mcs).
Select the SPI flash device type.
Right-click the SPI flash and select Program.
The flash programming will take for ever (last time it took 3 hours) so you better leave it overnight to finish. Here is the result. The programming was successful but I couldn't get it to work when using Design Suite 14.2 I had to go back to Design Suite 13.4. I am going to find out why it didn't work by asking around. Will let you know as soon as I have answer.
Running iMPACT in batch mode
We can save some time by running iMPACT in batch mode. Here is the command file:
Here is the command to start iMPACT: impact -batch impact.cmd
Removing the JP11 jumper
When configuring the FPGA from the SPI flash the JP11 mode jumper must be removed. We find the jumper below the HID host port (USB contact).
After the SPI ROM has been programmed, it can automatically configure the FPGA at a subsequent power-on or reset event if the JP11 jumper is removed. A programming file stored in the SPI ROM will remain until it is overwritten, regardless of power-cycle events.