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 NOT on 32-bit boundary

Running Keil 5.1 on Freescale K64 32MHz crystal.

Trying to copy data into a two-dimensional array. Copying to an array lastRequestedHeader[3][14] from an array requestedPacket[14].

I have no problem copying into lastRequestedHeader[0] because it starts at address 0x20004514 in memory, but copying to lastRequestedHeader[1] gives me an

Stepping through the memcpy call, I see the first two bytes being copied properly in the __aeabi_memcpy function, but then getting into __aeabi_memcpy4 is where my processor stops on an unaligned access fault

Any ideas? Is there another memcpy call that I can substitute into the project?

Parents
  • At the initial memcpy call:

    SRC = 0x20003C94
    DST = 0x20004522
    len = 0x0000000E
    Only source is 4-byte aligned.

    After the first two bytes, of course, the DST is now 4-byte aligned and the source is not.
    The call to __aeabi_memcpy4 has
    R0 = 0x20004524 (destination address)
    R1 = 0x20003C96 (source address)
    R2 - 0x0000000C (length)

    Then attempting to step into the __aeabi_memcpy4 hits the hard-fault, again with the unaligned access error

Reply
  • At the initial memcpy call:

    SRC = 0x20003C94
    DST = 0x20004522
    len = 0x0000000E
    Only source is 4-byte aligned.

    After the first two bytes, of course, the DST is now 4-byte aligned and the source is not.
    The call to __aeabi_memcpy4 has
    R0 = 0x20004524 (destination address)
    R1 = 0x20003C96 (source address)
    R2 - 0x0000000C (length)

    Then attempting to step into the __aeabi_memcpy4 hits the hard-fault, again with the unaligned access error

Children