cancel
Showing results for 
Search instead for 
Did you mean: 

SDRAM and unaligned memcpy causes exception

wilfred
Associate
Posted on August 13, 2015 at 00:29

I am using the The STM32F7 discovery kit (32F746GDISCOVERY) kit and I have run into an issue with memcpy using IAR (which seems to do some clever internal aligning and then copying 4 byte words).

In short, the copy fails if the SDRAM address is unaligned.

I can also simulate this error using BSP_SDRAM_WriteData

The following works:

 BSP_SDRAM_WriteData(0xC0000008, (uint32_t*)0x0806EB57, 2048);

The following fails:

BSP_SDRAM_WriteData(0xC0000009, (uint32_t*)0x0806EB58, 2048);

Notice that in (1) above, the ''to address'' is aligned and in (2), the ''to address'' is unaligned.

We are using the provided code for SDRAM initialization.

Please advice
1 REPLY 1
Nesrine M_O
Lead II
Posted on August 13, 2015 at 15:02

Hi, 

Any unaligned access to Device or Strongly-ordered memory generates alignment UsageFault and therefore does not cause any AXI transfer. 

So to resolve problem you can modify the default MPU attribute (Configure the MPU attributes as Write Through for SDRAM) or remap SDRAM at 0x60000000.

Have a look to

http://infocenter.arm.com/help/topic/com.arm.doc.ddi0489b/DDI0489B_cortex_m7_trm.pdf

 it may be very helpful.

Also I suggest you to try the example: STM32Cube_FW_F7_V1.1.0\Projects\STM32756G_EVAL\Examples\FMC\FMC_SDRAM_DataMemory

-Syrine-