Debugging Zephyr Applications

SEGGER OZone is a cross-platform graphical debugger designed for use with SEGGER J-Link debug adapters. This tutorial describes how to use OZone to debug a Zephyr application.

  • Download and install SEGGER OZone on your development host.

  • Modify your project's config file (usually prj.conf) to set the following kernel options:

    CONFIG_SERIAL=n
    CONFIG_PRINTK=y
    CONFIG_RTT_CONSOLE=y
    
  • Build and flash the application you wish to debug to your nRF52-DK.

  • Launch SEGGER Ozone and select "Start with empty project".

  • From the file menu, select Open... and browse to the build directory of your application. Within build, browse to the zephyr subdirectory and select zephyr.elf.

  • From the Tools menu, select J-Link Settings. Set the Target Device to nRF52832_xxAA. Set the Target Interface to SWD and the Speed to 4MHz. Save your settings when prompted. (You may wish to save your settings in your application's directory.)

  • Finally, select Start Debugging (the green power icon). Your program should run to the start of your main function. When you press Run / Continue, you should see the printk output from your application. (Make sure you have displayed the Terminal window (View menu) and that RTT output is enabled (right click in the Terminal window and select Capture RTT).)

  • For single stepping to work, you should disable optimisations in your project configuration. Edit prj.conf and add the setting CONFIG_NO_OPTIMIZATIONS=y.