Display and TouchGFX
Driver layers
The graphics stack on an STM32 with a parallel or DSI panel:
application
→ TouchGFX or LVGL
→ STM32 LCD Utility Drivers (stm32_lcd.c)
→ BSP LCD driver (stm32xxxxx_lcd.c)
→ component driver (nt35510, otm8009a, ...)
→ LTDC / DSI peripheral
STM32 LCD Utility Drivers are ST's lightweight graphics layer: basic 2D primitives that work with any panel, sitting on top of the BSP LCD drivers, which handle the panel-specific work.
Each layer has to come from a consistent version. Mixing a new component driver under an old BSP is what most of the failures below come down to.
Fixing a corrupted BSP demo display
ST ships a BSP example for most evaluation and Discovery boards, demonstrating the on-board components — display, touch panel, audio and so on.
If the screen shows garbage and the display hardware differs from what the board originally shipped with, ask on the ST Community first. Panel initialisation sequences are not something to reverse-engineer by trial and error.
Some combinations of STM32CubeIDE and MCU Package versions generate a STM32H747I-DISCO BSP example that does not compile. Repair steps:
- Copy in the new LCD component driver,
Drivers/BSP/Components/nt35510. - Open
.projectin a text editor and replacePARENT-1-PROJECT_LOC/DriverswithPARENT-2-PROJECT_LOC/Drivers. If files are still not found at compile time, change the remainingPARENT-1entries toPARENT-2individually — this is Eclipse's encoding of a relative path, and the generated project gets the depth wrong.Utilities/lcd/stm32_lcd.cis a common casualty. - Ignore C/C++ indexer errors during the process; they resolve once the paths are correct and the index is rebuilt.
- Update
Drivers/BSP/STM32H747I-DISCO. Only the*_lcd.*files need replacing if the LCD is the sole concern. - Copy in the LCD Utility Drivers.
- After flashing, content the application never drew, or extra coloured noise, points at non-volatile memory that was not cleared — an SDRAM or external flash frame buffer holding data from a previous run.
Once BSP_LCD_Init returns successfully, this should paint the whole screen
red:
BSP_LCD_FillRect(0, 0, 0, 800, 480, 0xFFFF0000UL); // ARGB8888: opaque red
The colour is ARGB8888 — FF alpha, FF red, 00 green, 00 blue. A frame
buffer configured for RGB565 interprets the same value completely differently,
which is a quick way to confirm the pixel format matches the LTDC layer
configuration.
Panel variants on the same board
Board revisions change panels without changing the board name, and the wrong component driver produces a blank or scrambled screen rather than an error. On the STM32F769I-DISCO:
| Board revision | Panel | Component driver |
|---|---|---|
| Older MB1166 | FRIDA FRD397B25009-D-CTK | OTM8009A |
| MB1166 rev A-09 and later (LCD IC REVB03) | FRIDA FRD400B25025-A-CTK | NT35510 |
Read the revision printed on the board and match the driver to it. The same
applies to the H747I-DISCO, which is why the repair steps above start by
replacing the nt35510 component.
TouchGFX
- The
CRCperipheral must be enabled and initialised, or the licence check fails. TouchGFX is licensed for ST silicon only and reads the CRC unit to confirm it. This is the usual explanation for a build that runs but renders nothing. In CubeMX:Computing ▸ CRC ▸ Activated. - Use a timebase other than SysTick. Set
SYS ▸ Timebase Sourceto a basic timer — TIM6 or TIM7 — so the HAL tick survives the RTOS taking over SysTick. See HAL_GetTick always returns 0. - Errors in the start-up file (
startup_stm32h747xihx.sand equivalents) can crash TouchGFX indirectly. A wrong vector table or stack size surfaces as a graphics fault rather than an obvious start-up failure. - Post Generate Target has serious bugs on dual-core parts such as the H7. Check what it produced before building, or drive generation manually.
- TouchGFX Designer only needs
ApplicationTemplate.touchgfx.partto begin with; the rest of the project structure is generated from it.
Generator settings
In CubeMX, under Middleware ▸ Software Packs Component Selector ▸ X-CUBE-TOUCHGFX, select the version, then set Graphics Application: true.
X-CUBE-TOUCHGFX:
Interface: LTDC
Application Tick Source: LTDC
TouchGFX Generator:
Display:
Width: 480
Height: 272
The display dimensions must match the panel exactly. Getting them wrong gives a picture that is offset, torn or scrolling rather than a clean failure — the frame buffer stride no longer matches what the LTDC scans out. Common panels:
| Board | Resolution |
|---|---|
| STM32F746G-DISCO | 480 × 272 |
| STM32F769I-DISCO | 800 × 480 |
| STM32H7B3I-EVAL (ROCKTEK RK070ER9427-CT) | 800 × 480 |
| STM32H747I-DISCO | 800 × 480 |
The LTDC layer settings in CubeMX carry the same numbers under Multimedia ▸ LTDC ▸ Layer Settings ▸ Image Width / Image Height, and both places must agree.
After changing any of this, Clean Project then Build Project. TouchGFX
generates source into the project tree, and a stale object file from the
previous geometry links without complaint.