cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX and CMake

TS-LMG
Associate III

Hello. 

I've been struggling to flash a simple TouchGFX application through the STM32 VS Code extension. I am using the Nucleo-G071RB dev board with the GFX01M2 display board. My project was initially created using the TouchGFX designer, then generated the CMake project in CubeMX. In VS Code, I added the SPI_FLASH section in  STM32G071RBTX_FLASH linker file, and the cmake/touchgfx sub directory in the CMakeLists. This allowed me to build the project with no errors. However, whenever I try to flash, I get the following:

Screenshot 2025-06-10 152940.jpg

I suspect this has something the do with the external flash. I am aware of an external loader file that you have to select in STM32CubeIDE, but I'm not too sure what would be the equivalent in VS Code. 

1 ACCEPTED SOLUTION

Accepted Solutions
TS-LMG
Associate III

Hello @GaetanGodart,

 

This issue has been solved. Several commands needed to be added to CMakeLists.txt, tasks.json and launch.json in order to get CMake to build, flash, and debug with external flash. 

 

Best regards,

Tom

View solution in original post

7 REPLIES 7
TS-LMG
Associate III

Update: I've added the location of the external loader to "serverArgs" of launch.json. I'm still having the same issue. 

GaetanGodart
ST Employee

Hello @TS-LMG ,

 

This looks like a flashing issue.
Since you erase internal memory and then flash it is perhaps an internal memory issue, not external?

Could you try to flash using STM32CubeProgrammer?

 

What about that SPI_FLASH section?
You say that you create the project using TouchGFX Designer, so it should work from there, then you change 2 things : you add the SPI_FLASH section and you also change the toolchain.
Could you try to only do 1 of these things to see which one is causing an issue?

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)

Hello @GaetanGodart,

Thank you for your reply. It seems like the flash issue happens right from the get-go. Without the SPI_FLASH, I get a flash overflow on the internal flash. And without the cmake/touchgfx in the CMakeLists, I get compile errors. Regarding the launch.json, I uncommented the external loader section: 

Screenshot 2025-06-12 093530.jpg

This had no effect. I'm not sure if the external loader is being used or not. 

Regarding STM32CubeIDE, the code works fine using ST-Link GDB server and the external loader generated by touchGFX. However, not including the external loader, I get the following error:

Screenshot 2025-06-12 094329.jpg

Switching to OpenOCD, I get this error message: 

Info : accepting 'gdb' connection on tcp/3333
Error: Failed to write memory at 0x900017c0
Error: Failed to write memory at 0x90005740
Info : dropped 'gdb' connection
shutdown command invoked
Info : dropped 'gdb' connection

I'll attach the zip of the Cmake project if you want to take a look at it. 

Hello @TS-LMG ,

 

The STM32GG071RB doesn't have a lot of internal memory.

If in TouchGFX Designer you open a demo compatible with the STM32G071RB, you will see that we put everything in external memory to not have an internal memory overflow like you do.

Regarding the STM32CubeIDE issue, it could be because you are missing the external loader in the configuration of the software. You can add it like that :
right click on your project => Properties => Run/Debug settings => External loaders

GaetanGodart_0-1750063295512.png

The OpenOCD issue seems to be the same : not able to load to external memory.

 

I see that you have created a new thread, does it mean that you were able to fix this issue?

 

Regards,

 

Gaetan Godart
Software engineer at ST (TouchGFX)
TS-LMG
Associate III

Hello @GaetanGodart,

Ah yes I made a mistake on my post. TouchGFXDesigner does add the SPI_FLASH. However, I noticed that its been set to 8M, which the GFX01M2 has a 64M external flash.

As for the CubeIDE, I can flash the board using GDB server + external loader with no issues. I still can't seem to get this to work in VSCode and CMake though. 

I've created a new thread because of other issues I have encountered regarding RTOS. I'm not sure if the G071RB has been configured for TouchGFX and RTOS, but I initially had issues with the Systick not incrementing when entering HAL::initialize() function. I'll make a follow-up reply to that post, as I have done lots of digging around on Friday. 

https://community.st.com/t5/stm32-mcus-touchgfx-and-gui/touchgfx-and-rtos-initialization-issue/td-p/812424 

Hello @GaetanGodart,

 

Were you able to try my example CMake project to see if you can get it to compile? 

 

Thank you. 

Tom 

TS-LMG
Associate III

Hello @GaetanGodart,

 

This issue has been solved. Several commands needed to be added to CMakeLists.txt, tasks.json and launch.json in order to get CMake to build, flash, and debug with external flash. 

 

Best regards,

Tom