Development and Guides


Debug Arduino Zero Pro using Platformio and Eclipse


I got myself a Arduino Zero Pro ( version) and was really excited to see what I can do with a board the can be debugged. I thought to myself, “this should be easy”. I develop Java code for a living and debugging is a simple as attaching a debugger to a running app, or starting it up from the IDE in debug mode. Then after reading how to get the Arduino to debug I was overwelmed with tools and configurations I had no knowledge of, such as:

  • OpenOCD vs GNU Eclipse OpenOCD
  • GDB (and arm-none-eabi-gdb), GDB server and client
  • vs boards and IDE’s

So to make things more confusing and harder to Google: I use platformio to build my projects, and I use Eclipse C++ as my IDE. Image trying to Google an issue for example “arduino zero platformio gdb eclipse address 0xffffffff out of range”

I’ve found examples of people using Atmel Studio with Visual micro – non of which I could get working by-the-way. It seemed like there was just too many bugs with Atmel Studio / Visual Micro to work with the Adruino Zero Pro. After 2 days of trying different things and wondering if I maybe got a broken board; I one morning figured it out! This morning to be exact, that’s why I’m writing this right now.

This post is a overview of my understanding of the components involved, and how I managed to get them running. vs

You can Google the fully story behind the split, but for what you need to know, there can be a slight difference between a Arduino from and, so make sure you know which version you have when trying to find help with your board. I have the Adruino Zero Pro (I know this because of the box it came in, and it’s printed on the board itself). My setup is done for the .org version, though it might work for .cc too, you just need to use the .cc tools wherever I’m using the .org tools.

Although, this post contradicts what I just said (if you have more details please comment below)

GNU OpenOCD and GNU Eclipse OpenOCD

OpenOCD is an On-Chip Debugger which is software that can interact with debugging hardware such as the EDBG chip found on the Arduino Zero. This means the special instructions that needs to be sent to the hardware is abstracted by OpenOCD. It can also act as a GDB Server, which is a more generic interface debugging clients such as your IDE can interact with. GDB is “the GNU Project debugger, allows you to see what is going on `inside’ another program while it executes — or what another program was doing at the moment it crashed.”

GNU Eclipse OpenOCD is a fork of OpenOCD that works with the Eclipse plugin.

Platformio internally also uses OpenOCD to upload your project to the board, so it’s not something entirely new – it has been there behind the scenes.

Get Started Debugging

Lets dive into the good stuff – getting to the part where we debug an Arduino.

Step 0 – Clean your Arduino Zero

I like to start things off by reflashing the bootloader to make sure the board is in a happy state (especially if you have been messing with the board)

Download the latest version of Arduino IDE – make sure you download from if you have the Arduino Zero Pro that I have, or download the IDE from if you have the Arduino M0 from

Open up the IDE, pick your board Arduino M0 Pro (programming port), port, and programmer Atmel EDBG programming port, and hit “Burn Bootloader”, if all goes well you can continue with the next steps. If you can’t find an option for your board, you might have to use the “board manager” to install the additional boards.

MAKE REALLY SURE you are installing the correct bootloader, it is possible to install the bootloader on the board, but things won’t go well further…

Step 1 – Setup a platformio project for Eclipse

For this you need Eclipse C++ (I’m using Neon.1) and Platformio already installed (I’m using 3.1.0)

  1. Create a new folder “blinkdebug”
  2. Intialize the platformio project
    platformio init --ide eclipse --board mzeropro
    use “zero” if you have the .cc board.
  3. Open an Eclipse workspace in Eclipse C++ and import the project
  4. Add a new source file blink.cpp with the following contents
    #include <Arduino.h>
    int delay_ms = 100;
    int counter = 0;
    void setup() {
      pinMode(13, OUTPUT);
    void loop() {
      digitalWrite(13, HIGH);
      digitalWrite(13, LOW);

Step 3 – Install Eclipse plugin

  1. Open Eclipse C++
  2. Open the Market place
  3.  Install GNU ARM Eclipse (using defaults should be fine)
  4. Restart Eclipse

Step 4 – Configure debug Options

Now that you have all the required software in place, lets start configuring them. According to the GNU ARM Eclipse plugin, most of the default are suppose to “just-work” but it didn’t work for me. Instead of installing GNU Eclipse OpenOCD, I use the OpenOCD that is provided with platformio. This way I know that my project is uploaded and debugged using the same version of OpenOCD and I automatically get OpenOCD updates when platformio updates the packages that ship with it. Also, I couldn’t get GNU Eclipse OpenOCD to work on linux, the version shipped with Platformio worked perfectly. So comparing my steps with the official docs from GNU Eclipse OpenOCD, you’ll see I configure mine differently – it just worked out better for me…

  1. Open Eclipse C++
  2. Click on your project > Click on the Dropdown arrow at debug > Debug Configurations…
  3. Double click on DBG OpenOCD Debugging
  4. It should automatically fill your project name and Application
  5. Configure Debugger
    • First create an variable to hold the location for platformio by clicking on Variables > Edit Variables > New
    • Name: platformio_path
    • Value (for Windows): C:\Users\trojanc\.platformio
    • Value (for Linux): /home/trojanc/.platformio
    • (replace trojanc with your username)
    • Click “Ok” on each dialog until you are back to the debug configuration screen
    • Fill in the rest of the screen as below
    • OpenOCD Executable: ${platformio_path}/packages/tool-openocd/bin/openocd
    • OpenOCD Config Options: -s ${platformio_path}/packages/tool-openocd/share/openocd/scripts -f ${platformio_path}/packages/framework-arduinosam/variants/arduino_zero_org/openocd_scripts/arduino_zero_org.cfg
    • GDB Client Executable: ${platformio_path}/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gdb

Step 5 – Debug the project

  1. Connect your Arduino using the programming port, and hit debug!
  2. The debugger should always stop at the first line in the main.cpp
  3. Add a break point inside the loop function
  4. When it stops, you can inspect the value of counter
  5. Change the value of delay_ms and see the affect
  6. I’m not going to write more on debugging on this post… at least you now (hopefully) got your arduino ready to debug.

Trouble shooting

1st steps

When ever you have weird problems, it usually helps to reload your Adruino’s bootloader using the Arduino IDE (this usually solves my problems). Also make sure you install the correct bootloader using the IDE (or the IDE if you have a Arduino Zero from

Debugging stopping at strange places

If you find that the debugger stops at places you don’t have source code for, and memory offsets that can’t resolve, when it feels like “this is not my arduino running”…

Make sure you are using the correct GNU Eclipse OpenOCD, and that you are using arm-none-eabi-gdb from your platformio install


Leave a Reply

Your email address will not be published. Required fields are marked *