# OpenOCD support

> **TL;DR**
> OS: Windows (MinGW or MinGW-w64) / Linux / macOS
>
>
>
> Required tools: OpenOCD, cross-compiler toolchain
>
>
>
> Build targets: CMake / Makefile / custom build target

If your embedded target supports on-chip debug with [OpenOCD](http://openocd.org/) (Open On-Chip Debugger), use the OpenOCD Download & Run configuration. It works for CMake-based projects, including the case of [STM32CubeMX](embedded-stm32.html), as well as [Makefile projects](makefiles-support.html), and [custom build targets](custom-build-targets.html).

> **Note:**
> You can also set up an OpenOCD  server using an alternative approach to the one described in this article. The [Debug Servers](debug-servers.html) configuration option offers a more convenient way to configure various gdbservers and combine them with build targets.

Procedure: Required tools

All platforms:

1.

[OpenOCD](https://openocd.org/pages/getting-openocd.html)

OpenOCD will be used as a flash probe and remote [gdbserver](https://sourceware.org/gdb/onlinedocs/gdb/Server.html).

In `Settings | Build, Execution, Deployment | Embedded Development`, you can check whether the OpenOCD location was detected correctly and set the path manually if needed.

2.

Toolchain

Your cross-compiler toolchain should be configured in advance.

* For ARM [Cortex-M](https://developer.arm.com/ip-products/processors/cortex-m) and [Cortex-R](https://developer.arm.com/ip-products/processors/cortex-r) MCUs, install [GNU ARM toolchain](https://developer.arm.com/open-source/gnu-toolchain/gnu-rm). After the installation, make sure the toolchain is presented in the system PATH: run `arm-none-eabi-gcc` from the command line, and your system should recognize this command.

* For all other platforms, install the platform-specific toolchain and set up the tools in `Settings | Build, Execution, Deployment | Toolchain` or in your CMake script (take a look at the template [CMakeLists.txt](https://github.com/elmot/clion-embedded-arm/blob/master/resources/xyz/elmot/clion/cubemx/tmpl_CMakeLists.txt)).

* If you are working with an [STM32CubeMX project](embedded-stm32.html), then installing [STM32CubeCLT](https://www.st.com/en/development-tools/stm32cubeclt.html) and [STM32CubeMX](https://www.st.com/en/development-tools/stm32cubemx.html) is a part of the project set up, and STM32CubeMX generates the linker file automatically.

Windows-specific:

* In addition to the tools required for all platforms, install the [ST-LINK/V2 driver](https://www.st.com/content/st_com/en/products/development-tools/software-development-tools/stm32-software-development-tools/stm32-utilities/stsw-link009.html#getsoftware-scroll).

* For GNU ARM Toolchain, use version 2019-q3 (and later) or 2018-q2 (and earlier). See the [issue](https://bugs.launchpad.net/gcc-arm-embedded/+bug/1810274) with 2018-q4.

* Only the MinGW and MinGW-w64 environments are supported ([CPP-15034](https://youtrack.jetbrains.com/issue/CPP-15034)).

Procedure: Create an OpenOCD configuration

1. Go to `Run | Edit Configurations`, click ![](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.add.svg) and select OpenOCD Download & Run from the list of templates.

> **Tip:**
> For STM32CubeMX projects, CLion adds a configuration of this type automatically during project creation.

2. In the settings, you can select the client GDB debugger and board config file, adjust the GDB and Telnet ports, and set up Download/Reset options.

![OpenOCD run/debug configuration](https://resources.jetbrains.com/help/img/idea/2026.2/cl_embed_openocdconfig.png)

3. When setting up the board config file, you can provide the path manually or click Assist and choose from the standard options:

![board configs selection dialog](https://resources.jetbrains.com/help/img/idea/2026.2/cl_embed_bardconfigs.png)

To adjust the board config file to your needs (for example, when you are working with a non-standard device or need to keep several config files), click Copy to Project & Use: the selected file will be copied into your project tree, and you'll be able to open it in the editor and modify as required.

Procedure: Run/debug an OpenOCD configuration

* When you Run![](https://resources.jetbrains.com/help/img/idea/2026.2/app.actions.execute.svg) this configuration, the compiled firmware is downloaded to the target board, and then the chip is reset.

* When you Debug![](https://resources.jetbrains.com/help/img/idea/2026.2/app.actions.startDebugger.svg), the firmware is downloaded, the chip is reset, and then the remote debugger is attached to the MCU.

Now your firmware running on-chip can be debugged using the entire set of CLion debug features, including [Memory view](memory-view.html) and  the [Peripherals](peripheral-view.html) tab showing peripheral registers and bits.

Also, notice the ![MCU reset](https://resources.jetbrains.com/help/img/idea/2026.2/clion-embedded.icons.ResetMcu.png) button on the left-hand bar of the Debugger tool window. When pressed, it sends the [chip reset command](http://openocd.org/doc/html/General-Commands.html) selected in the Reset option of the configuration settings.

![Debugging an embedded project](https://resources.jetbrains.com/help/img/idea/2026.2/cl_embed_debug_example.animated.gif)

## See also

### External Links

[Embedded Development in CLion FAQs](https://intellij-support.jetbrains.com/hc/en-us/articles/4405160320274-Embedded-Development-in-CLion) [CLion for embedded development, part III](https://blog.jetbrains.com/clion/2019/02/clion-2019-1-eap-clion-for-embedded-development-part-iii/) [CLion for embedded development, part II](https://blog.jetbrains.com/clion/2017/12/clion-for-embedded-development-part-ii/) [CLion for embedded development](https://blog.jetbrains.com/clion/2016/06/clion-for-embedded-development/)

