The following will walk you through building and debugging a Nios V software project using Eclipse Embedded CDT with
OpenOCD. These instructions assume that the users have generated a working Nios V processor hardware design file in their targeted board. In addition, the Board Support Package (BSP) and Application project are generated using the BSP Editor and Nios V Command-Line Utilities (niosv-bsp & niosv-app).
GNU RISC-V Embedded GCC
Download the GNU RISC-V Embedded GCC package (version 10.2.0-1.2 or later) based on your platform OS from the following link. Extract the download into any directory, such as C:/NiosVTools folder.
Download link :
https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases
CMake
Download the CMake package for binary distributions (version 3.14.10 or later) based on your platform OS from the following link. Extract the download into any directory, such as C:/NiosVTools folder.
Download link :
https://cmake.org/download/
If you are a Windows user, download the xPack Windows Build Tools package (version 4.2.1-2 or later) from the following link. Extract the download into any directory, such as C:/NiosVTools folder.
Download link :
https://github.com/xpack-dev-tools/windows-build-tools-xpack/releases/
Eclipse IDE for Embedded C/C++ Developers
Download the Eclipse IDE for your platform OS from the following link. Select the latest release with
R package, and find
Eclipse IDE for Embedded C/C++ Developers. Extract download into directory of your liking.
Download link :
https://www.eclipse.org/downloads/packages/release
Run Eclipse IDE
To run Eclipse, select Eclipse-installation-directory\eclipse\eclipse.exe. Select/Create a workspace folder and
Launch.

The Eclipse IDE should appear.
Install cmake4eclipse Plug-in
To install the cmake4eclipse plug-in to your Eclipse IDE. Follow any of the following methods,
Recommended Installation
- Navigate to https://github.com/15knots/cmake4eclipse#installation
- Follow the steps in the Installation section. It will guide the reader to drag an “Install” icon onto the running Eclipse workbench.
- Eclipse will prompt for a restart after this.
If you have issues dragging and dropping the "Install" button into Eclipse, it's possible a proxy is blocking the installation and you may need to manually download the zip and install.
Manual Installation
- Navigate to https://cloudsmith.io/~15knots/repos/p2-zip/packages/
- Install the latest cmake4eclipse zip package.
- In the Eclipse IDE, go to Help → Install New Software….
- On the Install window, click on Add…
- On the Add Repository window, click on Archive and select the downloaded zip package. Click Add.
- Tick the box for CMake package, and untick the box for Contact all update sites during install to find required software. Click Next to continue.
- On the Install Remediation window, select Keep my installation the same and modify the items being installed to be compatible, and click on Next.
- On the Install Details windows, click Finish.
- If the Security Warning window pops up, click Install Anyway.
- When the installation finished and prompted with Software Updates windows, click Restart Now.
Import/Build Nios V Application in Eclipse IDE
Open the Project Explorer View,
Window → Show View → Project Explorer.
Import Nios V application created by niosv-app,
File → New → C/C++ Project. In the dialog, choose
C++ Managed Build.

Point the
Location to your Application project.
Project Name should be same as the folder ("app" in this example). Ignore the warning
Directory with specified name already exists.
Select
CMake driven → Empty Project as the
Project Type. You may need to uncheck
Show project types and toolchains only it they are supported on the platform to display the CMake driven
Empty Project option. Click
Finish to import the Application project.
To modify the project settings, right click on the "app" folder and select
Properties.
If you have
cmake,
riscv-none-embed-*, and
windows-build-tools (Windows users only) in your system/user PATH already, you can skip this step and go to the next section.
In
C/C++ Build → Environment pane, setup your PATH to point to
cmake,
riscv-none-embed-*, and
windows-build-tools (Windows users only) executables. Click
Add.. to add a new PATH variable.
In Windows, the PATH separator is ';' (semicolon) and on Linux it is ':' (colon). Since the variable is
Appended to the already existing variable, prefix the whole "Value" string with a semicolon on Windows and a colon on Linux.
Here is an example "Value" string,
Name |
PATH |
---|
Value (in Windows) |
;C:\NiosVTools\cmake-3.14.10-windows-x86_64\bin;C:\NiosVTools\xpack-riscv-none-embed-gcc-10.2.0-1.2\bin ;C:\NiosVTools\xpack-windows-build-tools-4.2.1-2-win32-x64\xpack-windows-build-tools-4.2.1-2\bin |
Value (in Linux) |
:/mnt/c/NiosVTools/cmake-3.14.10-linux-x86_64/bin:/mnt/c/NiosVTools/xpack-riscv-none-embed-gcc-10.2.0-1.2/bin |
Set Buildscript Generator to "Unix Makefiles" (For Windows Users)
On Windows the default setting generate
MinGW Makefiles, which may cause issues.
Note:
- For cmake4eclipse version 2.1.4 or older, right-click the Application project, and select Properties.
- For cmake4eclipse version 3.0.0 until latest (3.0.3), navigate to Windows → Preferences.
Go to the
C/C++ Build → Cmake4eclipse → Host OS overrides pane.
In the Windows tab, set the
Buildscript Generator (-G) to
Unix Makefiles. Note that this setting is different "per-Configuration". If you are going to build with Release/etc, you'll have to set the
Buildscript Generator (-G) appropriately for those as well.
Number of Builder (For parallel compilation)
You'll most likely want to set this to
Use optimal jobs since the default is
Use unlimited jobs which may slow down your computer on initial (cold) compilation. Click
Apply and Close.
Build Software
To build the project,
Project → Build All. The Console window will show the status of the build. When the build is complete, the .elf file will be in the
build\Debug folder.
OpenOCD Debug Configuration
Generate OpenOCD Configuration File
First, you will need to generate an
OpenOCD configuration file. This provides the JTAG chain information to
OpenOCD.
Download the .sof with Nios V to the board. From the command line prompt, change directory to your app folder. Run the following command to create the configuration file:
Windows
>C:\intelFPGA_pro\21.3\quartus\bin64\openocd-cfg-gen.exe niosv-m.cfg
Linux
$ path-to/quartus/bin/openocd-cfg-gen niosv-m.cfg
Configuring GDB OpenOCD Debugging
In Eclipse IDE, go to
Run → Debug Configurations..., double click
GDB OpenOCD Debugging to create a new
OpenOCD configuration. Your newly built
app.elf file should already be selected automatically.

Select the
Debugger Pane
Enter the executable path to OpenOCD
- Windows: C:\intelFPGA_pro\21.3\quartus\bin64\openocd.exe
- Linux: $ path-to/quartus/linux64/openocd
Add OpenOCD to use the recently generated niosv-m.cfg file using OpenOCD 's -f flag.Point GDB Client Setup to: riscv-none-embed-gdb Add the following GDB commands
- set arch riscv:rv32
- set can-use-hw-watchpoints 0

Select the
Startup Pane, and disable
Arm semihosting. Click
Debug and confirm
Switching perspective.
OpenOCD Debugging using Eclipse IDE
Note: The initial loading of the program may take a bit. By default, the debugger will break on
main.

To add a breakpoint, right click on the line number and select
Toggle Breakpoint.

To start debugging,
Run → Resume.
For future Debug sessions, you can start the debugger using
Run → Debug History and selecting the debug configuration.
If you have
printf_(s) in your code, you can use _juart-terminal. From the command line prompt, run the following command:
> C:\intelFPGA_pro\21.3\quartus\bin64\juart-terminal
Use CTRL-C to exit the
juart-terminal.
You can spawn a similar
juart-terminal window by going to
Window → Show View → Terminal and then typing in
juart-terminal in the shell (You may need a full path depending your environment variables).