This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM5728: Can unaligned memory access be enabled?

Part Number: AM5728

Hi,

Working on a *barebone* target that has an AM5728 processor. I've found that when the standard C memcpy() routine is called on data that is not 32-bit aligned, it will crash. I am using the GCC 9.2.1 ARM compiler that comes with Code Composer Studio 11.1.0.00011. I have used the -mno-unaligned-access compiler flag, however it does not help with calls to memcpy(). It's _not_ possible to ensure the data involved is on a 32-bit word boundary because I'm dealing with arbitrary string of bytes which can be anywhere. For example, I can't even use memcpy() to append a string of bytes to the end of another byte array. The latter is arbitrary length, so the destination address cannot be restricted to 32-bit alignment.

Is there a way to configure the AM5728 to gracefully handle unaligned memory access or if there is a way for memcpy() ot be modified to handle unaligned addresses? Thx!

  • Hi,

    I have used the -mno-unaligned-access compiler flag, however it does not help with calls to memcpy().

    -mno-unaligned-access flag disables the support for unaligned accesses. Can you try using -munaligned-access instead and see if it works. Also, please refer to documentation developer.arm.com/.../-munaligned-access---mno-unaligned-access for more details.

    Regards,
    Parth

  • Hi, we are using -mno-unaligned-access because the AM5728 does _not_ allow unaligned access (ie. it generates an exception). Despite using that flag, memcpy still performs unaligned memory access. I'm asking if there is a setting on the AM5728 processor that can be programmed to _allow_ it to accept unaligned access. If not that, then it would also help to know if there is a way to make memcpy not perform unaligned access at all. Thx.

  • Hi,

    A fellow teammate determined that the Thumb version of the libg.a library was being linked in which allows for unaligned access. After changing the linker setting to explicitly link in the regular ARM version of libg.a, there are no unaligned memory exception.

  • Hi Wetson,

    A fellow teammate determined that the Thumb version of the libg.a library was being linked in which allows for unaligned access. After changing the linker setting to explicitly link in the regular ARM version of libg.a, there are no unaligned memory exception.

    Does that resolve your issue? If yes, can you please share mode details on this? What changes did you make to link regular version of libg.a?

    Regards,
    Parth