cancel
Showing results for 
Search instead for 
Did you mean: 

TochGFX Usage Fault "__ARM_common_memcpy4_8" (touchgfx_core.lib) (TouchGFX v 4.13.0)

MVoss.2
Associate II

0693W000003OgmRQAS.pngHello,

i have a problem with TouchGFX. After filling the framebuffer via DMA2D (DMA2D class of TouchGFX) i got a Usage Fault "unaligned". Last called function was __ARM_common_memcpy4_8 in touchgfx lib. When i have a look at the register values the register R0 has a not 4 byte aligned adress. Further the adress referenced to member variable "lastRects" (type vector template class) of Application class (member of FrontendHeap). Using the ARM "__((aligned (4)))" doesn't fix this problem. Further I don't know where exactly the instance is declared? Is it really because of the unaligned adress? How can I solve the problem?

Thanks and greetz

Note:

I found out that it only happens when I'm using double/multiple frambuffer. I'm working with lcd display with RGB Interface. So I want to use multible framebuffer.

Ehat could be the problem? Maybe any faulty settings?

I am setting frame buffer adresses like this:

 hal.setFrameBufferStartAddresses(adress frame buffer 1,adress frame buffer 2,adress frame buffer animation);

frame buffer 1 adress 0xC0000000

frame buffer 2 adress 0xC0054600

animation buffer adress 0xC00A8C00

Each frame buffer has a size from lcd width(480)*height(360) * 2 (because of using rgb565)

8 REPLIES 8
Martin KJELDSEN
Chief III

Which MCU? You may need to protect your framebuffer memory region with MPU to not get unaligned errors.

MVoss.2
Associate II

I'm working on STM32F750Z8 with external Flash (via QuadSpi) and external SDRAM for frambuffer. The lcd display is RGB interface type controlled by LTDC of microcontroller. The MPU is already defined. More precisely, it is protected over the entire SDRAM (in my case 0xC0000000 until 8MB size).

I really don't know what could be wrong.

Is the "__ARM_common_memcpy4_8" function a own TouchGFX function? Not like standard "memcpy" function?

I tried to overload "memcpy" to find out when it breaks down. Unfortunatelly "memcpy" won't be called.

Martin KJELDSEN
Chief III

Okay, what does your MPU configuration look like? You need to configure the proper memory type for that region to not have unaligned access - RAM accesses on Cortex-M7 does not need to be aligned in any specific way (although access is faster when aligned). 0xC0000000-0xDFFFFFFF is Device Memory, so configure the MPU to see this region as Normal Memory instead.

MVoss.2
Associate II

Thanks for your support. My config of MPU looks like following:

MPU_Region_InitTypeDef MPU_InitStruct = {0};

 MPU_InitStruct.Enable = MPU_REGION_ENABLE;

  MPU_InitStruct.Number = MPU_REGION_NUMBER1;

  MPU_InitStruct.BaseAddress = 0xC0000000;

  MPU_InitStruct.Size = MPU_REGION_SIZE_8MB;

  MPU_InitStruct.SubRegionDisable = 0x0;

  MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;

  MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;

  MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;

  MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;

  MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;

  MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;

Martin KJELDSEN
Chief III
  MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;

Try changing the memory access type.

MVoss.2
Associate II

Unfortunatelly witout any success. MPU_TEX_LEVEL1 (MPU_TEX_LEVEL2 as well) still running into usage fault :(

This is the topic, Martin was talking about:

https://www.keil.com/support/docs/3777.htm

MVoss.2
Associate II

Good to know, Thank you, didn't know that....

As mentioned I'm using MPU with this config now:

 MPU_InitStruct.Enable = MPU_REGION_ENABLE;

  MPU_InitStruct.Number = MPU_REGION_NUMBER1;

  MPU_InitStruct.BaseAddress = 0xC0000000;

  MPU_InitStruct.Size = MPU_REGION_SIZE_8MB;

  MPU_InitStruct.SubRegionDisable = 0x0;

  MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;

  MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;

  MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;

  MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;

  MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;

  MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;

I have an external Flash (located at 0x90000000) which has the same MPU settings.

Unfortunately I got still the Usage Fault. ;-( Remapping the adress of SDRAM is no option.

But is there are way to find the TouchGFX lib naturally aligned? (compiled with --no_unaligned_access)