Sunday 8 June 2014

Scripting the process of programming the EPCS on the DE0-Nano


In may post Getting your design to load from the EPCS16 on the DE0-Nano development board I walked through the steps to get my FPGA stored in the EPCS16 flash device. Once you have been through the process a few time it is simple enough to be lodged in your memory.  It will also become a little tiresome. This post looks at how the process can be scripted using a simple .bat file. 

A special folder


I wanted create a self contained folder will all the files needed to program the the EPCS16. This gives me the ability to give the ability to update boards to anyone who is using my board. The de0nano_pmg.bat file contains the short script as follows:

copy onehertzled_top.sof de0nano_pmg.sof
C:\altera\12.1\quartus\bin\quartus_cpf -c de0nano_pmg.cof
C:\altera\12.1\quartus\bin\quartus_pgm -c "USB-Blaster [USB-0]" de0nano_pmg.cdf
pause

The first line copies the oneherztled_top.sof file to create the file de0nano_pmg.sof. The reason I do this is to keep the rest of the script generic and expecting the same file what ever design I want to load. Therefore doing this initial copy means that if I ever wanted to program another SOF file into the EPCS I would only need to edit one line in this batchfile and the whole process would work exactly the same as before.

quartus_cpf

quartus_cpf -c de0nano_pmg.cof

The quartus_cpf application is the Altera program that we will use to convert the SOF file into the JIC file (and MAP file) that is in the correct format to program into the EPCS. Notice that the quartus_cpf contains a COF file as one of its input files.


The first step in creating the COF is to follow the section "creating the right file format" in my previous post  Getting your design to load from the EPCS16 on the DE0-Nano development board. Then clicking on "Save Configuration Setup" shown in the dialog above.


Saving the configuration will create the COF file. This is in fact an XML file that we can edit to change the input file name to de0nano_pmg.sof and the output file name to de0nano_pmg.jic as shown above.

quartus_pmg

quartus_pgm -c "USB-Blaster [USB-0]" de0nano_pmg.cdf

The quartus_pmg application will take the JIC and program it to the EPCS device. 



The "USB-Blaster [USB-0]" is the port that the byte blaster cable is connected to. The port you cable is connected to can be found in the Altera programmer. Also we can use the Altera programmer to generate a CDF file for use in this script.


The CDF file can be edited to specify the path and JIC file to be written into the device.

Running the script


All you need to do is click on the batchfile and program your DE0-nano!

I would love to know what you thought of this post.  Please leave a comment and let me know what you think! - Thanks J

1 comment: