<?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 Hard fault when erasing internal flash memory in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Hard-fault-when-erasing-internal-flash-memory/m-p/1057412#M57012</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;We are using FRDMK64F and are trying to erase 4096 bytes of internal flash memory from address 0xFD000.&lt;/P&gt;&lt;P&gt;We are facing hard fault when executing the code&amp;nbsp;&lt;/P&gt;&lt;P&gt;"callFtfxRunCommand((FTFx_REG8_ACCESS_TYPE)(&amp;amp;FTFx-&amp;gt;FSTAT));"&lt;/P&gt;&lt;P&gt;inside the "ftfx_command_sequence" function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The fault shown on debug is "BFARVALID" i.e bus fault Address Register Vaild flag and "PRECISERR" Precise data bus error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The weird thing is that we are able to erase this same sector from other part of code (handling different functionality).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have tried disabling cache as suggested in forums but could not resolve the issue.&lt;/P&gt;&lt;P&gt;To disable the cache we did:&lt;/P&gt;&lt;P&gt;FMC-&amp;gt;PFB0CR &amp;amp;= 0xFFFFFFE0;&lt;BR /&gt;FMC-&amp;gt;PFB1CR &amp;amp;= 0xFFFFFFE0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It might be useful to know that we are using a bootloader and the application starts from address 0x28000.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help will be appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Jun 2020 12:24:53 GMT</pubDate>
    <dc:creator>yash_bhatt1</dc:creator>
    <dc:date>2020-06-17T12:24:53Z</dc:date>
    <item>
      <title>Hard fault when erasing internal flash memory</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Hard-fault-when-erasing-internal-flash-memory/m-p/1057412#M57012</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;We are using FRDMK64F and are trying to erase 4096 bytes of internal flash memory from address 0xFD000.&lt;/P&gt;&lt;P&gt;We are facing hard fault when executing the code&amp;nbsp;&lt;/P&gt;&lt;P&gt;"callFtfxRunCommand((FTFx_REG8_ACCESS_TYPE)(&amp;amp;FTFx-&amp;gt;FSTAT));"&lt;/P&gt;&lt;P&gt;inside the "ftfx_command_sequence" function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The fault shown on debug is "BFARVALID" i.e bus fault Address Register Vaild flag and "PRECISERR" Precise data bus error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The weird thing is that we are able to erase this same sector from other part of code (handling different functionality).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have tried disabling cache as suggested in forums but could not resolve the issue.&lt;/P&gt;&lt;P&gt;To disable the cache we did:&lt;/P&gt;&lt;P&gt;FMC-&amp;gt;PFB0CR &amp;amp;= 0xFFFFFFE0;&lt;BR /&gt;FMC-&amp;gt;PFB1CR &amp;amp;= 0xFFFFFFE0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It might be useful to know that we are using a bootloader and the application starts from address 0x28000.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help will be appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jun 2020 12:24:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Hard-fault-when-erasing-internal-flash-memory/m-p/1057412#M57012</guid>
      <dc:creator>yash_bhatt1</dc:creator>
      <dc:date>2020-06-17T12:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: Hard fault when erasing internal flash memory</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Hard-fault-when-erasing-internal-flash-memory/m-p/1057413#M57013</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="text-align: justify;"&gt;Hello &lt;A _jive_internal="true" class="" data-content-finding="Community" data-userid="354520" data-username="yash.bhatt1@einfochips.com" href="https://community.nxp.com/people/yash.bhatt1@einfochips.com"&gt;yash.bhatt1&lt;/A&gt; &lt;/P&gt;&lt;P style="text-align: justify;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Wich functions are you using to erase the flash sector? I suggest you use the function:&lt;/P&gt;&lt;P style="text-align: justify;"&gt;FLASH_Erase(flash_config_t *config, uint32_t start, uint32_t lengthInBytes, uint32_t key)&lt;/P&gt;&lt;P style="text-align: justify;"&gt;This function erases the appropriate number of flash sectors based on the desired start address and length in bytes. I tested it by my side with the values you provided and functioned well.&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;I suggest you to first verify the status of the Flash, it is recommended that the flash is unsecured to erase the sector.&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Let me know if this is helpful, if you have more questions do not hesitate to ask me.&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Best regards,&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Omar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jun 2020 19:58:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Hard-fault-when-erasing-internal-flash-memory/m-p/1057413#M57013</guid>
      <dc:creator>Omar_Anguiano</dc:creator>
      <dc:date>2020-06-18T19:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: Hard fault when erasing internal flash memory</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Hard-fault-when-erasing-internal-flash-memory/m-p/1057414#M57014</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/nxf54944"&gt;nxf54944&lt;/A&gt;‌,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We were able to resolve this issue. We had to disable the interrupts before the erase and write on internal flash and then enable the interrupts.&lt;/P&gt;&lt;P&gt;Got this from one of the NXP threads.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yash&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Jun 2020 11:25:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Hard-fault-when-erasing-internal-flash-memory/m-p/1057414#M57014</guid>
      <dc:creator>yash_bhatt1</dc:creator>
      <dc:date>2020-06-20T11:25:11Z</dc:date>
    </item>
  </channel>
</rss>

