3.9 Debugging the User Application Using SoftConsole

Before debugging, the board and the serial terminal must be set up. For more information about the board and serial terminal setup, see Board Setup and Serial Terminal Emulation Program (PuTTY) Setup.

To debug the application, perform the following steps:

  1. From the Project Explorer, select the MiV_uart_blinky project, and then click the Debug icon from the SoftConsole toolbar, as shown in the following figure.
    Figure 3-29. Debug Icon
  2. In the Create, manage, and run configurations window, double-click GDB OpenOCD Debugging to generate the debug configuration for the MiV_uart_blinky project.
  3. Select the generated MiV_uart_blinky Debug configuration, and click Search Project (if by default not available), as shown in the following figure.
    Figure 3-30. Create, manage, and run configurations Window – Main Tab
  4. Select the MiV_uart_blinky.elf binary from the Program Selection window, and click OK, as shown in the following figure.
    Figure 3-31. MiV_uart_blinky.elf Selection
  5. Go to the Debugger tab, and replace the Config options, Executable name, and Commands as follows:
    • Config Options: --file board/microsemi-riscv.cfg
    • Executable name: ${cross_prefix}gdb${cross_suffix}
    • Commands:
      set mem inaccessible-by-default off
      set arch riscv:rv32
      set $target_riscv = 1
      set remotetimeout 7
      Figure 3-32. Create, manage, and run configurations Window – Debugger Tab
  6. In Debug Configurations > Startup tab, clear the Pre-run/Restart reset check box to halt the program at the main () function, and clear the Enable ARM semihosting check box.
    Figure 3-33. Debug Settings- Startup Tab
  7. Click Apply, and then click Debug, as shown in the preceding figure.

    The Confirm Perspective Switch dialog opens, as shown in the following figure.

    Figure 3-34. Confirm Perspective Switch Dialog Box
  8. Click Yes.

    The debugger halts the execution at the first instruction in the main.c file, as shown in the following figure.

    Figure 3-35. First Instruction in the main.c File
  9. On the SoftConsole toolbar, click the Resume icon to resume the application execution, as shown in the following figure.
    Figure 3-36. Resume Application Execution
  10. The string Hello World! is printed on the serial terminal, as shown in the following figure. Also, LEDs 4, 5, 6, and 7 on the PolarFire Evaluation Board blink.
    Figure 3-37. Hello World in Debug Mode
  11. On the SoftConsole menu, click Run > Suspend to suspend the execution of the application.
  12. Click the Registers tab to view the values of the Mi-V internal registers, as shown in the following figure.
    Figure 3-38. Mi-V Register Values
  13. Click the Variables tab to view the values of variables in the source code, as shown in the following figure.
    Figure 3-39. Variable Values
  14. From the SoftConsole toolbar, use the Step Over option to view the application execution line by line, or use the Step Into option to execute the instructions inside a function. Use the Step Return option to come out the function. You can also add breakpoints in the application source code.
  15. On the SoftConsole toolbar, click Terminate to terminate the debugging of the application.
  16. Close PuTTY and SoftConsole.