SW4STM32 and SW4Linux fully supports the STM32MP1 asymmetric multicore Cortex/A7+M4 MPUs

   With System Workbench for Linux, Embedded Linux on the STM32MP1 family of MPUs from ST was never as simple to build and maintain, even for newcomers in the Linux world. And, if you install System Workbench for Linux in System Workbench for STM32 you can seamlessly develop and debug asymmetric applications running partly on Linux, partly on the Cortex-M4.
You can get more information from the ac6-tools website and download (registration required) various documents highlighting:

System Workbench for STM32

Converting to C++

I have imported a cube project into the workbench which compiles and runs ok.
When I convert it to C++ I get the following error when I Build All:-

make: *** Test_2 Configuration.elf Error 1 Test_2 Configuration C/C++ Problem

If first the main is renamed to have a .cpp extenstion then the HAL commands are not resolved.

The workbench and cube are the latest versions.

Any help would be appreciated.

How did you do the conversion ? (did you use option 1, below)

1) In Project Explorer right-click on project and then from contex menu choose “Convert to C++” option.

2) Change .project file:
to convert a C project to a C++ project, simply add: org.eclipse.cdt.core.ccnature
just below the line org.eclipse.cdt.core.cnature to the .project file generated by STM32CubeMX.

Let the generated files with the .c extension.
Add your files with the extension .cpp if you write C++ code.
Check the build output, for .cpp files should be invoked g++ compiler and for .c files gcc compiler

I did not try any of above on System Workbench, so I don’t know if works. I used second option on TrueStudio.


The proper way to convert a C project to C++ is to use option 1) above; however, i’m not sure example programs were generated correctly to support automatic conversion and you may have to correct C++-related project settings.

You must at least check that the C++ compile build settings (in project >> Properties >> C/C++ Build >> Settings) are coherent with those from the C Compiler (mainly symbol definitions, include files and libraries).


Option 1 & 2 allow the use of main.cpp but only if I also make the following change to the linker

C/C++Build>settings>MCU G++ Linker>General>
${workspace_loc:/${ProjName}/LinkerScript.ld} change
C:\Users\Richard\Documents\ARM_st\Test_1\SW4STM32\Test_1 Configuration\STM32F401RETx_FLASH.ld

But I can’t generate a class without an error.

I also now get an invalid argument for WritePin(GPIOD,GPIO_PIN_2,1); in the code below.

while (1)

Experimenting I can run main as a cpp file in c mode but as soon as I do it wont resolve the WritePin command above. The class also builds but not if add the #include “stm32f4xx_hal.h”.

I cant see any difference in the build settings - I think I am one small alteration away from succcess but frustration means Atmel is calling!!!! Convert to C++ should mean exactly that.

In fact, not only you should correct the linker script specification (use a relative path, like ..\STM32F746NGHx_FLASH.ld rather than an absolute one), but you also must add linker flags -specs=nosys.specs -specs=nano.specs in C/C++ Build >> Settings >> MCU G++ Linker >> Miscellaneous

Then the project should compile correctly.

These are glitches in C to C++ conversion that will be corrected in a future release.


Hi Bernard
Tried that and it seems better, in as much as I can now generate a class (named beta),

however the line HAL_GPIO_WritePin(GPIOD,GPIO_PIN_2,1); still generates an unresolved error

and placing #include “beta.h” in main.cpp creates, Fatal error: beta.h: No such file or directory.

Your continuing help would be appreciated.



Hi Richard,

The problem is that, if you are compiling C++ code, you must be careful about argument types. In your code you try to call a function having prototype
void HAL_GPIO_WritePin(GPIO_TypeDef* GPIOx, int GPIO_Pin,int PinState);
while the effective function is
void HAL_GPIO_WritePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState);

The second parameter can be converted from int to uint16_t without any problem, especially as it is a constant; however the C++ compiler can’t convert an int to an enum (while the C compiler can). This is one of the few differences between C and C++.

You should then correctly use the enum constants each time a parameter is an enum; for example you should correct your code to read

Regarding the include of beta.h, this is a bit more tricky and is related to th eway CubeMX generates the System Workbench project.

The problem is that main.c is a link to a file located elsewhere, while the beta.h file you’ve created is in the User directory... Thus
#include "beta.h"
when written in main.c will search in the directory where main.c is located (out of the project...) but not where it seems to be, that is in User...

You must then add ${ProjDirPath}/Applications/User to the search path for the compiler, in project >> Properties >> C/C++ General >> Paths and Symbols >> Includes; don’t forget to create the path for all languages and all configurations.

By the way, how did you rename main.c in main.cpp? the straightforward way of doing so will usually not work correctly; the best way is to create a new file, named main.cpp, copy the content of main.c in it then delete main.c.However, in this case, you can’t re-regenerate your project code under CubeMX if ever you have to change pin assignments or device initialization.

I would then advise you to keep main.c in C, just adding a few function calls in it (in the user code areas so they will not be overwritten by CubeMX) and code them in C++.


Hi Bernard
I had renamed main.c to main.ccp using the simple right click Rename option, at this point it didn’t work.
By following your method of creating a new main.cpp file and copying the contents it did.

Two further questions:-
1 With reference to the HAL, are there any other differences between C & C++ that you can easily share?
2 On future releases, will Cube be configured to work directly with C++?

Thank you very much Bernard.