cancel
Showing results for 
Search instead for 
Did you mean: 

Custom PCB Using TGFX

Zhi Pang
Associate III

0690X000006CnjYQAS.jpgThis is not a question asking post, just something I want to share. Hope will help people who meet the same problems I solved.

Last I asked lots of question about how to build a TouchGFX project.

You can find the original ask in [Does CubeMX 5.0.0 Ready to Build a TouchGFX Project?]

https://community.st.com/s/question/0D50X0000A1kKWaSQM/does-cubemx-500-ready-to-build-a-touchgfx-project

After few weeks work, I finally make this right. Now I'd like to share some information with you.

About my situation:

Host project builder: STM32CubeMX 5.0.0

Firmware package: STM32Cube FW_F4 V1.23.0

GUI builder: TouchGFX Designer 4.10.0 within the firmware package

ToolChain/IDE: TrueSTUDIO for STM32 9.0.0 convert from SW4STM32

Hardware: Custom PCB with STM32F429IG

LCD Panel: 1024 * 600, RGB565 interface parallel

Touch Screen: Capacity Multi-touch, IIC interface

Q1. How to build a host project for TouchGFX graphic solution using TrueSTUDIO toolchain?

A1. You can follow UM1718 tutorial 10 or my posts which have more details and screen shots in my original ask. BUT before you hit the generate code button, make sure the Toolchain/IDE setting is select to SW4STM32. Since there are some generation problems when using TrueSTUDIO as its Toolchain/IDE. Later then you can use TrueSTUDIO to open .project files and do some automatic conversion.

Q2. How to build a GUI project within the host project? Why I try to build the host project and tons of missing files error are showed?

A2. After you hit the generate code button and the generation is completed.You'd better not to open .project file so far. Go back to CubeMX's GRAPHICS configuration page. Now the TouchGFX's Execute button should be available then click it. You could do some quick design just for test in the opening TouchGFX designer.After dragged some widgets or change background image, you have to save the GUI project and click the Generate Code button. The the status bar or Detailed Log will tell you if code generation is finished.

Q3. What if I meet a code generation error in GUI project?

A3. Close the TouchGFX designer and then reopen project in yourhostprojectname/TouchGFX/yourhostprojectname.touchgfx file. And then try again. In most cases, it can be generated after close and reopen procedure. But if it didn't, at least you can give a try that delete all files and directories except yourhostprojectname.ioc file and try again.

Q4. Error in compile main.cpp?

A4. You may need to change

void MX_FREERTOS_Init(void);

to

extern "C" void MX_FREERTOS_Init(void);

in line:89 or /*Private function prototypes*/ section in main.cpp.

Q5. Error in compile freertos.c?

A5. You may need to change

void GRAPHICS_MainTask(void)
{
    touchgfx::HAL::getInstance()->taskEntry();
}

to

extern "C"{
    void GRAPHICS_MainTask(void)
    {
        touchgfx::HAL::getInstance()->taskEntry();
    }
}

in the bottom of BoardConfiguration.cpp.

Q6. Fall into an infinite loop in startup file after tastEntry() function called?

A6. Make sure you enable interrupts related to LTDC and DMA2D in CubeMX NVIC configuration.

Q7. LCD display some glitch-style content and program run into the Hardfault_Handler() function?

A7. Check in MX_FREERTOS_Init() function which is declared in freertos.c, and double the defaultTask stack size (in bytes) parameter. 128 to 256, 256 to 512 ,512 to 1024. The 1024 bytes stack size work for my situation.

Q8. LCD display the test design well but want more design?

A8. Make sure you close the host project in TrueSTUDIO project resource manager. And open your GUI project like A3. Finish your design and generate GUI code. Now reopen your host project and completely rebuild it. If you meet some errors said that no such file things, you were probably do some "delete" design before.If you just do "add" design, usually won't come up these errors. You have to find out which files didn't exist in file system anymore but still in your host project structure, and remove them from it. And do a completely rebuild again. Please don't click the Execute button again, unless you want start a totally new GUI design.

Q9. Want to use LCD width or height beyond 1000 pixels?

A9. I don't know why the width or height limitation is 1000? Because LCD display panel commonly have 1024 pixels in width or height. You can do some hacks to override the limitation, but at your own risk. Firstly, use notepad to open *.touchgfx file, change

...    
"Resolution": {
      "Width": 1024,
      "Height": 600
    },
...

value to what you want before you do any design else. Secondly, change values in BoardConfiguration.cpp -LCD_GetXSize(void)\LCD_GetYSize(void)\touchgfx_init(). Thirdly, change value HW_Init.cpp -MX_LCD_Init() - HAL_LTDC_SetPitch().

I will keep share if I found something is valuable.

28 REPLIES 28
andrea venturi
Associate III

hi, thanx for taking time to describe the thorough process..

me too, i'm facing some issues in this "cubeMX cfg -> touchGFX designer -> export to SW4STM32 prj output format -> trueStudio import & build" process.

the "execution" of the TouchGFX designer EXECUTE step is puzzling me, because it starts with an "empty GUI design" i.e. it doesn't inherit the "HW MCU and LCD properties" from CubeMX previous step (in my case a pretty standard ST32F429I-DISC1 eval board..), as if it didn't know and started blank, then:

  • if a try to load the "stub" project.touchcfg or "import GUI" it doesn't format properly the "canvas".
  • if i open a "new prj" with the same target board ( the well known STM32F429I-DISC1 again..) and i put the application folder where there's the "touchCFG" dir, at "generation code" time, it creates a different source code tree starting with the name of the Designer project (can't accept chars like _ and - BTW..), so it doesn't match the overall "trueStudio" project codetree..

my current SW ver are :

  • CubeMX 5.0 vwith
  • STM32CubeF4 4.1.23 with onboard
  • TouchGFX designer 4.10.0 (libs and GUI)
  • and trueStudio 9.1.0

i understand the integration promise by STM is HUGE!! and i appreciate the effort

i know everything is currently under a steep integration phase,

but i think some pretty raw tutorials on "which files are good for in the prj tree" and how to debug the "trueStudio prj errors" would give some relief to the customers, as they could better understand what's going on, under all the graphical wrappers! :)

..and maybe fix errors properly by hand in a meaningful way.

bests

BTW is the recent trueStudio 9.2.0 worth the time to check if it helps on this touchGFX integration?

Zhi Pang
Associate III

Hi @elguezzar​ ,

I use the "Board Selector" way in CubeMX and choose a STM32429I-EVAL board as the project template. Then I turn off the peripherals which do not relate to Graphic function, such as USB, ETH and so on. Since I can't find the parameters of LCD panel (AM-480272H3TMQW-T01H) which is use by STM32429I-EVAL, I am not sure the settings in LTDC is right. But the project is built correctly.

0690X000006CoeYQAS.jpg

Hi @Community member​ ,

As far as I know, the TGFX integration problem is not relate to TrueSTUDIO. It is about how the CubeMX to generate code(project) template which base in HAL structure cooperate with TGFX's M-V-P structure.

Unfortunately, TrueSTUDIO v9.1 and v9.2 don't work for me. Because they change the debugging tools to STM32CubeProgrammer CLI. And I encountered a problem that the debug session close unexpected. So I just use v9.0 for now.

hi @Zhi Pang​ ,

i rebuilt your project in Atollic, i generated Hex file, and i flashed my Eval board but nothing displayed on LCD 0690X000006ConGQAS.jpg

Hi @elguezzar​ 

I think the LTDC is not being initialize​d correctly.

In the project I offered, the MX_LCD_Init() function is located in \Application\User\TouchGFX\target\HW_Init.cpp.

You need to compare it with the official demo's LCD_Init() function which is located in \STM32Cube_FW_F4_V1.23.0\Projects\STM324x9I_EVAL\Demonstrations\TouchGFX\Gui\target\BoardConfiguration.cpp.

Since I don't have a EVAL board, I can't verify the project if it is fully functional or not for you.

PPiar
Associate II

thanks for the post. Do you know what is the maximum screen resolution STM32F7 could handle? What about STM32F4?

The data of maximum screen resolution gave by ST is 1024 × 768 on F4 & F7.

You can find more detail below:

https://www.st.com/content/st_com/en/stm32-graphic-user-interface.html

In my case, I use a 180MHz F4 with 32 MBytes external SDRAM to drive a 1024 × 600 LCD by RGB565 format. The result didn't perform very well.

I think one of the reason is TGFX is not optimized enough compare with STemWin.

Now I am planning to replace a lower resolution LCD, maybe 800 × 600? Or use a F7/H7 chip instead? At least, my TGFX GUI project is running correctly.

@Zhi Pang​ 

Exactly...

I changed LTDC, FMC, and DMA2D configuration according to desmonstation on STM32Cube_FW_F4_V1.23.0.

Now i can display my GUI on STM324x9I_EVAL board

Thank you for your support :) 0690X000006CpjZQAS.jpg

Mon2
Senior III

Hi Zhi Pang. Wish to thank you for your informative posts. We have been struggling with these tools for the past 3 weeks and almost gave up for our STM32F429i-DISC1 target. Happy to say that after a lot of reading, your post offered inspiration to try other ideas and now have it all working well. Will review the process from scratch again to be sure that we are not hallucinating and will post a document detailing the steps we took to get this all working correctly. To get this working together is like winning a lottery. Such a powerful toolchain but lacking proper documentation and examples to be up and running quickly. Hats off to you for your knowledge shown in these forums!!