131 views
in GUI Development by
Hi, EW team:

      In my Autosar project, I have EwProcess scheduled in a task of the lowest priority, so all other tasks can preempt it. When bitmap resource is loaded from external Norflash with EwCopy, preemption will interrupt the loading as well. To make use of the preemption time, I'd like to replace memcpy() with a DMA copy. So my questions are:

     1. Is this idea applicable?

    2. If yes, what should I take care of when implementing the DMA copy? Invalidating cache is my only concern now. I don't know if there is any potential violation against EW platform.

 

Thank you.

Best regards.

Stephen

1 Answer

0 votes
by
 
Best answer
Hi Stephen,

according to your description, you intend to use the DMA in a synchronous manner - this means, the GUI task will not continue until the DMA has completed the transfer. Just other tasks are using the CPU time. In this case I do not see any obstacles here. As you already mentioned, the address range of the DMA destination has to be invalidated for the D-Cache.

Best regards,

Manfred.
by
Hi,Manfred:

      That's what I intend to d.

     Thank you.

 

Best regards.

Stephen
by
Hi, Manfred

     The DMA hardware of RT1170 requires a larger size of transfer unit, for example 32 bytes to provide better performance, which further require the head address of source and destination aligned to 32. Is it possible to change the allocator of RTE to provide memory block  aligned to 32 bytes?

    Thank you.

Best regards.
Stephen
by
Hi Stephen,

modifying the allocator of RTE would be possible - but then you waste a lot of memory for all small objects like Chora objects, strings, ...

In principle on iMXRT1170 the bitmaps are already aligned to 64/32/16 bytes (depending on their color format) - so there should be no big change necessary.

Please let me know what kind of data and in which scenario you want to transfer via DMA - then it will be easier to find a proper solution.

Best regards,

Manfred.
by
Hi, Manfred:

    I'd like to use DMA transfer when data is loaded from norflash, and when data is copied within  RAM. Yes, maybe whenever memcpy() is used.  As my original post said, all these copy work was done in a task with the lowest priority. DMA transfer will not suffer from the interrupt caused by preemption.

   Further, in practice, we find DMA copy with a larger unit such as 32 bytes shows obvious performance advantage over memcpy().

   As to your doubt of wasting memory. We have a 32MB RAM. If 1000 objects are needed at once, 32kB memory  would be wasted at most. It's a price I think we can afford for performance, at least we'd like to have a try.

  Thank you.

Best regards.

Stephen
by

Hi Stephen,

you can try the following modification in order to ensure that EwAlloc returns always 32 byte aligned addresses:

void* EwAlloc( int aSize )
{
  /* allocate necessary memory plus 32 bytes plus size of a 32 bit address */
  void* mem = EwAllocHeapBlock( aSize + 32 + 4 );

  /* create a 32 byte-aligned address */
  unsigned long addr = ((unsigned long)mem + 32 + 4 ) & 0xFFFFFFE0;

  /* save original address 4 bytes before the aligned address */
  *((unsigned long*)(addr - 4)) = (unsigned long)mem;

  /* return the aligned address */
  return (void*)addr;
}


void EwFree( void* aMemory )
{
  /* read original address 4 bytes before the aligned address */
  void* mem = (void*)(*((unsigned long*)((unsigned long)aMemory - 4 )));

  /* free the original memory */
  EwFreeHeapBlock( mem );
}

Does it work?

Best regards,

Manfred.

by
Hi, Manfred:

     I still need your help. I need to confirm what resources need to be copied into RAM in runtime. Compressed bitmaps, strings, and VG strings? I have to define alignment of 32 bytes for all these const  resources.

 

   Thank you.

Best regards.

Stephen

    .
by
Hi Stephen,

I have no idea what you want to achieve....

Initially, you wanted to make some DMA transfers in the background - now you want to copy bitmaps, strings, .... Please note that the linker/locator provides the addresses of all constant data.

Best regards

Manfred.

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...