Embedded Design Handbook

ID 683689
Date 8/28/2023
Public
Document Table of Contents

6.2.3.6. Debugging the Nios II Software Running in On-Chip Flash

After programming the .pof file into the On-chip flash, power cycle the board to ensure successful Nios® II system boot up.
  1. Open the Nios® II Software Build Tools for Eclipse from Tools menu.
  2. To set a breakpoint, double click the space beside each c programming code as shown below.
    Figure 252. Step 2 Illustration

    The build tool selects either hardware breakpoint or software breakpoint automatically based on the setting in BSP. Hardware breakpoint is used because the code is in On-chip flash. Only four hardware breakpoints can be used as based on parameter set in the Nios® II IP.

  3. Right click on the application project, then click on Debug As>Debug Configuration.
  4. Under Project tab, select the correct project name if you have more than one project.
    Figure 253. Step 4 Illustration
  5. Under Target Connection tab, ensure that the Intel® FPGA Download Cable II is detected for connection. Select Start processor and Reset the selected target system options. Un-select Download ELF to selected target system, as the Nios® II processor is booting from on-chip flash, therefore downloading ELF is not required.
    Figure 254. Step 5 Illustration
  6. Under Debugger tab, you can choose to either stop the execution of the program at main or not.
    Figure 255. Step 6 Illustration
    Note: If you are using one of the hardware breakpoint, this option is enabled.
  7. Click on Debug. Click Yes when you are asked to switch to debug perspective. And the Nios® II Debug window is opened.
    Figure 256. Step 7 Illustration

    The execution of the program is stopped at the main. The small arrow beside the code indicates the execution of the program stop at that line of program.

  8. Use the different icons from the toolbar:
    • Resume icon: to continue the execution of the program. The execution of the program stops at the next breakpoint set in the program.
    • Step into or Step over icon: to debug the program line by line.
    • Terminate icon: to stop the debugging process
    Figure 257. Step 8 Illustration
  9. You can view the variables, breakpoints, register values and memory as shown below.
    Figure 258. Step 9 Illustration
  10. Nios® II console displays all the messages from printf() function during program execution.
    Figure 259. Step 10 Illustration
  11. Nios® II Software Build Tools for Eclipse reports an error if more than four set hardware breakpoints are inserted in the program.
    Figure 260. Step 11 Illustration