Difference between revisions of "Getting Started: Quartus Prime & OpenOCD"

From spiderboard.org
Jump to: navigation, search
(Created page with "== Prerequisites == * Quartus Prime * A SpiderSoM or MX10 with SpiderBase * One of the following: ** OpenOCD (Linux only) ** USB Blaster and Quartus Pr...")
 
(Prerequisites)
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
== Prerequisites ==
 
== Prerequisites ==
  
* Quartus Prime
+
* [http://fpgasoftware.intel.com/?edition=lite Quartus Prime]
* A SpiderSoM or MX10 with SpiderBase
+
* A [[Spiderboard_SoM|SpiderSoM]] or MX10<sup>[[Installing OpenOCD#MX10 Hardware Issue|[note]]]</sup> with [[Spiderboard_Baseboard|SpiderBase]]
 
* One of the following:
 
* One of the following:
** [[Installing OpenOCD|OpenOCD]] (Linux only)
+
** [[Installing OpenOCD|OpenOCD]] (Linux & Windows)
 
** USB Blaster and Quartus Programmer
 
** USB Blaster and Quartus Programmer
 +
* a [https://shop.aries-embedded.de/tools/pmod/302/pmod-8ld Pmod 8LD], to connect to your SpiderBase, in case you want to see the blinking LEDs
  
 
== Quartus Prime Project ==
 
== Quartus Prime Project ==
  
 
<ol>
 
<ol>
<li> Create a new Quartus Prime Project. Name the project ''Example'', this will set our top level entity for later. Choose the correct FPGA, the remaining settings can be left default.
+
 
 +
<li> Create a new Quartus Prime Project. Name the project ''Example'', this will set our top level entity for later.
 +
<li> In ''Family, Device & Board Settings'', select Family "MAX 10" and then search for your FPGA. <br>
 +
 
 +
<div><ul>
 +
<li style="display: inline-block;"> [[File:Quartus-new-project.png|x150px|thumb|Project and Top-Level-Entity are being set.]] </li>
 +
<li style="display: inline-block;"> [[File:quartus-set-device.png|x150px|thumb|In this example the 10M08SAU169C8G FPGA is installed on the module.]] </li>
 +
</ul></div>
 +
 
 
<li> Go to '' Assignments -> Device -> Device and Pin Options -> Voltage'' and select 3.3-V LVCMOS as Default I/O Standard.
 
<li> Go to '' Assignments -> Device -> Device and Pin Options -> Voltage'' and select 3.3-V LVCMOS as Default I/O Standard.
 
<li> If you plan to use OpenOCD, you can enable automatically creating a .svf file. Under ''Device and Pin Options -> Programming Files'' select ''Serial Vector Format File (.svf)''.
 
<li> If you plan to use OpenOCD, you can enable automatically creating a .svf file. Under ''Device and Pin Options -> Programming Files'' select ''Serial Vector Format File (.svf)''.
 +
 +
<div><ul>
 +
<li style="display: inline-block;"> [[File:Quartus-assignment-device.png|x150px|thumb]] </li>
 +
<li style="display: inline-block;"> [[File:Quartus-device-pin-options.png|x150px|thumb]] </li>
 +
<li style="display: inline-block;"> [[File:Quartus-set-voltage.png|x150px|thumb]] </li>
 +
<li style="display: inline-block;"> [[File:Quartus-enable-svf.png|x150px|thumb]] </li>
 +
</ul></div>
 +
 
<li> Open the new file dialog and create a VHDL file.
 
<li> Open the new file dialog and create a VHDL file.
 
<li> Copy and paste the code below.
 
<li> Copy and paste the code below.
 
<li> Save the VHDL file. This file contains our top level entity ''Example'', which matches our project configuration.
 
<li> Save the VHDL file. This file contains our top level entity ''Example'', which matches our project configuration.
<li> Run ''Analysis & Elaboration'' (Processing -> Start -> ...), this will create nodes for pin assignment.
+
<li> Run ''Analysis & Elaboration'', this will create nodes for pin assignment.
 
<li> Open ''Pin Planner'' and edit the location for the existing signals:
 
<li> Open ''Pin Planner'' and edit the location for the existing signals:
 
{| class="wikitable"
 
{| class="wikitable"
Line 39: Line 56:
 
|clk25
 
|clk25
 
|PIN_H4
 
|PIN_H4
|PIN_F9
+
|PIN_J12
 
|}
 
|}
 
For a complete  pin assignment table see [[Pin Assignment Table|here]].
 
For a complete  pin assignment table see [[Pin Assignment Table|here]].
<li> Run ''Compilation'' (Processing -> ...)
+
 
 +
<div><ul>
 +
<li style="display: inline-block;"> [[File:Quartus-bar-elaboration.png|x70px|thumb|Analysis & Elaboration]] </li>
 +
<li style="display: inline-block;"> [[File:Quartus-bar-planner.png|x70px|thumb|Pin Planner]] </li>
 +
<li style="display: inline-block;"> [[File:Quartus-pin-planner.png|x70px|thumb]] </li>
 +
</ul></div>
 +
 
 +
<li> Run ''Compilation''
 +
 
 +
<div><ul>
 +
<li style="display: inline-block;"> [[File:Quartus-bar-compilation.png|x70px|thumb|Compilation]] </li>
 +
</ul></div>
 +
 
 
<li> The subfolder '''output_files''' now contains an Example.sof file, an Example.pof file and if enabled the respective .svf files.<br />
 
<li> The subfolder '''output_files''' now contains an Example.sof file, an Example.pof file and if enabled the respective .svf files.<br />
.sof directly configures the FPGA. This configuration will be lost when the FPGA powers down. <br />
+
.sof (.svf) directly configures the FPGA. This configuration will be lost when the FPGA powers down. <br />
.pof writes to flash memory. When the FPGA powers up, it will load the configuration stored in the flash memory.
+
.pof (_pof.svf) writes to flash memory. When the FPGA powers up, it will load the configuration stored in the flash memory.
 
<li> After programming the FPGA via OpenOCD or USB Blaster the yellow LED on the base should start blinking and the green LED lights up if exactly one user button is pressed.
 
<li> After programming the FPGA via OpenOCD or USB Blaster the yellow LED on the base should start blinking and the green LED lights up if exactly one user button is pressed.
 
</ol>
 
</ol>
Line 93: Line 122:
  
 
== Programming via OpenOCD ==
 
== Programming via OpenOCD ==
# Configuring OpenOCD
 
## Create ''aries-pic.cfg'' and ''altera-10m08s.cfg'' and insert content below.
 
## If you use a different FPGA than 10M08S, you may want to create an other file with updated idcode instead. (see below)
 
# Convert the project files to a .svf File
 
## Automatically
 
### Before running Compilation go to ''Assignments -> Device -> Device and Pin Options -> Programming Files'' and select ''Serial Vector Format File (.svf)''.
 
### The .sof file will be located under '''/output_files/Example.svf''' and the .pof file under '''/output_files/Example_pof.svf'''.
 
## Manually
 
### In Quartus Prime, open the Programmer (Tools -> Programmer).
 
### Choose whether you want to use the .sof or the .pof file.
 
### Open File menu and select ''Create JAM, JBC, SVF or ISC File...''
 
### Choose file format ''Serial Vector Format (.svf)''. Select filename or leave it as default.
 
# Run OpenOCD
 
## Open a terminal window and type:
 
##: $ openocd -f </pathto/aries-pic.cfg> -f </pathto/altera-10m08s.cfg>
 
## A new tap should now be created with the correct idcode.
 
# Connect to OpenOCD via telnet
 
## Open another terminal window and type:
 
##: $ telnet localhost 4444
 
## You should now be connected to your OpenOCD server.
 
## To run the .svf file type:
 
##: svf /<path_to>/Example.svf
 
:: On a 10m02s the .sof file takes about 30 seconds and the .pof file about 3 minutes to program.
 
 
<br />
 
 
'''aries-pic.cfg'''
 
<nowiki>
 
interface usb_blaster
 
usb_blaster_lowlevel_driver ftdi
 
usb_blaster_vid_pid 0x04d8 0xefd0
 
</nowiki>
 
 
'''altera-10m08s.cfg'''
 
<nowiki>
 
jtag newtap 10m08s tap -expected-id 0x31820dd -irlen 10
 
</nowiki>
 
  
If you use a different MAX10 FPGA than the one above, replace name ''10m08s'' and idcode ''0x31820dd'' with values provided below.
+
# If not done already install and configure [[Installing OpenOCD|OpenOCD]].
 +
# Open a terminal and run the command
 +
#: '''$''' mx10spider ''<path/to/file.svf>''
 +
# If your project for example is under ''/opt/quartus_projects/Example'' run either:
 +
#: '''$''' mx10spider /opt/quartus_projects/Example/output_files/Example.svf
 +
#: '''$''' mx10spider /opt/quartus_projects/Example/output_files/Example_pof.svf
 +
#: for programming the ''.sof'' or ''.pof'' file respectively.  
  
{| class="wikitable"
+
<div><ul>
! Name
+
<li style="display: inline-block;"> [[File:terminal_oocd_success.png|thumb|Terminal after successfully running Example.svf]] </li>
! ID Code
+
</ul></div>
!
 
! Name
 
! ID Code
 
|-
 
|10m02s
 
|0x31810dd
 
|
 
|10m02d
 
|0x31010dd
 
|-
 
|10m04s
 
|0x318a0dd
 
|
 
|10m04d
 
|0x310a0dd
 
|-
 
|10m08s
 
|0x31820dd
 
|
 
|10m08d
 
|0x31020dd
 
|-
 
|10m16s
 
|0x31830dd
 
|
 
|10m16d
 
|0x31030dd
 
|-
 
|10m25s
 
|0x31840dd
 
|
 
|10m25d
 
|0x31040dd
 
|-
 
|10m40s
 
|0x318d0dd
 
|
 
|10m40d
 
|0x310d0dd
 
|-
 
|10m50s
 
|0x31850dd
 
|
 
|10m50d
 
|0x31050dd
 
|-
 
|}
 
  
 
== Programming via USB Blaster ==
 
== Programming via USB Blaster ==
Line 188: Line 139:
 
# In Quartus Prime, open the Programmer (Tools -> Programmer).
 
# In Quartus Prime, open the Programmer (Tools -> Programmer).
 
# Choose whether you want to use the .sof or the .pof file.
 
# Choose whether you want to use the .sof or the .pof file.
# Click ''Hardware Setup...'' and select your USB Blaster, if there is none available you may need to run ''jtagconfig''.
+
# Click ''Hardware Setup...'' and select your USB Blaster, if there is none available you may need to start the jtag service.
 
# Press Start
 
# Press Start
 +
 +
<div><ul>
 +
<li style="display: inline-block;"> [[File:spider-with-blaster.png|thumb|x160px|SpiderSoM and SpiderBase with USB-Blaster connected.]] </li>
 +
<li style="display: inline-block;"> [[File:programmer-hwsetup.png|thumb|x170px]] </li>
 +
<li style="display: inline-block;"> [[File:programmer-select-blaster.png|thumb|x170px]] </li>
 +
<li style="display: inline-block;"> [[File:programmer-start-success.png|thumb|x170px]] </li>
 +
</ul></div>

Revision as of 15:49, 5 November 2019

Prerequisites

Quartus Prime Project

  1. Create a new Quartus Prime Project. Name the project Example, this will set our top level entity for later.
  2. In Family, Device & Board Settings, select Family "MAX 10" and then search for your FPGA.
    • Project and Top-Level-Entity are being set.
    • In this example the 10M08SAU169C8G FPGA is installed on the module.
  3. Go to Assignments -> Device -> Device and Pin Options -> Voltage and select 3.3-V LVCMOS as Default I/O Standard.
  4. If you plan to use OpenOCD, you can enable automatically creating a .svf file. Under Device and Pin Options -> Programming Files select Serial Vector Format File (.svf).
    • Quartus-assignment-device.png
    • Quartus-device-pin-options.png
    • Quartus-set-voltage.png
    • Quartus-enable-svf.png
  5. Open the new file dialog and create a VHDL file.
  6. Copy and paste the code below.
  7. Save the VHDL file. This file contains our top level entity Example, which matches our project configuration.
  8. Run Analysis & Elaboration, this will create nodes for pin assignment.
  9. Open Pin Planner and edit the location for the existing signals:
    Node Name SpiderSoM MX 10
    button[1] PIN_A5 PIN_T13
    button[0] PIN_B7 PIN_T7
    led[1] PIN_L2 PIN_T6
    led[0] PIN_L1 PIN_T12
    clk25 PIN_H4 PIN_J12

    For a complete pin assignment table see here.

    • Analysis & Elaboration
    • Pin Planner
    • Quartus-pin-planner.png
  10. Run Compilation
    • Compilation
  11. The subfolder output_files now contains an Example.sof file, an Example.pof file and if enabled the respective .svf files.
    .sof (.svf) directly configures the FPGA. This configuration will be lost when the FPGA powers down.
    .pof (_pof.svf) writes to flash memory. When the FPGA powers up, it will load the configuration stored in the flash memory.
  12. After programming the FPGA via OpenOCD or USB Blaster the yellow LED on the base should start blinking and the green LED lights up if exactly one user button is pressed.


VHDL Code:

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;

entity Example is
	port (
		clk25	: in	std_logic;
		button	: in	std_logic_vector(1 downto 0);
		led	: out	std_logic_vector(1 downto 0)
	);
end entity Example;



architecture archExample of Example is

	signal counter : integer range 1 to 12500000 := 1;
	signal led_yellow : std_logic := '0';

begin

	process (clk25)
	begin
		if (clk25 = '1' and clk25'EVENT) then
			if (counter < 12500000) then
				counter <= counter + 1;
			else
				led_yellow <= not led_yellow;
				counter <= 1;
			end if;
		end if;				
	end process;
	
	led(1) <= led_yellow;
	led(0) <= button(0) xor button(1); 

end architecture archExample;

Programming via OpenOCD

  1. If not done already install and configure OpenOCD.
  2. Open a terminal and run the command
    $ mx10spider <path/to/file.svf>
  3. If your project for example is under /opt/quartus_projects/Example run either:
    $ mx10spider /opt/quartus_projects/Example/output_files/Example.svf
    $ mx10spider /opt/quartus_projects/Example/output_files/Example_pof.svf
    for programming the .sof or .pof file respectively.
  • Terminal after successfully running Example.svf

Programming via USB Blaster

  1. Connect the USB Blaster to the JTAG Header on the SpiderBase.
  2. In Quartus Prime, open the Programmer (Tools -> Programmer).
  3. Choose whether you want to use the .sof or the .pof file.
  4. Click Hardware Setup... and select your USB Blaster, if there is none available you may need to start the jtag service.
  5. Press Start
  • SpiderSoM and SpiderBase with USB-Blaster connected.
  • Programmer-hwsetup.png
  • Programmer-select-blaster.png
  • Programmer-start-success.png