wiki:howto/SPI_Flash_Config

Version 1 (modified by murphpo, 12 years ago) (diff)

--

WARP v3: SPI Flash

Programming the SPI Flash

The SPI flash is programmed via iMPACT. Programming the SPI flash requires two steps- generating the PROM file and writing the PROM file to the flash.

The PROM programming file (.mcs file) can be generated via the iMPACT GUI or with the promgen command.

To generate the PROM programming file via the iMPACT GUI:

  1. Open iMPACT and start the Create PROM File flow
  2. In the PROM File Formatter window:
    1. Set Storage Target to SPI Flash -> Configure Single FPGA
    2. Click the first green arrow
    3. Set Storage Device to 128M
    4. Click Add Storage Device, then click the second green arrow
    5. Change the Output File Name and Output File Location to your preferred path
    6. Set File Format to MCS and Add Non-Configuration Data Files to No
    7. Click OK
  3. Click OK in the Add Device dialog box
  4. Select your desired FPGA configuration .bit file
  5. Click No when prompted to add another device file, then click OK to continue
  6. Right-click in the iMPACT window and choose Generate File

To generate the PROM programming file via promgen:

  1. Launch a Xilinx command prompt
  2. Navigate to the folder with your .bit file
  3. Run:
    promgen -spi -p mcs -c FF -s 131072 -u 0 <your .bit file name> -o <new .mcs file name>
    

To write the .mcs file to the SPI flash:

  1. Connect a programming cable to the FPGA JTAG connector (J14)
  2. Run iMPACT (if not already open) and start the Boundary Scan flow
  3. Right-click and choose Initialize Chain
  4. Click OK in the Device Programming Properties window
  5. Right-click on the FPGA icon and select Add BPI/SPI Flash
  6. Select your .mcs file
  7. The Select Attached SPI/BPI window will show. Choose SPI PROM model M25P128, data width 1.
  8. Right-click on the Flash icon (not the FPGA icon) and choose Program
  9. Confirm Design-Specific Erase Before Programming is checked
  10. Optionally un-check Verify; verification increases the programming time, and we've never seen a verification error
  11. Click OK

iMPACT will now begin writing your .mcs file to the SPI flash. This process is slow, typically requiring 3+ minutes. Watch the iMPACT GUI and console for status and error messages.

When the programming process completes the FPGA will initiate a configuration cycle from the flash. You will see the green STAT LED glow at half intensity as the FPGA reads the configuration file. The LED will illuminate fully when configuration completes.

Configuration Clock Frequency

The FPGA uses Master SPI mode when loading a bitstream from the SPI flash. In this mode the FPGA generates the configuration clock signal and drives it to the CCLK pin. The CCLK pin is routed to the SPI serial clock input. A faster CCLK will result in a faster configuration process.

The CCLK frequency is specified in the .bit file and is preserved when generating the .mcs file (as described above). You can change the CCLK frequency via the -g ConfigRate bitgen option. We have successfully tested CCLK frequencies up to 33MHz. Higher frequencies will sometimes work. However the FPGA-generated CCLK frequency is specified as ±55%, so higher nominal frequencies may violate the SPI flash max frequency of 54MHz.

To set the CCLK frequency to 33MHz:

  • ISE: open the Generate Programming File properties and change Configuration Options -> ConfigRate to 33.
  • XPS: edit Project -> bitgen.ut, add a line:
    -g ConfigRate:33
    

You will need to re-generate the .mcs file and re-program the SPI flash if you change the CCLK frequency.