Nios® II Software Developer Handbook

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

5.4.3.6.1. Configuring a BSP for Debugging

You individually specify the optimization and debug level for the application and BSP projects, and any user library projects you might be using. You use the BSP settings hal.make.bsp_cflags_debug and hal.make.bsp_cflags_optimization to specify the optimization and debug level in a BSP, as shown in the “Configuring a BSP for Debugging” example.
Example 4–7. Configuring a BSP for Debugging
nios2-bsp hal my_bsp --set hal.make.bsp_cflags_debug -g \
 --set hal.make.bsp_cflags_optimization -O0r

Alternatively, you can manipulate the BSP settings with a Tcl script.

You can easily copy an existing BSP and modify it to create a different build configuration.

For more information, refer to the “Copying, Moving, or Renaming a BSP” chapter.

To change the optimization and debug level for a user library, use the same procedure as for an application.

Note: Normally you must set the optimization and debug levels the same for the application, the BSP, and all user libraries in a software project. If you mix settings, you cannot debug those components which do not have debug settings. For example, if you compile your BSP with the -O0 flag and without the -g flag, you cannot step into the newlib printf() function.