<?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: Hardfault (unaligned) using USB &amp;amp; ENET in i.MX RT Crossover MCUs</title>
    <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Hardfault-unaligned-using-USB-amp-ENET/m-p/1698800#M26196</link>
    <description>&lt;P&gt;I switched to NewlibNano ( nohost ) and it worked. Optimization was at zero all along.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Aug 2023 16:18:49 GMT</pubDate>
    <dc:creator>GoatRope</dc:creator>
    <dc:date>2023-08-03T16:18:49Z</dc:date>
    <item>
      <title>Hardfault (unaligned) using USB &amp; ENET</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Hardfault-unaligned-using-USB-amp-ENET/m-p/1697900#M26174</link>
      <description>&lt;P&gt;I get a hardfault ( unaligned ) using an app based on combining 1024 samples lwip_httpsrv_freertos and host_msd_fatfs_freertos. Newbie attempt on 1024 eval board.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Deviations from the samples:&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) heap4 model , ucHeap&lt;/P&gt;&lt;P&gt;2) No off chip RAM used; 192K DTC used&lt;/P&gt;&lt;P&gt;3) code added to align ( 8 )&amp;nbsp; the source for memcpy in&amp;nbsp;ENET_SendFrame() . This can avoid the hardfault here but same issue arises&amp;nbsp; elsewhere.&amp;nbsp;&lt;/P&gt;&lt;P&gt;4)&amp;nbsp;xTaskCreate(USB_HostTask) and&amp;nbsp;xTaskCreate(USB_HostApplicationTask) both commented out.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Symptom: Enet runs fine unless I invoke this function within USB_HostApplicationInit:&amp;nbsp;&lt;/P&gt;&lt;P&gt;status = USB_HostInit(CONTROLLER_ID, &amp;amp;g_HostHandle, USB_HostEvent); // &amp;lt;== Problematic?&lt;/P&gt;&lt;P&gt;Would highly welcome questions, feedback on specific issues, and general input as to how to debug and/or fix this.&amp;nbsp; Attached are linker, memory and hardfault screenshots. Thanks, dB&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2023 18:30:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Hardfault-unaligned-using-USB-amp-ENET/m-p/1697900#M26174</guid>
      <dc:creator>GoatRope</dc:creator>
      <dc:date>2023-08-02T18:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: Hardfault (unaligned) using USB &amp; ENET</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Hardfault-unaligned-using-USB-amp-ENET/m-p/1698779#M26195</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Try a USB + ENET reference from here too:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.utasker.com/iMX/RT1024.html" target="_blank"&gt;https://www.utasker.com/iMX/RT1024.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;If you are sure it is alignment you could try adding -mno-unaligned-access to the compiler flag settings. This will ensure GCC doesn't generate mis-aligned addresses (which it does frequently when max. optimisation is used) in packed structs or when generally optimising.&lt;/P&gt;&lt;P&gt;If that doesn't help you can easily identify the cause of such faults if you modify the hard fault handler to be an empty interrupt&lt;/P&gt;&lt;P&gt;&lt;EM&gt;void hardfault(void)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;{&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;// optionally add a counter and set a break point on it&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; volatile static int iCnt = 0;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; iCnt++;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;When it hits just switch to disassembler mode and step out of the hard fault which will return to the &lt;U&gt;instruction that caused it&lt;/U&gt;. Then see the instruction (probably a pointer it is using is not aligned), where it was set and why it is not as it should be.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Mark&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;i.MX and Kinetis stock available at &lt;A href="https://www.utasker.com/Shop/semi.html" target="_blank"&gt;https://www.utasker.com/Shop/semi.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2023 15:56:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Hardfault-unaligned-using-USB-amp-ENET/m-p/1698779#M26195</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2023-08-03T15:56:17Z</dc:date>
    </item>
    <item>
      <title>Re: Hardfault (unaligned) using USB &amp; ENET</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Hardfault-unaligned-using-USB-amp-ENET/m-p/1698800#M26196</link>
      <description>&lt;P&gt;I switched to NewlibNano ( nohost ) and it worked. Optimization was at zero all along.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2023 16:18:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Hardfault-unaligned-using-USB-amp-ENET/m-p/1698800#M26196</guid>
      <dc:creator>GoatRope</dc:creator>
      <dc:date>2023-08-03T16:18:49Z</dc:date>
    </item>
  </channel>
</rss>

