cancel
Showing results for 
Search instead for 
Did you mean: 

How does STM32CubeIDE know where these files are and how can I edit them in the workspace? (TouchGFX generated)

CDyer.1
Senior

Hi,

Firstly, apologies if this in the incorrect section as this is specifically about CubeIDE. I am attempting to use the touchGFX designer in conjunction with CubeIDE. Once I have generated the necessary screens, buttons etc. with TouchGFX designer, I hit "generate code" and it provides me with a bunch of folders, an .ioc and various project files for different IDEs.

0693W000005C88qQAC.png 

I go in to the folder that is generated for STM32CubeIDE and load up the .cproject file.

0693W000005C89oQAC.png 

If I then build/compile this project in the cubeIDE, it is successful but then I get repeats of folders (they added by the build process) and also, files that are not present in the workspace, but ARE present in the touchGFX folder can be detected. For example, there is no Core / Inc and Src folders in the IDE workspace but they ARE in the folders generated by TouchGFX and the CubeIDE knwo this, so any references to "main.h" will be found by the IDE despite it not being directly in the workspace. Here are some images to help illustrate:

No Core / Inc and Src in the IDE workspace and some repeated folders

0693W000005C8GfQAK.pngBut it is in the TouchGFX folder and the IDE can find it no problem when it is referenced.

0693W000005C8H9QAK.png 

Now my questions, how does the IDE know where these folders are as it compiles correctly? If I want to change main.c/.h I have to go out of the IDE, locate the file and then change it in a text editor, refresh the project and then build (or shortcut Ctl + click where the reference in the code is). What is it that I am doing wrong? How should I be importing projects generated by touchGFX if not opening the specific project file for the specific IDE? If I open just .ioc file that is present and generate a separate project using CubeMX then the touchGFX configs are lost and I get a blank screen.

Any help would be great, as I'm clearly not opening the generated code correctly and I'm sure this is a simple fix. Thanks

10 REPLIES 10
CDyer.1
Senior

If anyone has any ideas or can point me in the direction of an explanation, it would be appreciated...​

Michael K
Senior III

Let's get the Debug folder out of the way because it's an exception to the explanation below. Anything that appears in Debug are build fragments and object files from a build in a Debug configuration. If you Clean your project you'll find that folder empty. If you switch to Release configuration you'll find a similar folder.

Let's look at the sidebar (third picture). In the folders (Application, Drivers, Middlewares) you'll find .cpp and .c files. The files that appear here get compiled. These folders correspond to the folders in the STM32CubeIDE folder in the filesystem (photo 2). However, if you look in those folders with windows explorer you'll find they have no .c or .cpp files in them! Why? In the case of the touchgfx generator, nearly all files are "linked files" - they don't necessarily inhabit the folders that appear in the sidebar. They live somewhere else, and are only represented in those folders. As you saw, the actual main.c file is in Core/src, but in CubeIDE it appears in Application/User. It's a linked resource. The idea is that you can have central library code (such as the STM32 hal) external to your project folder, but while still being a part of your project.

You'll find the sidebar folders (Application/Drivers/Middleware) appear to be devoid of headers. That's because header files aren't compiled in the same way a .cpp or .c file is - instead they are included by a .cpp or .c file being compiled. In the same way that you copy or link a c or cpp file in the sidebar to tell the IDE which files you want compiled, the IDE needs to know where it should look for headers when a file includes them. To define or review locations for headers, right click your project in the side bar -> Properties -> C/C++ Build -> Settings -> Tool Settings. In MCU GCC Compiler and MCU G++ Compiler, you have a Include Paths section. Each folder here is a potential location for the IDE to look for header files (excluding the standard library). Notice that these paths are relative to the Configuration folder i.e. STM32CubeIDE/Debug or STM32CubeIDE/Release, and point to actual filesystem paths, NOT CubeIDE workspace paths (although doing so is possible). If you click on the Includes menu list in the sidebar, you'll see all these folder and can expand them to see the headers contained within.

Embedded UI/UX Consulting: cadenza.design
Pavel A.
Evangelist III
scottSD
Senior III

@CDyer.1

 

Did you ever get an actual solution to this problem? I tried starting a project from scratch within Stm32CubeIDE, but cannot get the display on an Stm32F46-Discovery kit to work. I followed a tutorial video and the project does compile, but the Project Explorer isn't showing the correct file structure in many areas (core include/src and 'gui' and 'generated' do not show 'include' or 'src' directories. 

https://www.youtube.com/watch?v=Q-mfuzW6S-0 

 

I am using Stm32cubeIDE 1.16.0 and TouchGFX 4.24.1

Link to the files you want to show in the project folder. For example, if you want main.h to show in the Core folder...

 

1, Right click on the Core folder and import

KarlYamashita_0-1728627624951.png

 

2. Select File System

KarlYamashita_1-1728627689573.png

3. Navigate to the Core>Inc folder and Click Select Folder

KarlYamashita_2-1728627783948.png

4. Select the file(s) you want to import and link to them. 

KarlYamashita_3-1728627845647.png

5. The main.h file now shows in the project folder. You can double click main.h and it'll open in the IDE for you to edit.

KarlYamashita_4-1728627939183.png

6. As you can see in the Core folder, files that are linked have the Up arrow icon. They are not physically in the Core folder. While syscalls.c and sysmem.c are the actual files in the actual Core folder

KarlYamashita_5-1728628162154.png

 

When adding new c/h files, typically you would right click on the folder and do New>Header Files or Source Files,

But that adds them to STM32CubeIDE\Application\User\Core folder which the paths don't point to so you'll get some build errors.

Instead, create the files (blank text) in a text editor and save them to Src/Inc folders in the root Core folder. Then link to them as shown above and you'll be able to edit them as normal. Then you can start adding your code.

 

 

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.

Thanks for your quick reply. I appreciate it. Apparently when importing a project from the TouchGFX Designer, the Project Explorer structure is completely different than when starting a project from scratch in Stm32CubeIDE. 

In 2020 was state of this little differ, but seems you skip some steps required to refresh and show all file after first generation code in TGFX template opened . Add software package into project have step by step and skip some result to trouble. But when you understand it , TGFX can be added with 7 clicks.

@MM..1 I am not sure I understand your answer. You mention I missed some steps but didn't provide those steps. And you didn't provide the "7 clicks".

The project structure shown in the Stm32CubeIDE Project Explorer looks nothing like what is on the file system. And what is on the file system shows multiple files for some TouchGFX generated "base" files. Some are showing up under "projectName\STM32CubeIDE\Application\User\generated" and also showing up under "projectName\TouchGFX\generated\gui_generated"

I dont like TouchGFX created projects, isnt real for custom boards and make chaos as you see. But for learning and support IDEs not only Cube must be more complicated.

MM1_0-1729010689863.png

as you see MDK-ARM is folder for use project in MDK, EWARM for IAR and ... 

In normal created CubeIDE or from MX only one target IDE projects is structure more simple and clean.