Electronic – 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?

Best Answer


  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:

    -f PATH_TO_OPENOCD/scripts/board/stm32f4discovery.cfg 
    -f PATH_TO_OPENOCD/scripts/interface/stlink-v2-1.cfg 
    -c init -c "reset init"

You can then start up GDB and connect to localhost:3333 to interact with the device. For example, here's how to configure Visual Studio Code to debug mbed boards.

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.