Head Tracker v2.1
  • Head Tracker v2.1
    • HeadTracker v2.2
  • Getting Started
    • Hardware Required
    • Software Installation
      • Flashing Firmware
    • Wiring
      • Option 1- Bluetooth
        • Adding a FrSky BT Module
        • Checking Bluetooth Functionality?
      • Option 2 - Wired
        • Pulse Position Modulation (PPM)
          • Trainer Ports
        • Serial Bus (SBUS)
          • Radio Master TX16S Setup
          • FrSky Taranis X9D
      • Option 3 - Bridged
        • Radio Master TX16S Mk2
      • Analog Input
      • Digital Inputs
      • PPM Input
      • PWM Output
      • ELRS Setup
      • Flight Stick
    • Mounting
      • User Designed Cases
    • Structure of the Application
    • IMU, Calibration and Drift
    • Extended Servo Range
  • Settings
    • GUI Setup
      • Tilt / Roll / Pan
      • General
      • Output
      • Input
      • Bluetooth
      • PWM
      • Analog
      • Aux
  • Radio Setup
    • How to Edit Documentation
    • Open/Edge TX
      • Color Screen Radios
      • Black and White Radios
    • Jeti
    • Spektrum
      • NX
      • DX
        • DX18
    • Flysky
    • Frsky - Ethos
  • Videos
    • YouTube
  • Support
    • Discord Chat
    • Issues
    • Development
      • Firmware
        • Debugging
        • Arduino Nano 33 BLE
        • IMU Sensor Chip
      • GUI (Qt6)
      • GUI (Qt5, Depreciated)
      • Git Workflow and Actions
  • Links
    • Download
    • GitHub Page
    • RC Groups Forum
Powered by GitBook
On this page
  • Wiring
  • Be sure to firmly secure the wires on the bottom
  • VSCode Debugging

Was this helpful?

  1. Support
  2. Development
  3. Firmware

Debugging

PreviousFirmwareNextArduino Nano 33 BLE

Last updated 2 years ago

Was this helpful?

This code is getting pretty complicated to be testing with print statements. Since the code runs on a Real time operating system (Zephyr) the processor with be doing a lot of context switches (jumping to different parts of code) it can be difficult to diagnose an issue without a debugger, sometimes even with a debugger :) A print statement badly placed can actually cause a fault. This is why you will need a debugger board if you want to dig deeper into any microcontroller project.

I am using a JLink. The education edition to be more specific which is free for open source use. Full size debugger or mini will work. You should also be able to use a Blackmagic probe and possibly others, but I will not cover that here. The EDU(cation) edition is very well priced and can be found from your favorite electronics suppliers. If you want to work with closed source you cannot use the EDU, and should purchase the full blown version.

Download and install Jlink Software and Docs Package. Follow install guide

Wiring

To wire the debugger to the Nano 33 BLE you will need to solder 5 small wires onto the back of the Nano 33 BLE. Following these guides.

Be sure to firmly secure the wires on the bottom

Highly suggested to use some hot glue and firmly secure the wires that are soldered onto the bottom. I glued the bottom and the bread board at the tie-wrap. Since you are constantly rotating the board around it's pretty easy to rip the small traces off the bottom. This is how my first Nano died.

VSCode Debugging

In platformio.ini set your debug_tool = to the tool you have attached. The git repository code has it pre-set to jlink. Under the Debug tab in VSCode at the top pick - PIO Debug (skip Pre-Debug) this won't try to compile twice every time you start debugging. Compile errors will be listed under debug console tab instead.

To start a debugging session click the green play button beside PIO Debug (skip Pre-Debug) or press F5. Shift-F5 will cancel the session.

On start it always breaks at the code entry point, void main(). Click the Blue play icon to continue execution.

You can add breakpoints wherever you wish, place the red breakpoint dot beside the line to break at.

When the code goes to execute this line it will pause, you can inspect variables, etc.

Pausing the code will cause issues in some locations. The debugger does not pause the hardware timers on the board, since they continue counting strange results can occur. Using the JLink Ozone debugger does work better if your having issues. It's included when you install the software package from above.

If your this far through the guide you probably already have an idea how a debugger works! Happy coding. Be sure to create pull requests and submit your changes. Happy coding!

JLink EDU - Full Size
JLink Edu - Mini
EDU Full Size. IOT shown, but is the same connections as BLE version.
EDU Mini Connection
SEGGER - The Embedded Experts - Downloads - J-Link / J-Trace
Logo