# Debugging mbed os 5

I took a look at the mbed OS 5 and the corresponding mbed cli

I created first programs and programmed them via the binary drag and drop to the flash disk provided by the programmer (Using the GCC_ARM compiler, target is a NUCLEO_F429ZI). For serious projects this is not suitable as the device cannot be debugged this way.

As i can read from the mbed documentation the programmer also contains the CMSIS-DAP interface which can be used to program/debug the device.

For evaluation i would like to use a free IDE and use it for debugging. So i would choose Eclipse for this using the C/C++ version of it.

My question now is:

• How does the toolchain for a Windows / Linux machine look like?
• Does a professional toolchain even include the CMSIS-DAP or does one better use JTAG directly?
• What is the flow of programming / debugging over CMSIS-DAP?

TL;DR:

1. Make sure to make a debug build (mbed compile --profile ./mbed-os/tools/profiles/debug.json).
2. Use the OpenOCD Eclipse Plugin.

A bit deeper:

Most mbed boards can be programmed using pyOCD or OpenOCD, these tools start up a GDB server to which GDB can then connect (via arm-none-eabi-gdb). (Almost?) every C++ IDE understands how to use GDB for debugging.

For the F429ZI you use OpenOCD, with the following parameters:

PATH_TO_OPENOCD/bin/openocd
-f PATH_TO_OPENOCD/scripts/board/stm32f4discovery.cfg

If you want semihosting messages (f.e. to debug uVisor), use netcat to connect to pyOCD/OpenOCD via: nc localhost 4444 right after attaching the debugger.