Loading...
 

STM32MP1 support available in SW4STM32

   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 download a short video showcasing this on the ac6-tools website (registration required).

System Workbench for STM32


How to properly convert c ++ project?

I have used the STM32CubeMx(ver 4.15) to generate a source code,and import in SW4STM32(4.5.2).

Now, I want to use class in main.c, so I right-click on project folder -> Convert to C++ and rename “main.c” to “main.cpp”.

I also search all containing text “main.c” and change to “main.pp” in this project, but still show few errors.

How to properly convert c ++ project? cry

Hi,

The “Convert to C++” feature is not fully complete yet. The linker options are not persistent between C and C++.
You have to manually change the following values in Properties > C/C++ Build > Settings > MCU G++ Linker :

In General > Linker Script, change the ld script into the one in your project root directory (the name pattern should be ../STM32FXXXXx_FLASH.ld)
In Miscellanous > Linker Flags, add -specs=nosys.specs -specs=nano.specs

The problem has been reported and these options will be automically changed in the next release.

Hope it works
Kevin.

If you still have errors while building the project, please copy/paste the errors from the “Console” panel.

Most of the displayed error are due to misinterpretation by Eclipse CDT. You can remove then by rebuilding the index (Right click on the project, Index > Rebuild)

On console view, it says that the Error_Handler() does not exists. By default CubeMX should generate it in main.c, maybe something wrong happens in the generation process.

Here the default function :

/**
  * @brief This function is executed in case of error occurrence.
  * @param None
  * @retval None
*/
void Error_Handler(void) {
	/* USER CODE BEGIN Error_Handler */
	/* User can add his own implementation to report the HAL error return state */
	while(1)
	{
	}
	/* USER CODE END Error_Handler */
}

Hi Kevin:

“Error_Handler” function is already in main.cpp.

The following are my steps:
1. STM32CubeMx -> Generate
2. SW4STM32 -> Import -> General -> Exisiting projects into Workspace
3. SW4STM32 -> Windows -> Preferences -> Indexer -> uncheck “Index unused header”
(It will show few errors when I import the new project, so I uncheck this option.)
4. SW4STM32 -> project folder -> right-click -> Convert to C++

Until above, there is no errors and compile success.
-------------------------------------------------------------------------------

5. SW4STM32 -> project folder/Src/main.c -> right-click -> rename “main.c” to “main.cpp”

There show a lot of errors.
Error: http://i.imgur.com/LeOCxY0.jpgQuestion
Console: http://codepad.org/nJUeXLDwQuestion
-------------------------------------------------------------------------------

6. SW4STM32 -> project folder -> right-click -> properties -> C/C++ Build -> Settings
a. MCU G++ Compiler -> Preprocessor -> Defined symbols(-D) -> add
Symbols: http://i.imgur.com/9PkTduH.jpgQuestion

b. MCU G++ Compiler -> Includes Include paths (-I) -> add
../Inc
../Drivers/STM32F4xx_HAL_Driver/Inc
../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy
../Drivers/CMSIS/Include
../Drivers/CMSIS/Device/ST/STM32F4xx/Include

c. MCU G++ Compiler -> General -> Linker Script(-T) -> add
C:\Users\Top\Desktop\STM32\stm32test\myUART\STM32F411RETx_FLASH.ld

d. MCU G++ Compiler -> Miscellaneous -> Linker flags -> add
-specs=nosys.specs -specs=nano.specs

7. SW4STM32 -> Search -> Search -> File Search -> Containing text: -> “main.c”
Search result: http://i.imgur.com/034E7cK.jpgQuestion

8. Modify “main.c” to “main.cpp”
Modify result: http://i.imgur.com/70ywlbA.jpgQuestion

Error: http://i.imgur.com/2q2NMYg.jpgQuestion
Console: http://codepad.org/UvYc9DrDQuestion

I think maybe I loss some steps, how should I do next? cry


I successfully use some c++ code inside a .c file like

std::vector v = {1.2,2.3,4.5,5.6,6.7};
std::stack hp;
hp.push(“1221”);
hp.push(“test”);
hp.push(“stack”)
hp.push(” item”);
const char *data;
while( hp.size() > 0)
{
data = hp.top().c_str();
hp.pop();
USARTSendString(data);
}
USARTSendString(“\n”);

Just by changing ‘gcc’ to ‘g++’ in the project settings AND adding the flag ‘-fpermissive’

I know it is very far to be a good solution but I really need to use some C++ STL features, that’s the quick and dirty solution I found till now with the constraint that I want to keep my code in sync with CubeMX (which does not yet? generate C++ code if I’m right)


It compiles and runs on a F7...

It just makes the Eclipse indexer mad, I had hundreds of ‘unresolved symbols’ while the code compiles and links fine, I tried to find a workaround by googling a long time but nothing works, if you rename the *.c files in *.cpp files, than the indexer is happy but the code does not compile anymore for many other problems, so I just disabled the Eclipse indexer to avoid all the error messages polution but it is frustrating not to have this nice feature...

J.

France

Hi,

The simplest solution is to right-click on your project >> Convert to C++

You just have to check that your install of System Workbench for STM32 is up to date (Help >> Check for Updates....

Of course you must still name your C++ source files with a .cpp extension instead of .c; Standard C source files are still compiled by teh C compiler, only C++ source files are compiled by the C++ compiler.

Bernard (Ac6)