This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

memcpy unalign bug

test code:
static int buffer[128];

memcpy_test(int * p)
{ memcpy(buffer, p, 128);
}

memcpy_test(0x00000000) ==> OK
memcpy_test(0x00000001) ==> unalign fault

use MDK libc memcpy, when dst or src is align,
auto higher optimization to used memcpy4.

but use instruction LDM.
so, if the arg p is unalign, fault....

info:
cortex-M3/M4
MDK 3.x/4.x/5.x

quote arm doc:
The Cortex-M4 processor supports unaligned access only for the following instructions:
• LDR, LDRT
• LDRH, LDRHT
• LDRSH, LDRSHT
• STR, STRT
• STRH, STRHT
All other load and store instructions generate a UsageFault exception if they perform an
unaligned access, and therefore their accesses must be address aligned

Unaligned LDM, STM, LDRD, and STRD instructions always fault irrespective of
whether UNALIGN_TRP is set to 1.