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...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...