Jump to content

A bug in the STM32 LTDC Driver

Recommended Posts

Line 545 of gdisp_lld_STM32LTDC.c currently reads:

srcstart = LTDC_PIXELBYTES * ((gU32)g->p.x2 * g->p.y1 * + g->p.x1) + (gU32)g->p.ptr;

Given that the operator "* +" clearly compiles but is nonsense, the correct line of code should be:

srcstart = LTDC_PIXELBYTES * ((gU32)g->p.x2 * g->p.y1 + g->p.x1) + (gU32)g->p.ptr;

I think this is a plain and simple typo, but it has been there since uGFX 2.7 or earlier.  This means the srcstart (the starting address of the blit source) is not being calculated correctly.  I believe the reason this slipped passed the radar in v2.7 is that, for some unknown reason, this same calculation was repeated (without the typo) in line 578, where DMA2D->FGMAR was set to the source address.  So in 2.7, the only time the erroneous value was used was in cache flushing and invalidation.  In the latest (2.9 release and guthub) version, the erroneously-calculated srcstart is being used directly to set FGMAR (as it should), but due to the typo, the resulting blit regions are copying essentially from random areas as their source.

As for reproduction steps, any blit from a pixmap to the display will calculate incorrectly except for, I suppose, blits with a source of (0,0) and a few other lucky combinations.

I just thought I would report this to be helpful.

Link to comment
Share on other sites

  • 1 month later...
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...