Ozone (NEORV32)
Introduction
Hardware
Software
Build the application
How to debug?
Download
 

Introduction

Here I will show you how to use Ozone to debug a RISC-V application inside a NEORV32 Processor on a DE0-Nano board.

Ozone is a full-featured graphical debugger for embedded applications. With Ozone it is possible to debug any embedded application on C/C++ source and assembly level. Ozone can load applications built with any tool chain / IDE or debug the target's resident application without any source. Ozone includes all well-known debug controls and information windows and makes use of the best performance of J-Link and J-Trace debug probes. The user interface is designed to be used intuitively and is fully configurable. All windows can be moved, re-sized and docked to fit the need of any developer. (Source: SEGGER)

Hardware

For this tutorial a DE0-Nano board with "JTAG Terasic Adapter" was used:

The following wiring is needed:

 DE0-Nano GPIO1  Signal
 Pin 1  TCK
 Pin 2  nTRST
 Pin 4  TDI
 Pin 5  TMS
 Pin 6  TDO
 Pin 7  RESET (not used)
 Pin 12  GND
 Pin 29  +3V3
 Pin 30  GND
 Pin 33  UART0_RXD
 Pin 34  UART0_TXD

The DE0-Nano provides a lot of functionality. But for this tutorial only the following subset was used:

  • Cyclone IV (EP4CE22F17C6)
  • Build in USB Blaster
  • 2 Push-button switches
  • 8 Green User LEDs
  • 50 MHz oscillator

The following options of the NEORV32 was configured:

INT_BOOTLOADER_EN true
ON_CHIP_DEBUGGER_EN   true
MEM_INT_IMEM_SIZE 32KB
MEM_INT_DMEM_SIZE 16KB

At the end of this session, you will find the project for the DE0-Nano board.

Software

At the time of writing this tutorial, the following versions were in use:

  • Quartus II Web Edition 15.0.2.153
  • J-Link EDU (HW: v11 SW: v7.58d)
  • NEORV32 v1.6.4.6
  • Ozone - The J-Link Debugger v3.26a

Build the application

The MSYS2 environment and the RISC-V Windows compiler from Embecosm were used to build the application. For source level debugging it is needed to have debug information available in the ELF file. Therefore the following command must be used:

make USER_FLAGS+="-g3 -gdwarf-4" clean_all exe

Use this command to build the "blink_led" application:

This creates a "main.elf" file with a size of approximately 138 KB. With a size of only about 14 KB, there is no debug informations are available.

How to debug?

First of all make sure that the project for the DE0-Nano board is installed and running.

Connect the J-Link to the PC and to the DE0-Nano (do not forget to power the target) and start Ozone. The next window now looks like this:

(Click inside the picture to expand)

Make sure that the following settings are set. "Device" is set to "RV32" (1), "Register Set" is set to "RV32I" (2), "Instruction Set Extension" is set to "None" (3) and "Peripherals" ist set to the "neorv32.svd" (4) file.

Press "Next" and the window will look like:

Press "Next" again and select the ELF File which you want to debug:

Press "Next":

And press "Finish". Ozone will now look like:

(Click inside the picture to expand)

Here you can see "main.c" from the "blink_led" application. Ozone is prepared to start the debug session now. Press the "Start" button or F5 to start the debugger:

Ozone should look like:

(Click inside the picture to expand)

Now we are ready to debug the application. You can step through the code with the following buttons:

Step Over (F10)

Step Into (F11)

Setting a breakpoint is very easy. Click at the gray dot at the left of the line number:

Click at the gray dot in line 119, a breakpoint will be set:

The red dot is the new breakpoint. You can remove the breakpoint by clicking on it again. Now we want to resume, press the "Resume" button or (F5):

The program will be executed and it will stop at the breakpoint:

Take a look at the "Local Data" window. After nine steps (F10) the windows should look like:

The "cnt" value was incremented and set to 4. But the "GPIO" value should be 3. This can be checked in the "Registers" window:

Magic? No, the register view is available because you has set the neorv32.svd file at the beginning. Even you can double click on the value from "OUTPUT_LO" and can change it in the debugger.

You can stop the debug session by pressing the "Stop" button:

This was now a quick introduction how to use Ozone to debug your RISC-V application.

Download

Quartus de0n-neorv32-blinky_20211212 project, for the DE0-Nano board (5.75 MB)