cancel
Showing results for 
Search instead for 
Did you mean: 

How to change folder / link structure of a TouchGFX project generated from IOC in STM32CubeIDE?

HTD
Senior III

Problem:

The project contains core code c files as link in the project. It makes adding new files in common location ridiculously complicated and slow.

(Path: PROJECT/CM7/Core)

Workaround:

I remove the links to core files, I add a links to Core/Src and Core/Inc directories, works as charm. Now I can add files to those directories.

The catch:

Each time IOC file is changed, the IDE creates those links again and they must be manually deleted.

Where IS the folder structure and instructions to create those links?

There is similar problem with TouchGFX files (and the virtual folder structure is even crazier), but saving changes in IOC doesn't rebuild that structure.

6 REPLIES 6
ktrofimo
Senior III

Leave default folder structure as it is, let Cube and TouchGFX manage it as they want. But add a new link to your own code ​folder (and another one for includes, if you want, but it is not necessary)

Like this:

Project

- [Core​]

+ - main.c (link to file)

. . .

- [TouchGFX]

+ - MainView.cpp (link to file)

. . .

- [MyCode] (link to folder)

+​ - mycode.c

. . .

@ktrofimo​ you need to post as a 'Code snippet' for the formatting to work; eg,

0693W00000NrFyOQAV.pnghttps://community.st.com/s/question/0D53W00001ZaNnSSAV/how-to-conditionally-select-between-pin-configurations-at-compile-time

0693W000008xsqBQAQ.png

That's what I tried to do in the first place, however, the compiler tried to compile the same files twice. That's the reason I deleted the original links. It's weird, because physically the files are not duplicated. Just in one virtual directory I had links to files, in another - the link was to physical directory. BTW, I've just launched TouchGFX designer and it removed all my C++ files from the Cube project. They are still on the disk, but the IDE links are broken.

I checked the build scripts, and as I expected, they contain physical paths, not the links. I don't quite understand how it works.

@Adam �?yskawa​ "launched TouchGFX designer and it removed all my C++ files from the Cube project"

Does TouchGFX support C++ ?

It is written in C++​

Nikos Mich.
Associate III

How to create a SMT32cubeIDE project with TouchGFX functionality that has similar folder structure to a touchGFX project created in STM32cubeIDE from scratch:

1.   Create a dummy project from TouchGFX designer for your discovery board. Put in the GUI just a box. Generate code.Then, close the TouchGFX designer.

2.   Somewhere in your PC create a Folder with the name of the project you wish to create, let’s say “base�?.

3.   Open the .ioc file of the project created with TouchGFX designer with CubeMX. Open with CubeMX and not from STM32cubeIDE. Go to File->Save Project As.. and save the project in the folder you have created in Step 2. CubeMX names automatically the new project (i.e. the new .ioc file) with the same name as the folder you will save it in, so the file that will be produced is base.ioc. Then go to the tab “Project Manager�? and select Project->Toolchain/IDE STM32CubeIDE and “tick Generate Under Root�?. Save the project. Press “Generate Code�?. Close CubeMX.

4.   Open with Windows explorer the folder of the project that was created with TouchGFX and in a new window open the project that you created in Step 3 (we will call it “base project�? from now on) .

   a)   One-by-one copy the following folders from the folder of the TouchGFX Designer project to the folder of base project so that they overwrite the existing folders: “Core�?, “Drivers�?, “Middlewares�?.

   b)   Go to the folder “TouchGFX�? of the TouchGFX Designer project and copy one-by-one all the folders contained in it to the folder “TouchGFX�? of base project.

   c)   Go to the folder “STMCubeIDE�? of the TouchGFX Designer project. Copy the two .ld files to the root folder of the base project so that they overwrite the existing files.

   d)   Go to the folder “STMCubeIDE\Application\Startup�? of the TouchGFX Designer project and copy the .c file to the “Core\Startup�? folder of the base project so that it overwrites the existing file.

   e)   Go to the folder “STMCubeIDE\Application\User�? of the TouchGFX Designer project and copy the .c files to the “Core\Src�? folder of the base project so that they overwrite the existing files.

5.   Import the base project to STM32CubeIDE. Expand the project in the project explorer and click on the file “ApplicationTemplate.touchgfx.part�? to open the TouchGFX designer. Then, choose “Black UI�? and create a simple GUI just using a box and Text. Generate code and close TouchGFX.

6.   In the STM32CubeIDE, click on the ioc file and then Generate code.

7.   Build all. Some errors will be produced, because the compiler cannot find the .h files of the BSP. Go to the project name, right click and then go to properties to add the include paths for these header files. Unlike other IDEs, the files added to the project explorer are not included automatically to the compiler’s paths and so this must be done manually. Instructions for this are available online. Here is a rough way to do it. Properties->C/C++ Build->Settings->MCU GCC Compiler -> Include path. Add the path to the header file that the compiler couldn’t find. And also Properties->C/C++ Build->Settings->MCU GCC Compiler -> Include path. Add the path to the header file that the compiler couldn’t find. They are in the folder �?Drivers/BSP/Components�? of the base project. It is also best to change the #includes in the code from a path e.g. #include “Components/ili9341.h�? to just the filename #include “ili9341.h�?

8.   You are Done!! You can use project base as a starting point for your TouchGFX projects.