Importing a STCubeMX generated project

Importing an STM32CubeMX generated project under System Workbench for STM32

Generate and import the CubeMX project

Since version 4.7.0, STM32CubeMX can generate code for System Workbench for STM32. However, the integration is not fully done, and we are working on it. For now, you have to follow the instruction from this page to import the project from the generated code.

  1. Create a working directory (myworkspace for example). It will be the common directory between System Workbench and STM32CubeMX.
  2. On STM32CubeMX, go in the settings, Project > Settings ... then enter a "Project Name" (such as myproject). Change the "Project Location" into the location of the previous working directory. The "Toolchain Folder Location" should be myworkspace/myproject. Don't forget to select "SW4STM32" as your "Toolchain / IDE" before generating the code.
  3. Open System Workbench for STM32 using myworkspace as workspace. Your project explorer should not contain the STM32CubeMX generated code as project.
  4. Import the STM32CubeMX generated project as following
    • File >> Import...
    • Choose "Existing Projects into Workspace" from the "General" group
    • Click on "Browse" for the root directory. It should select your workspace by default, if not, enter the workspace location.
    • The projects list is refreshed and should display your project ("myproject Configuration"), select it.
      • Starting with CubeMX-4.13.0, the project is now named simply "myproject"
    • Ensure the option "Copy projects into workspace" is unchecked
    • Click on the"Finish" button.

Now you have a working project; however there is a small potential problem is you use a version of CubeMX prior to 4.13: Your project is called "myproject Configuration", and a name with a space in it is, at least, a burden (especially on Linux but also on Windows).

Rename the generated files (up to CubeMX-4.12.0)

If you still use an old CubeMX version (up to 4.1), to circunvent, at least partially, the project naming problem, you could rename the generated files; this is no more needed since CubeMX-4.13.0 :

  1. Right click on project > Properties
  2. Go to C/C++ Build > Settings > Build Artifact
  3. Suppress " Configuration" from the artifact name (or give it a more significant name)

Do not rename your project
Eclipse seems to break all linked resources pointing to project-relative paths when the project is renamed...

Setting up your project for debug

Then you should have a working project that can be compiled correctly.

However, with CubeMX-4.7.0 or if you do not choose an evaluation board in CubeMX-4.8.0, the generated project do not include a board description with full debug connection information: it's missing the debug probe and debug link information. You thus can't debug as simply as usually.

If you try to debug your code using project >> Debug as >> Ac6 STM32 C/C++ Application..., the first time, you will get a dialog asking you the debugging characteristics of your board:


You can then either select an existing board or create a new one.

You can also create a debug configuration and provide the debug configuration manually:

  1. Debug As > Debug Configurations...
  2. Create an new Ac6 STM32 Debugging configuration
  3. Choose your project and executable (if needed)
  4. Select the Debugger tab
  5. If there is a "NO SCRIPT FOUND" red error message (most surely currently), select the "Manual spec" redio button and provide the debug configuration by:
    • Selecting the debug device (ST-LinkV2 or V2-1 depending on your board)
    • Selecting the debug interface (usually SWD)
  6. Then you can start the debugger

Another solution is to create a debug configuration then select the appropriate debug script manually by

  1. Debug As > Debug Configurations...
  2. Create an new Ac6 STM32 Debugging configuration
  3. Choose your project and executable (if needed)
  4. Select the Debugger tab
  5. If there is a "NO SCRIPT FOUND" red error message (most surely currently), select the "Use local script" redio button. Provide a debug script by one of these three means:
    1. Browse to your System Workbench install directory, then plugins\fr.ac6.mcu.debug_1.1.0.201503121050\resources\openocd\scripts\board and look for the script for your board (you may find also some st-specific scripts in st_board). This is usually the way to use for a standard ST board (eval, disco or nucleo)
    2. Manually search for a close board in the directory above then manually copy it to your project main directory, then browse to it and select it.This is usually a good way to go for a custom board that is very close to an ST board (often an EVAL board), including the same debug interface
    3. Get a custom board debug script created when creating a project using your custom board (may be a no-firmware project with an empty main program). Copy the System Workbench-generated debug script in your project and browse to it. This is usually convenient if you define your own board, create a custom board in a System Workbench-generated test project and want to reuse it in your STM32CubeMX-generated project (see Create a custom board)
  6. Once your configuration is working, you can launch it by using the small "bug" button in the top toolbar (either click it directly or use the small arrow on its right to see the last valid debug configurations used).

In all cases you will find a debug script in your project directory; for some complex boards, you may have to edit it or re-create it like in the last solution above.