Skip to content

Eclipse and Sloeber

1 - Software requirements

1.1 - Install Eclipse C/C++ IDE

Install the current Eclipse IDE for C/C++ Developers from the Eclipse website. It includes the C/C++ Development Tooling (CDT) required by Sloeber, so an old Eclipse release repository or a separate legacy plug-in is not needed.

Install OpenOCD separately using your operating system's package manager or the OpenOCD project documentation. Make a note of the path to the openocd executable and its scripts directory; these paths are used later in the debug configuration.

1.2 - Install Sloeber (The Arduino Eclipse Plugin)

From the Eclipse main tab, go to “Help > Eclipse Marketplace” and search for Sloeber.
Download the "Sloeber plugin", follow the recommended instructions and restart Eclipse.
By now, the main tab should look like the following: SloeberMenu

1.3 - Install STM32 Cores

Open “Arduino > Preferences”.
In the tree view that pops up, go to “Arduino > Third party index url’s” and add the STM32 support package URL:

https://raw.githubusercontent.com/stm32duino/BoardManagerFiles/main/package_stmicroelectronics_index.json

UrlIndex

Hit “Apply and Close” then re-open the “Arduino > Preferences” menu. The STM32 Core is now available in the “Platforms and Boards” menu.

CoreInstall

Select the latest core version and hit “Apply and Close”.

2 - Programming the boards

Tip

Make sure your board is correctly connected before going any further.

There are multiple options to start a new project.

  • Option A: From the “Arduino” menu, click on “New Sketch”.
  • Option B: Click on the new sketch icon directly from the toolbar.
  • Option C: From the “File > New > Project…”, click on “Arduino New Sketch”.

Regardless of the chosen method, set your “Project name” and the “Location” of your project. Then push the “Next” button. Complete the Arduino required information (board type, port number, and so on) and click “Next”.

Do not forget to select the “Platform folder” corresponding to the STM32 Core version previously installed.

ProjectConfig

Note

If you plan to debug, select “Debug (-g)” from the “Optimize” list, otherwise you will not have debugging symbols.

From there, you can create your own sketch or use pre-configured examples.
In this case, we will try the “Blink” example.
From the “select code” bar, apply “Sample sketch” and then choose “Examples > 01.Basics > Blink” and “Finish”.

BuiltInExamples

Note

As the GCC ARM Toolchain is provided by the STM32 core, you do not have to download it in order to program your board.

Use the “Arduino” menu or the upload button on the toolbar to upload your sketch. If the setup is correct, the LED should blink on your board.

3 - Debugging Arduino Code

First, make sure your board can work with ST-LINK. The debugger support is currently fully tested with the boards supported by the STM32 core. See the Supported boards list.

3.1 Software requirements

Two standard tools are required in order to debug the code:

  • GDB, the GNU Debugger. The STM32 core provides an arm-none-eabi-gdb executable in its toolchain package. Use the executable from the installed toolchain, for example <STM32 core package>/tools/xpack-arm-none-eabi-gcc/<version>/bin/arm-none-eabi-gdb on Linux or the corresponding .exe path on Windows.
  • OpenOCD, installed separately as described in the requirements above.

Important

Make sure these tools are correctly installed on your platform before proceeding any further.

Important

Do not forget to select “Debug (-g)” in the “Optimize” list in the “Arduino Board Selection” of your project, otherwise you will not have debugging symbols.

3.2 Setting up debug configuration

If you are using Sloeber directly, rather than CDT with the plugin, you may not find the “Debug Configurations” menu under “Run”. This is because you are in the Arduino view, where unnecessary menus are hidden. You can switch to the regular C/C++ view or right-click your project in the Arduino view to reach the debug configurations menu.

From the “Run” menu, select “Debug Configurations”. Double-click on “GDB OpenOCD Debugging” to create a new configuration and set the configuration name.

DebugMenu

Move to the “Debugger” tab in order to configure OpenOCD and GDB.

3.2.1 Setting up OpenOCD

  1. First, set the path to the OpenOCD executable installed on your system. Configure the path to the matching scripts directory as well. The executable path can be represented by an Eclipse variable, for example:
${openocd_path}/${openocd_executable}

The “Actual executable” field shows the full executable path.

  1. Set the “GDB port” to 3333, the “Telnet port” to 4444, and the “Tcl port” to 6666.

  2. Finally, set the debugger configuration in the “Config options” field; specify the script path folder and configuration files (.cfg) related to your MCU. In this case, we use a Nucleo F030R8, so the configuration arguments are:

-s "${openocd_path}/../scripts" -f interface/stlink-v2-1.cfg -f target/stm32f0x.cfg

OpenOCD-config

Important

Replace the interface and target configuration files with the versions for the board you are using.

3.2.2 Setting up GDB

In the “Debugger” tab, scroll to the GDB Client setup field.

  • Set the “Executable name” field to the path of the arm-none-eabi-gdb executable by adding ${A.COMPILER.PATH}/arm-none-eabi-gdb.

By now, the “Debugger” tab should look like the following:

DebugConfig

Move to the “Startup” tab, scroll until the “Run/Restart Commands” fields and add:

monitor reset halt
monitor reset init

Then go to the “Common” tab and check “Debug” and “Run” in the “Display in favorites menu”. Finally, click on “Apply” and “Close”.

3.3 Launching a debug session

Launch the debug session from the “Debug” or “Run” button in the toolbar.
If the configuration process runs correctly, you will be able to see the debug capabilities of the chip in the Debug console (number of breakpoints, watchpoints, and so on).

If you are facing problems with messages like binary not found, click on the drop-down menu and then on your configuration instead of clicking directly on the debug icon.

DebugConsole

Now, you can debug your code using the Eclipse debug features, including step-by-step execution, breakpoints, memory inspection, and variable views.

DebugView