414 views
in System Integration by
Hi,

We are using IMXRT1170 with Embedded Wizard 10.0. We have double framebuffer of resolution 800*480. We need to get the dump/data of the current rendering framebuffer(i.e. the front buffer) and store the dump in the Hyper Flash. How to get this framebuffer dump and store the same in Flash?

Best Regards,

Preethi S

1 Answer

0 votes
by

Hi Preethi,

please have a look into the file ewmain.c - there you will find the function EwUpdate() which is called by the main loop to perform the graphics composition into the current back-buffer:

static void EwUpdate( XViewport* aViewport, CoreRoot aApplication )
{
  XBitmap*       bitmap;
  GraphicsCanvas canvas     = EwNewObject( GraphicsCanvas, 0 );
  XRect          updateRect = {{ 0, 0 }, { 0, 0 }};

  if ( !canvas )
    return;

  if ( DisplayInfo.UpdateMode == EW_BSP_DISPLAY_UPDATE_NORMAL )
  {
    bitmap = EwBeginUpdate( aViewport );

    /* redraw the dirty area of the screen */
    if ( bitmap  )
    {
      GraphicsCanvas__AttachBitmap( canvas, (XHandle)bitmap );
      updateRect = CoreRoot__UpdateGE20( aApplication, canvas );
      GraphicsCanvas__DetachBitmap( canvas );
      EwEndUpdate( aViewport, updateRect );
    }
  }
...
}

The variable bitmap contains the current back-buffer. At the end of the function EwUpdate() you can call EwLockBitmap() in order to get read access to the content of the current back-buffer. Locking this bitmap ensures that all drawing operations are completed. Then you can iterate through the bitmap and store all pixel data within the HyperFlash (by using a suitable flash driver). When the operation is completed don't forget to call EwUnlockBitmap().

Does this answer your question?

Best regards,

Manfred.

by

Hi Manfred,

Tried to lock the bitmap and take the first pixel of the locked bitmap area. But a reset happening in the harware . Kindly find the code snippet for the same

static void EwUpdate( XViewport* aViewport, CoreRoot aApplication )
{
  XBitmap*       bitmap;
  GraphicsCanvas canvas     = EwNewObject( GraphicsCanvas, 0 );
  XRect          updateRect = {{ 0, 0 }, { 0, 0 }};
  XRect         lockArea;
  XBitmapLock*  lock;

 

  if ( !canvas )
    return;

  if ( DisplayInfo.UpdateMode == EW_BSP_DISPLAY_UPDATE_NORMAL )
  {
    bitmap = EwBeginUpdate( aViewport );

    /* redraw the dirty area of the screen */
    if ( bitmap  )
    {
      GraphicsCanvas__AttachBitmap( canvas, (XHandle)bitmap );
      updateRect = CoreRoot__UpdateGE20( aApplication, canvas );
      GraphicsCanvas__DetachBitmap( canvas );
      EwEndUpdate( aViewport, updateRect );
    }
  }
  else
  {
    int regions = CoreRoot__BeginUpdate( aApplication );

    while ( regions-- )
    {
      /* get rectangular area of the update region for scratch-pad buffer */
      if ( DisplayInfo.UpdateMode == EW_BSP_DISPLAY_UPDATE_SCRATCHPAD )
        updateRect = CoreRoot__GetUpdateRegion( aApplication, regions );

      /* iterate through all update areas */
      while ( EwBspDisplayGetUpdateArea( &updateRect ))
      {
        /* update the current subarea */
        bitmap = EwBeginUpdateArea( aViewport, updateRect );
        GraphicsCanvas__AttachBitmap( canvas, (XHandle)bitmap );
        CoreRoot__UpdateCanvas( aApplication, canvas, updateRect.Point1 );
        GraphicsCanvas__DetachBitmap( canvas );
        EwEndUpdate( aViewport, updateRect );
      }

      if ( DisplayInfo.UpdateMode != EW_BSP_DISPLAY_UPDATE_SCRATCHPAD )
        break;
    }
    CoreRoot__EndUpdate( aApplication );
  }
  /* Lock the entire bitmap for write operation */
  lockArea.Point1.X = 0;
  lockArea.Point1.Y = 0;
  lockArea.Point2.X = 800;
  lockArea.Point2.Y = 480;
  EwPrint("\n ******Lock Bitmap*****");
  lock              = EwLockBitmap( bitmap, 0, lockArea, 1, 0 );
  EwPrint("\n ******Bitmap locked*****%u",lock);         //Returns 0
  dest   = (unsigned int*)lock->Pixel1;                         //At this point there is a reset
  EwPrint("\n ******Bitmap locked dest:%d*****",dest);
  EwUnlockBitmap( bitmap );
}

Here if we try to print the lock object its returning 0 , then if we try to access lock->Pixel1 then there is a reset happening in hardware.

Kindly check and let me know if we miss something.

 

Best Regards,

Preethi S


 

by

Hi Preethi,

sorry, my first answer was not fully correct - the XBitmap of the framebuffer is only valid from EwBeginUpdate() until EwEndUpdate(). Thus the returned lock was 0.

Please find in the following a short example - tested on the target ;-)

Add the following function:

static void DumpFramebuffer( XBitmap* aBitmap )
{
  XRect          lockArea = {{ 0, 0 }, { 0, 0 }};
  XBitmapLock*   lock;

  if ( !aBitmap )
    return;

  /* lock the entire bitmap for read operation */
  EwPrint("Lock bitmap with size %d x %d\n", aBitmap->FrameSize.X, aBitmap->FrameSize.Y );
  lockArea.Point2 = aBitmap->FrameSize;
  lock = EwLockBitmap( aBitmap, 0, lockArea, 1, 0 );

  EwPrint("Address = 0x%08X\n", lock->Pixel1 );
  EwPrint("Pitch1X = %d\n", lock->Pitch1X );
  EwPrint("Pitch1Y = %d\n", lock->Pitch1Y );

  EwPrint("Finally unlock bitmap...\n" );
  EwUnlockBitmap( lock );
}

Then add the call within EwUpdate() - just before the EwEndUpdate() function call:

static void EwUpdate( XViewport* aViewport, CoreRoot aApplication )
{
  XBitmap*       bitmap = 0;
  GraphicsCanvas canvas     = EwNewObject( GraphicsCanvas, 0 );
  XRect          updateRect = {{ 0, 0 }, { 0, 0 }};

  if ( !canvas )
    return;

  if ( DisplayInfo.UpdateMode == EW_BSP_DISPLAY_UPDATE_NORMAL )
  {
    bitmap = EwBeginUpdate( aViewport );

    /* redraw the dirty area of the screen */
    if ( bitmap  )
    {
      GraphicsCanvas__AttachBitmap( canvas, (XHandle)bitmap );
      updateRect = CoreRoot__UpdateGE20( aApplication, canvas );
      GraphicsCanvas__DetachBitmap( canvas );

      DumpFramebuffer( bitmap );

      EwEndUpdate( aViewport, updateRect );
    }
  }
...
}

Does it work?

Best regards,

Manfred

Embedded Wizard Website | Privacy Policy | Imprint

...