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).

Download and Install Open-source Tools

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/

Windows Build Tools (For Windows Users)

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

eclipse-r-package.JPG

Run Eclipse IDE

To run Eclipse, select Eclipse-installation-directory\eclipse\eclipse.exe. Select/Create a workspace folder and Launch.

5670e2cb2f1ca943653440be1d6a1a59.png

The Eclipse IDE should appear.

5fdf3cb7acc0cf0ca268e1d391a56df3.png

Install cmake4eclipse Plug-in

To install the cmake4eclipse plug-in to your Eclipse IDE. Follow any of the following methods,

  1. Navigate to https://github.com/15knots/cmake4eclipse#installation
  2. Follow the steps in the Installation section. It will guide the reader to drag an “Install” icon onto the running Eclipse workbench.
  3. 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

  1. Navigate to https://cloudsmith.io/~15knots/repos/p2-zip/packages/
  2. Install the latest cmake4eclipse zip package.
  3. In the Eclipse IDE, go to Help → Install New Software….
  4. On the Install window, click on Add…
  5. On the Add Repository window, click on Archive and select the downloaded zip package. Click Add.
  6. 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.
  7. On the Install Remediation window, select Keep my installation the same and modify the items being installed to be compatible, and click on Next.
  8. On the Install Details windows, click Finish.
  9. If the Security Warning window pops up, click Install Anyway.
  10. When the installation finished and prompted with Software Updates windows, click Restart Now.

cmake-method2.png

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.

da9c8fff0857d7042857f85b7239253f.png

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.

7f2c219d40cf787cf83859da242f319d.png

Configure Application Project Settings

Toolchain Path Setup

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 

d6db443952e8e74c0e400c5f19317b68.png

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.

4344ea89f029816d93e92c8161cd70b9.png

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.

044269ecfbe4b0b9e43dbe8ecd849d43.png

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.

1d55839c897d7780c837f4d1d93e9fac.png

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.

6ec284060f51d13170c147e15dad5d79.png

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
debug configuration debugger.png

Select the Startup Pane, and disable Arm semihosting. Click Debug and confirm Switching perspective.

f2c1bb7ede4ef8d55eabef08df40527c.png

OpenOCD Debugging using Eclipse IDE

Note: The initial loading of the program may take a bit. By default, the debugger will break on main.

355e14daa3376c29559a18d4976b3cc7.png

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

9813ec23f7647da27401ae0f869ef3bc.png

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).

© 1999-2024 RocketBoards.org by the contributing authors. All material on this collaboration platform is the property of the contributing authors.

Privacy Policy - Terms Of Use

This website is using cookies. More info. That's Fine