<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: unaligned access fault caused by memcpy in lwip in i.MX RT Crossover MCUs</title>
    <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/unaligned-access-fault-caused-by-memcpy-in-lwip/m-p/1444217#M19170</link>
    <description>&lt;P&gt;I am getting same error Active Fault&amp;nbsp;@ queue.c line 1479&lt;/P&gt;&lt;P&gt;Unaligned access (8)&lt;/P&gt;</description>
    <pubDate>Thu, 14 Apr 2022 15:07:28 GMT</pubDate>
    <dc:creator>snahmad</dc:creator>
    <dc:date>2022-04-14T15:07:28Z</dc:date>
    <item>
      <title>unaligned access fault caused by memcpy in lwip</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/unaligned-access-fault-caused-by-memcpy-in-lwip/m-p/1082110#M9240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I&amp;nbsp; am trying to add exception handling functionalities in my software and there is a problem of usage fault by unaligned memory access after enabling the exception handler. calling memcpy&amp;nbsp; inside netifapi_netif_set_up() caused the fault. What should I do to solve this fault? Is it better to disable the unaligned access fault? I tried to use the options -munaligned-access or -mnounaligned-access and none of them solved the issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following are the information of my project environment:&lt;/P&gt;&lt;UL style="list-style-type: disc;"&gt;&lt;LI&gt;Board: imxrt1060 evk&lt;/LI&gt;&lt;LI&gt;SDK: 2.6.2 (SDK_2.6.2_EVK-MIMXRT1060-FreeRTOS.zip)&lt;/LI&gt;&lt;LI&gt;Project: evkmimxrt1060_lwip_tcpecho_freertos&lt;/LI&gt;&lt;LI&gt;Library: Newlib (semihost)&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2020 02:44:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/unaligned-access-fault-caused-by-memcpy-in-lwip/m-p/1082110#M9240</guid>
      <dc:creator>creatorwonny</dc:creator>
      <dc:date>2020-05-28T02:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: unaligned access fault caused by memcpy in lwip</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/unaligned-access-fault-caused-by-memcpy-in-lwip/m-p/1082111#M9241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What optimisation do you have enabled?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The GCC compiler version used by MCUXpresso has a bug with misaligned accesses when optimisation is high and if you keep the level no higher that -O1 for code that fails it may work around it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have, for example, a misaligned error on the following code if an array of bytes is not long word aligned:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new, courier, monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CBW_READ_10 *ptrRead = (CBW_READ_10 *)ptrCBW-&amp;gt;CBWCB;&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new, courier, monospace; "&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ulLogicalBlockAdr = ((ptrRead-&amp;gt;ucLogicalBlockAddress[0] &amp;lt;&amp;lt; 24) | (ptrRead-&amp;gt;ucLogicalBlockAddress[1] &amp;lt;&amp;lt; 16) | (ptrRead-&amp;gt;ucLogicalBlockAddress[2] &amp;lt;&amp;lt; 8) | ptrRead-&amp;gt;ucLogicalBlockAddress[3]);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error doesn't occur with other compilers (eg. IAR or when GCC optimisation is lowered).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The reason for the error on this case (the C code access to 4 bytes is not alignment dependent) is due to the optimiser using an M7 byte reversal instruction to change the endian ordering (very efficient, rather than 4 byte reads and shifts) but it also loads the register with a long word move (not supported by the M7 if not aligned) and so fails in case the byte array happens to not be aligned.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had the same issue a number of times and in some cases I could force the byte array to be aligned to get around it but generally this is not practical.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may find that the library routines you use are also using techniques to copy the largest size that is possible (eg. long to long rather than on a byte basis, when possible) and in conjunction with GCC optimisation similar things may go wrong. &lt;STRONG&gt;By watching the disassembled code the error should be visible&lt;/STRONG&gt; - if it is reliable with lower optimisation it may be something similar.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[uTasker project developer for Kinetis and i.MX RT]&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2020 17:07:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/unaligned-access-fault-caused-by-memcpy-in-lwip/m-p/1082111#M9241</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2020-05-28T17:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: unaligned access fault caused by memcpy in lwip</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/unaligned-access-fault-caused-by-memcpy-in-lwip/m-p/1082112#M9242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't use optimization so the optimization level is -O0. For now, I decided not to enable the unaligned access usage fault because I don't know how long it will take to solve this problem or if it's really possible. Even so, I really want to know if this is possible and how.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Wonny&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 May 2020 00:11:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/unaligned-access-fault-caused-by-memcpy-in-lwip/m-p/1082112#M9242</guid>
      <dc:creator>creatorwonny</dc:creator>
      <dc:date>2020-05-29T00:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: unaligned access fault caused by memcpy in lwip</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/unaligned-access-fault-caused-by-memcpy-in-lwip/m-p/1241547#M13044</link>
      <description>&lt;P&gt;Please check your MPU configuration&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 07:04:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/unaligned-access-fault-caused-by-memcpy-in-lwip/m-p/1241547#M13044</guid>
      <dc:creator>crist_xu</dc:creator>
      <dc:date>2021-03-08T07:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: unaligned access fault caused by memcpy in lwip</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/unaligned-access-fault-caused-by-memcpy-in-lwip/m-p/1444217#M19170</link>
      <description>&lt;P&gt;I am getting same error Active Fault&amp;nbsp;@ queue.c line 1479&lt;/P&gt;&lt;P&gt;Unaligned access (8)&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 15:07:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/unaligned-access-fault-caused-by-memcpy-in-lwip/m-p/1444217#M19170</guid>
      <dc:creator>snahmad</dc:creator>
      <dc:date>2022-04-14T15:07:28Z</dc:date>
    </item>
  </channel>
</rss>

