‎2018-12-12 12:42 AM
This 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?]
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.
‎2018-12-17 07:12 AM
I'm working with the STM32F746G-DISCO. I have found that CubeMX does not include touch drivers....once you get it to compile, the display will show your GUI but the controls don't work. Does this happen with the F429? If so, can anyone share any details on how you added touch drivers.
‎2018-12-17 07:18 AM
hi @Zhi Pang​ , thanx for the reply..
after some days of tweaking the CubeMX/CubeF4/trueStudio pipeline.. i have to say i didn't find the clue, so i decided to stick with the "native" touchGFX -> GCC/Makefile process.
there's already the freeRTOS integration and good recipes for adding tasks and data exchange.. it looks to me the smoothest path.
i would like to listen if there are any advantages when using these IDEs
‎2018-12-17 07:44 AM
@Clark Sann​
u have to copy the two folders "Components" and "STM32746G-Discovery". In the folder for the CubeMX project, create a folder named BSP under Drivers and place the two copied folder to the BSP folder
then u uncomment code in the two functions : (STM32F4TouchController::init(), STM32F4TouchController::sampleTouch(int32_t& x, int32_t& y)) in STM32F4TouchController.cpp
‎2018-12-17 08:07 AM
Hi Clark Sann. This post is to confirm that the use of the CubeMX does NOT include touch drivers for the STM32F429i-DISC1. This issue took about 1.5 days to resolve over the weekend. For sure we recall reading a relevant article on the main TouchGFX article that detailed how to modify the IAR compiler to import the support from the CubeMXF4 download. Even after this procedure, had some compiler errors on the reading of the X, Y readings from the STMPE811 RTP controller. However, did fix all of these errors. Perhaps it is too early on our Monday but my google-fu is weak and unable to locate the article that should help you out. Trying to determine the best way to share the knowledge, before we forget but may take 1-2 days to organize. Will start documenting asap...
‎2018-12-17 08:17 AM
OK!! Found the article that is relevant to you...
See here:
https://touchgfx.zendesk.com/hc/en-us/articles/360020001992-Configuring-STM32F7508-DISCO
Review the details about "Modifying the EWARM Project" and do the same except for your target CPU.
We followed this general guideline for our CubeMXF4 (latest download).
Need to state that our success has been with the IAR compiler only as we found some serious batch of errors early on with Keil. After documenting the process that got this all working, will revisit the Keil compiler use.
With the above article, then the touch controller will be supported. For us, we are on I2C3 port pair (STM32F429i-DISC1) so be aware of this for your CUBEMX code generation.
Next the next bug you may waste time is on:
bool STM32F7TouchController::sampleTouch(int32_t& x, int32_t& y)
{
/* USER CODE BEGIN F4TouchController_sampleTouch */
TS_StateTypeDef state = { 0 };
BSP_TS_GetState(&state);
if (state.touchDetected)
{
x = state.touchX[0];
y = state.touchY[0];
return true;
}
return false;
/* USER CODE END F4TouchController_sampleTouch */
}
Change to:
bool STM32F7TouchController::sampleTouch(int32_t& x, int32_t& y)
{
/* USER CODE BEGIN F4TouchController_sampleTouch */
TS_StateTypeDef state = { 0 };
BSP_TS_GetState(&state);
if (state.touchDetected)
{
//x = state.touchX[0];
//y = state.touchY[0];
// going from memory but 99.9% sure this is correct
// and will confirm in the formal
// document for this entire process
x = state.X;
y = state.Y;
return true;
}
return false;
/* USER CODE END F4TouchController_sampleTouch */
}
a lot more to say so will document to move on and be productive with these tools...
sorry - wanted to add the comment that the above routines are ALREADY generated by the TouchGFX tool. Just do a search for the text "sampleTouch" (is case sensitive) to locate the code block and then modify / uncomment as per the TouchGFX article. This will then activate the related routines. We recall that most of these code blocks were commented out so they were null routines for the touch support.
‎2018-12-17 01:02 PM
Hi. Here is the first draft document of the full procedure to support the STM32F429i-DISC1 target that we followed:
https://s3.amazonaws.com/axxonshare/my_combo_tutorial.zip
Welcome your feedback on the document and if it works for you. Good luck! :grinning_face:
‎2018-12-17 01:30 PM
Thank you guys for the help. But I must be an idiot...I cannot figure out how to include the files. I have copied the files into the BSP folder, but the compiler refuses to see them. For example, it can't find stm32746g_discovery_ts.c. That's bad because that file contains the function BSP_TS_Init which is needed by the TouchController. I have fought eclipse for 3 days trying to solve this. I am using SW4STM32. I don't know whether SW4STM32 is broken or if I am...one of us is for sure!
It does not help me that ST has decided to restructure the project so that almost every file is linked into it. By doing that, the folder structure in Eclipse is almost totally different than the folder structure on the hard drive. And the include files are missing altogether. Are they trying to make it as hard as possible? I joke, I joke. I know they are not trying to do that but they are succeeding at it very well.
So here is what I have done.
I've many many ways to add the BSP files to my project and include those files, but no matter what I do, stupid SW4STM32 still refuses to use those files. I am totally frustrated with SW54STM32 and a bunch of other things. Anyone have any ideas?
‎2018-12-17 02:36 PM
Hi @Clark Sann​ , any chance you can consider the IAR compiler? The details on how to add the required files has been documented by Draupner at the supplied URL. Also just posted our process in the last hour on how to build a working project for the STM32F429 target (with touch panel).
‎2018-12-17 10:55 PM
Hi, @Mon2​
Thank you for sharing this document, it resumes all step to build a project with TouchGFX and CubeMX... I have 2 questions :
Regards
‎2018-12-18 04:56 AM
Hi @elguezzar​ . Enabled the SPI pin to only relax the raised error / warning from the STM32CubeMX tool. Not sure if it is really required for operation as it appears that the ILI9341v controller onboard the TFT display is being configured using I2C. Can disable and still proceed to generate the code for testing upon reaching the office in a few hours. Based on the schematics for the STM32F429i-DISC1 kit, the PF9 = MOSI is used but may be our misunderstanding. Will experiment and write back with the updates.
The use of the USB is at your option. Do not believe there was any impact to leave this port function enabled. Once this package is operational, you are free to enable / disable ports of your choice using the powerful CubeMX tool to generate most of your code. To be honest, without such tools, not worthwhile to even consider the ST line as there is far too much low level code that is required to be operational.