Skip to main content
Associate III
January 14, 2025
Solved

Unable to display Text using FreeRTOS, TouchGFX and Custom LCD

  • January 14, 2025
  • 7 replies
  • 3318 views

Hello Everyone,

Earlier we have successfully developed a variant using STM32F746 Discovery board but now we have shifted towards our own developed PCB with custom LCD Display 800 * 480.

Our new PCB uses MT25Q128A external flash for storing images, text and font used by TouchGFX and we are using single buffer allocation in external SDRAM for framebuffer. We are using different pins for QuadSPI communication so had to develop custom external loader for this. We have tested the external loader for various images and it works fine.

When we started inputting texts in TouchGFX the system would wait infinitely in xQueueSemaphoreTake() function so we suspected something might be wrong with loading from external flash so we created another project this time stored everything in internal flash, again the result was same, the TouchGFX hangs while using texts.

After searching through the community we came across following links:

https://community.st.com/t5/stm32-mcus-touchgfx-and-gui/ui-stuck-in-takeframebuffersemaphore/td-p/203677/page/7

Here it is suggested to  try to change the line in stm32h7xx_hal_dma2d.c, in the function, but is related to H7 series.

Same thread also suggested changing MPU Config

pitbull_0-1736834760700.png

 

We had disabled MPU in our project but even after enabling it the result was unaffected.

 

pitbull_1-1736834760419.png

 

Please guide me where I am doing wrong.

Thankyou 

 

Regards,

Pitbull

Best answer by pitbull

Hii @MM..1

 

Finally resolved the issue.

Following is the link 

https://forums.freertos.org/t/how-to-debug-to-resolve-configassert-pxqueue-uxitemsize-0-loop-error/17269 

Increasing the stack size for the tasks resolved the issue in the following post.

Similarly I increased the stack size for every task from 128 words to 512 words.

Thankyou @MM..1  @jumman_JHINGA @Flemming Gram CHRISTENSEN  for your time and support.

 

Thankyou

 

Regards,

Pitbull 

7 replies

pitbullAuthor
Associate III
January 14, 2025

Hello Everyone,

Earlier we have successfully developed a variant using STM32F746 Discovery board but now we have shifted towards our own developed PCB with custom LCD Display 800 * 480.

Our new PCB uses MT25Q128A external flash for storing images, text and font used by TouchGFX and we are using single buffer allocation in external SDRAM for framebuffer. We are using different pins for QuadSPI communication so had to develop custom external loader for this. We have tested the external loader for various images and it works fine.

When we started inputting texts in TouchGFX the system would wait infinitely in xQueueSemaphoreTake() function so we suspected something might be wrong with loading from external flash so we created another project this time stored everything in internal flash, again the result was same, the TouchGFX hangs while using texts.

After searching through the community we came across following links:

https://community.st.com/t5/stm32-mcus-touchgfx-and-gui/ui-stuck-in-takeframebuffersemaphore/td-p/203677/page/7

Here it is suggested to  try to change the line in stm32h7xx_hal_dma2d.c, in the function, but is related to H7 series.

Same thread also suggested changing MPU Config

pitbull_0-1736832798007.png

We had disabled MPU in our project but even after enabling it the result was unaffected.

 

pitbull_1-1736832860313.png

Please guide me where I am doing wrong.

Thankyou 

 

Regards,

Pitbull

Flemming Gram CHRISTENSEN
ST Employee
January 14, 2025

Hi.

The issue about MPU in the topic you refer to is to disable prefetching outside of the QSPI range.
This is important and should be done. Normally this gives an error after running a while (could be hours).

Try moving texts and fonts to internal flash for a test. This is done in the linker script.

Also check the DMA2D for errors. One error is the configuration error. There is maybe a handler for this in the top of TouchGFXGeneratedHAL.

It can also be a DMA2D Transfer error. This comes if there is a error on the memory subsystem during the transfers. 

You can check this by looking at the DMA2D registers (in the ISR register).

If you get this, you do not get the Transfer Complete interrupt, and the process stops.

Hope it helps.

pitbullAuthor
Associate III
January 14, 2025

Hii Fleming,

 

Already checked by moving fonts and texts in internal flash. Facing the same issue.
Will check for the DMA2D registers and update you accordingly.

 

Thankyou for your quick response.

 

Regards, 

Pitbull

 

pitbullAuthor
Associate III
January 25, 2025

Hii @Flemming Gram CHRISTENSEN 

 

I have checked the DMA2D ISR registers and the response looks okay. But the problem seems to persist. I have also tried disabling the DMA2D ChromART accelerator but even then the touchGFX hangs when text is visible.

 

pitbull_0-1737793737631.png

 

Please guide me accordingly.

 

Thankyou

 

Regards,

Pitbull

pitbullAuthor
Associate III
January 27, 2025

Hello @MM..1 

 As you suggested I tried updating touchGFX to 4.22.1 but the issue persists.

But again as you said it is definitely a issue with font as entering white spaces renders the text area perfectly.

Will try with different touchGFX versions and will keep you posted.

Thankyou for your guidance.

 

Regards,

Pitbull

Flemming Gram CHRISTENSEN
ST Employee
January 27, 2025

The reason it can show a string of spaces, is because there are no pixels in a space.
This points to a problem with reading flash.

But then, if it also fails with texts and flash in internal flash, then something else is wrong.

 

When it hangs there, someone did not return the framebuffer semaphore.

Any custom widgets? Other code calling lockframebuffer?

Did you remember to call the superclass in TouchGFXHAL::endFrame? (if you modified it).

Another thing to try:

in STM32DMA.cpp, try different settings here:

BlitOperations STM32DMA::getBlitCaps()
{
return static_cast<BlitOperations>(BLIT_OP_FILL
| BLIT_OP_FILL_WITH_ALPHA
| BLIT_OP_COPY
| BLIT_OP_COPY_L8
| BLIT_OP_COPY_WITH_ALPHA
| BLIT_OP_COPY_ARGB8888
| BLIT_OP_COPY_ARGB8888_WITH_ALPHA
| BLIT_OP_COPY_A4
| BLIT_OP_COPY_A8);
}

If you remove the A4 line, all texts are drawn in SW, not DMA2D. Does it make a difference?

In the same file, using a debugger, set a breakpoint on this yellow line:

FlemmingGramCHRISTENSEN_0-1737964045860.png

What does the ISR register of DMA2D say? Any errors?

Also check that the FGMAR (font) and BGMAR (framebuffer) addresses are both readable.

Verify the addresses in the MAP file.

Best hopes!

 

pitbullAuthor
Associate III
January 28, 2025

Hii @Flemming Gram CHRISTENSEN 

 

Thankyou for your support.

I tried the following as you suggested.

If you remove the A4 line, all texts are drawn in SW, not DMA2D. Does it make a difference?

No. It does not make any difference and the screen hangs as in this as well even if I move everything to internal flash.

In the same file, using a debugger, set a breakpoint on this yellow line:

pitbull_0-1738037030066.png

The breakpoint is never hit in the debugger. 

The system enters the function but does not enter the mentioned case. It either enters in default case ( BLIT_OP_COPY & BLIT_OP_COPY_16BIT ) or BLIT_OP_COPY_ARGB8888_WITH_ALPHA case.

 

Thankyou

 

Regards,

Pitbull

 

 

MM..1
Chief III
January 28, 2025

Show code crash, is generated or your custom? 

jumman_JHINGA
Senior III
January 28, 2025

Hii @pitbull  when i started working on custom board i also faced issue whenerver getFont() function was getting called, MCU was going going to memfaulthandeler(). I tried diffrent diffrent MPU configuration but didnt work anything. latter i got to know that QUADSPI BSP configuration was wrong. by adding correct BSP firmware my issue got resolved.

 

I'll suggest you to dont use TouchGFX genrated BSPs. 

pitbullAuthor
Associate III
January 29, 2025

Hii

 

Show code crash, is generated or your custom? 

@MM..1 Please find my attached project for your reference. I have attached the CustomLoader project for programming the external flash as well as the final project in which the text is to be displayed.

 

Hii @jumman_JHINGA 

I am currently using n25q128a driver from stm32. But as you are suggesting reading from external flash is an issue but when I store the text in internal flash I continue to face the same issue.

I will try to rewrite the qspi driver as you suggested and will update you accordingly.
I am using MT25Q128A as external flash using qspi and have developed a custom loader using different pinout for qspi for loading the external flash, but am using the N25Q128A driver from stm32 in the main project.

The images are displayed without any issue but as soon as text is to be rendered the touchGFX hangs.

 

Thankyou for your guidance.

 

Regards,

Pitbull

MM..1
Chief III
January 29, 2025

Sending this big zips isnt very helpfull. And your project is unsynced code and gui differ... 

Normal show this line i comment code work. Uncomment crash. 

Now you send

void imageScreenView::changeText()
{
 mode++;
 switch(mode)
 {
		case 0:
			//Unicode::strncpy(helloTextBuffer, "Cosmo", HELLOTEXT_SIZE);
			break;
		case 1:
			//Unicode::strncpy(helloTextBuffer, "New PCB", HELLOTEXT_SIZE);
			break;
		case 2:
			//Unicode::strncpy(helloTextBuffer, "Gauging", HELLOTEXT_SIZE);
			break;
		case 3:
			//Unicode::strncpy(helloTextBuffer, "Air Leak Tester", HELLOTEXT_SIZE);
			break;
		case 4:
			//Unicode::strncpy(helloTextBuffer, "TWAIPL", HELLOTEXT_SIZE);
			break;
		default:
			mode = 0;
			//Unicode::strncpy(helloTextBuffer, "Technowings", HELLOTEXT_SIZE);
			break;
 }
 //helloText.invalidate();
}
jumman_JHINGA
Senior III
January 30, 2025

Check in TouchGFX may be you hide that text.

 

also check frontscreenViewBase.cpp file. in that your text should get initialized as follow:

Screen1ViewBase::Screen1ViewBase()
{
 textArea1.setXY(411, 180);
 textArea1.setColor(touchgfx::Color::getColorFromRGB(255, 0, 0));
 textArea1.setLinespacing(0);
 textArea1.setTypedText(touchgfx::TypedText(T___SINGLEUSE_JTFE));
 add(textArea1);
}

 

pitbullAuthor
Associate III
January 30, 2025

Hii @jumman_JHINGA 

 

Yes I have hidden the text in touchGFX Designer but controlling its visibility through code.

But setting it visible through code causes touchGFX to hang.

Following is the generated source file code at initialization

 

frontScreenViewBase::frontScreenViewBase() :
 buttonCallback(this, &frontScreenViewBase::buttonCallbackHandler)
{
 __background.setPosition(0, 0, 800, 480);
 __background.setColor(touchgfx::Color::getColorFromRGB(0, 0, 0));
 add(__background);

 backgroundImage.setXY(160, 95);
 backgroundImage.setBitmap(touchgfx::Bitmap(BITMAP_BACKGROUND_ID));
 add(backgroundImage);

 switchScreenButton.setXY(331, 222);
 switchScreenButton.setBitmaps(touchgfx::Bitmap(BITMAP_ALTERNATE_THEME_IMAGES_WIDGETS_BUTTON_REGULAR_HEIGHT_36_SMALL_ROUND_ACTION_ID), touchgfx::Bitmap(BITMAP_ALTERNATE_THEME_IMAGES_WIDGETS_BUTTON_REGULAR_HEIGHT_36_SMALL_ROUND_PRESSED_ID));
 switchScreenButton.setAction(buttonCallback);
 add(switchScreenButton);

 testText.setXY(354, 186);
 testText.setColor(touchgfx::Color::getColorFromRGB(0, 0, 0));
 testText.setLinespacing(0);
 testText.setTypedText(touchgfx::TypedText(T___SINGLEUSE_VTF6));
 testText.setVisible(false);
 add(testText);
}

 

 

Also I have checked the memory where the text is stored and verified it to be correct.

pitbull_0-1738215195787.png

In map file following are the addresses where the generated text are stored in external flash

 

TextFlashSection
 0x9009b168 0x34
 *(TextFlashSection TextFlashSection.*)
 TextFlashSection
 0x9009b168 0x8 ./TouchGFX/generated/texts/src/LanguageGb.o
 0x9009b168 indicesGb
 TextFlashSection
 0x9009b170 0x22 ./TouchGFX/generated/texts/src/Texts.o
 0x9009b170 texts_all_languages
 *fill* 0x9009b192 0x2 
 TextFlashSection
 0x9009b194 0x8 ./TouchGFX/generated/texts/src/TypedTextDatabase.o
 0x9009b194 typedText_database_DEFAULT
 0x9009b198 typedTextDatabaseArray
 *(.gnu.linkonce.r.*)
 0x9009b19c . = ALIGN (0x4)
TEXT_LOCATION_FLASH_PRAGMA
KEEP extern const touchgfx::Unicode::UnicodeChar texts_all_languages[] TEXT_LOCATION_FLASH_ATTRIBUTE = {
 0x4e, 0x65, 0x77, 0x20, 0x54, 0x65, 0x78, 0x74, 0x0, // @0 "New Text"
 0x54, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x0 // @9 "Testing"
};

 

From the memory reader we are able to read the exact text stored at the address mentioned in the map file.

pitbull_1-1738216071087.png

Please correct me if anything is wrong here.

 

Also if I change the text configuration to following:-

pitbull_2-1738216359379.png

That is enable binary font file and disable remap texts then the Text is not displayed even when set to Visible but the task continues without getting stuck.

 

 

Thankyou

Regards,

Pitbull

pitbullAuthor
Associate III
January 30, 2025

Hello @MM..1 

I added the new text testText in the project and then did this testing.

pitbull_0-1738218071795.png

By default, I set it to hidden in touchGFX designer and performed the testing.

Sorry for disturbing you, but I really need some help and really very much thankful for your guidance and time.

 

Thankyou

 

Regards,

Pitbull

 

pitbullAuthorBest answer
Associate III
January 30, 2025

Hii @MM..1

 

Finally resolved the issue.

Following is the link 

https://forums.freertos.org/t/how-to-debug-to-resolve-configassert-pxqueue-uxitemsize-0-loop-error/17269 

Increasing the stack size for the tasks resolved the issue in the following post.

Similarly I increased the stack size for every task from 128 words to 512 words.

Thankyou @MM..1  @jumman_JHINGA @Flemming Gram CHRISTENSEN  for your time and support.

 

Thankyou

 

Regards,

Pitbull 

Flemming Gram CHRISTENSEN
ST Employee
January 30, 2025

Great news! Good job.

Where did you get the "previous" stack size? Should we change something in MX or in the documentation?

Best Regards

pitbullAuthor
Associate III
January 31, 2025

Hello @Flemming Gram CHRISTENSEN 

No I had not changed the default value in CubeIDE for minimum stack size. The previous stack size was the default value from cubeIDE. 

 

Thankyou once again for your support.

 

Regards,

Pitbull