Professional Documents
Culture Documents
Developing Software For The Nios® II Processor Exercise Manual
Developing Software For The Nios® II Processor Exercise Manual
Processor
Exercise Manual
Software Requirements:
Intel® Quartus® Prime Standard Edition Software Version 17.1
Hardware Requirements:
Intel® Cyclone® 10 LP FPGA Evaluation Kit
Use the link below to download the design files for the exercise:
https://www.altera.com/customertraining/webex/N_Sw_Des_Flow/lab.zip
Set Up of Lab Exercises
After downloading the design files for this exercise, you should see the directory called NII_SW_Dev.
You will find two folders in this directory: Solutions and working_dir.
Locate the .sof and .sopcinfo files in the working_dir. These are the hardware files you will need to
program your development board and start to develop your software code in the Nios II Software
Build Tools.
Note: The software folder underneath working_dir is where you will build the software project for
the lab.
Hardware Set Up
Connect the USB cable from the Intel® FPGA Download Cable II port (J17) of the
development board to your PC
2
In this section, you will use the Nios II Software Build Tools for Eclipse to create a software project.
You will then program the FPGA development board with the .sof file provided, download and run the
design on the board.
Part A - Create software project based on the “Hello World” software template
Note:
The software projects are located in the software directory in a typical system.
It is NOT recommended to create the workspace in the same folder as the software
projects. Place it at least one directory up as shown.
If the Nios II Eclipse workbench opens directly, bypassing the Workspace Launcher,
then create this new local workspace inside the Nios II Software Build Tools for
Eclipse by going to File Switch Workspace Other… The dialog box shown above
will appear. Select the indicated path and workspace name as shown.
3. When the tool opens, create a new Nios II Application and BSP from Template by clicking
on the File menu New.
4. When the new project wizard opens, browse to the .sopcinfo file in the working_dir
directory and name the project Lab1a. Then select the Hello World template.
3
5. Click Finish.
6. In the Project Explorer, right-click on Lab1a_bsp and select Nios II BSP Editor… to open
the Nios II BSP Editor.
4
7. In Nios II BSP Editor, expand into Advanced.hal.linker under Settings. Leave all settings
unchecked.
10. Once the build finished, launch the Quartus Prime Programmer from the Nios II menu.
5
Note: You may need to check the Hardware Setup to ensure you are selecting the right
hardware.
14. Close the Quartus Prime Programmer. Do not save changes to the .cdf file.
15. Run the Hello World application on the development board. Right-click on the Lab1a
project, and select Run As Nios II Hardware.
6
16. If the Run Configurations page appears next, click Run.
Note: If the Run button is greyed out, go to Target Connection tab, click Refresh
Connections, verify the appropriate download cable for your board, click Apply and Run.
17. The Nios II Console tab shows the text “Hello from Nios II!”.
7
Part B - Create blank application project. Re-use BSP from Part A
2. Name the project Lab1b and browse to Lab1a_bsp for the BSP location.
3. Click Finish.
4. You should see the following three software projects in the Project Explorer.
5. Add the file Lab1b.c to the Lab1b project by dragging and dropping it
from …\NII_SW_Dev\working_dir\software\src_code folder onto the Lab1b project in
Project Explorer. When the File Operation dialog box opens, select Copy Files and click OK.
8
6. Once the file has been added to the project, right-click on Lab1b and click Build Project.
After the build finished, right-click on the project, go to Run As Nios II Hardware.
7. Observe the program output on the Nios II Console. You should see running LEDs on the
board.
8. Click the red stop button in Nios II Console to disconnect the program.
9
Part C - Create new BSP project and re-associate Lab1b application project to it
1. Select File New Nios II Board Support Package to create a new BSP project.
2. Name the project Lab1b_bsp, and browse to the .sopcinfo file in working_dir directory.
3. Choose Altera HAL as the BSP type, and click Finish.
4. In the Project Explorer, right-click on the Lab1b project, and select Properties.
5. Select the Nios II Application Properties page, and change the BSP project location
to ../Lab1b_bsp, then click OK.
10
6. Use the Nios II BSP Editor to examine and modify the default BSP settings for Lab1b_bsp.
Once the BSP Editor opens, select File Open, then browse to the software
folder …\NII_SW_Dev\working_dir\software\Lab1b_bsp and open the settings.bsp file.
b. Alternatively, you can right-click on Lab1b_bsp, and select Properties. Then choose Nios
II BSP Properties and select BSP Editor…
c. You can also right-click on Lab1b_bsp and select Nios II BSP Editor…
11
7. The BSP Editor opens the Main page by default. From here, observe that stderr, stdin and
stdout are set to jtag_uart.
8. Make sure all settings under Settings.Advanced.hal.linker are unchecked. Click Generate
and Exit.
9. Right-click on Lab1b project and select Build Project. After the build finished, right-click on
the project, go to Run As Nios II Hardware.
10. Observe the program output on the Nios II Console. You should see running LEDs on the
board.
11. Click the red stop button in Nios II Console to disconnect the program.
12
Summary
Every software application project created in the Nios II Software Build Tools requires an associated
BSP (Board Support Package) project. You can create a new BSP every time you create an application
project if you like, or you can re-use existing BSP projects to avoid having to establish new BSP
settings for your application. The choice is yours. You can even change what BSP project a given
application project is associated with to fit your changing project requirements. To help illustrate
these options you performed the following steps in this lab exercise:
Created an application and BSP project pair using a built-in “Hello World” software template,
and ran this project on the development board.
Created a blank application project, associated a pre-existing BSP with it, and added
software code to it. We then ran this on the development board.
Created a new BSP project with new project settings, re-associated an existing software
application project to it, and ran the application on the development board.
13
---------------------------------------------------------------------------------------------
Intel Corporation. All rights reserved.
Intel, the Intel logo, Altera, Arria, Cyclone, Enpirion, MAX, Nios, Quartus and Stratix
words and logos are trademarks of Intel Corporation or its subsidiaries in the U.S.
and/or other countries.
14