<?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 LPC55xx (Mass) Flash erase with IAP in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55xx-Mass-Flash-erase-with-IAP/m-p/1312881#M45956</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'm using LPC5526 with SDK v2.8.0 with Eclipse IDE (2020-06)&amp;nbsp; (so not MCUXpresso).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'm trying to do a runtime mass erase of the flash.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I get the mass erase working with the FLASH_Erase API, specifying the full flash area to erase.&lt;BR /&gt;But (obviously) the controller is not capable of doing anything afterwards.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I would like to at least do a&amp;nbsp;FLASH_VerifyErase afterwards.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So I implemented a function in RAM (see&amp;nbsp;&lt;A href="https://mcu-things.com/blog/ramfunc-gcc/" target="_blank"&gt;https://mcu-things.com/blog/ramfunc-gcc/&lt;/A&gt;), calling the IAP ROM functions directly (which I figured should work):&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;__attribute__((long_call, noinline, section(".ramfunc"))) void MassErase(void) {
   flash_config_t flInst;
   UINT32 flashBlockBase = 0;
   UINT32 flashTotalSize = 0;

   if (FLASH_API_TREE-&amp;gt;flash_init(&amp;amp;flInst) == kStatus_FLASH_Success) {

      FLASH_API_TREE-&amp;gt;flash_get_property(&amp;amp;flInst, kFLASH_PropertyPflashBlockBaseAddr, &amp;amp;flashBlockBase);
      FLASH_API_TREE-&amp;gt;flash_get_property(&amp;amp;flInst, kFLASH_PropertyPflashTotalSize, &amp;amp;flashTotalSize);

      if (FLASH_API_TREE-&amp;gt;flash_erase(&amp;amp;flInst, flashBlockBase, flashTotalSize, kFLASH_ApiEraseKey) {
         if (FLASH_API_TREE-&amp;gt;flash_verify_erase(&amp;amp;flInst, flashBlockBase, flashTotalSize) == kStatus_FLASH_Success) {
            // Mass erase successfull
         }
      }
   }
}&lt;/LI-CODE&gt;&lt;P&gt;I verified code is running in RAM.&lt;/P&gt;&lt;P&gt;flash_init returns success and flash_get_property returns correct data, so ROM API calls seems to work OK.&lt;/P&gt;&lt;P&gt;Also&amp;nbsp;flash_erase works (in the end Flash is erased), but I still get a SIGTRAP before flash_verify_erase can be executed.&lt;/P&gt;&lt;P&gt;Any idea what I can be doing wrong?&lt;/P&gt;</description>
    <pubDate>Sun, 25 Jul 2021 20:58:48 GMT</pubDate>
    <dc:creator>janpieterderuit</dc:creator>
    <dc:date>2021-07-25T20:58:48Z</dc:date>
    <item>
      <title>LPC55xx (Mass) Flash erase with IAP</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55xx-Mass-Flash-erase-with-IAP/m-p/1312881#M45956</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'm using LPC5526 with SDK v2.8.0 with Eclipse IDE (2020-06)&amp;nbsp; (so not MCUXpresso).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'm trying to do a runtime mass erase of the flash.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I get the mass erase working with the FLASH_Erase API, specifying the full flash area to erase.&lt;BR /&gt;But (obviously) the controller is not capable of doing anything afterwards.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I would like to at least do a&amp;nbsp;FLASH_VerifyErase afterwards.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So I implemented a function in RAM (see&amp;nbsp;&lt;A href="https://mcu-things.com/blog/ramfunc-gcc/" target="_blank"&gt;https://mcu-things.com/blog/ramfunc-gcc/&lt;/A&gt;), calling the IAP ROM functions directly (which I figured should work):&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;__attribute__((long_call, noinline, section(".ramfunc"))) void MassErase(void) {
   flash_config_t flInst;
   UINT32 flashBlockBase = 0;
   UINT32 flashTotalSize = 0;

   if (FLASH_API_TREE-&amp;gt;flash_init(&amp;amp;flInst) == kStatus_FLASH_Success) {

      FLASH_API_TREE-&amp;gt;flash_get_property(&amp;amp;flInst, kFLASH_PropertyPflashBlockBaseAddr, &amp;amp;flashBlockBase);
      FLASH_API_TREE-&amp;gt;flash_get_property(&amp;amp;flInst, kFLASH_PropertyPflashTotalSize, &amp;amp;flashTotalSize);

      if (FLASH_API_TREE-&amp;gt;flash_erase(&amp;amp;flInst, flashBlockBase, flashTotalSize, kFLASH_ApiEraseKey) {
         if (FLASH_API_TREE-&amp;gt;flash_verify_erase(&amp;amp;flInst, flashBlockBase, flashTotalSize) == kStatus_FLASH_Success) {
            // Mass erase successfull
         }
      }
   }
}&lt;/LI-CODE&gt;&lt;P&gt;I verified code is running in RAM.&lt;/P&gt;&lt;P&gt;flash_init returns success and flash_get_property returns correct data, so ROM API calls seems to work OK.&lt;/P&gt;&lt;P&gt;Also&amp;nbsp;flash_erase works (in the end Flash is erased), but I still get a SIGTRAP before flash_verify_erase can be executed.&lt;/P&gt;&lt;P&gt;Any idea what I can be doing wrong?&lt;/P&gt;</description>
      <pubDate>Sun, 25 Jul 2021 20:58:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55xx-Mass-Flash-erase-with-IAP/m-p/1312881#M45956</guid>
      <dc:creator>janpieterderuit</dc:creator>
      <dc:date>2021-07-25T20:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: LPC55xx (Mass) Flash erase with IAP</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55xx-Mass-Flash-erase-with-IAP/m-p/1312882#M45957</link>
      <description>&lt;P&gt;Ah, I just tried a 'step into' the flash_erase function with the debugger, and turned up in an interrupt routine.&lt;/P&gt;&lt;P&gt;Disabling all interrupts fixed the issue.&lt;BR /&gt;I can now verify Flash erasure (and anything else) from RAM.&lt;/P&gt;</description>
      <pubDate>Sun, 25 Jul 2021 21:02:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55xx-Mass-Flash-erase-with-IAP/m-p/1312882#M45957</guid>
      <dc:creator>janpieterderuit</dc:creator>
      <dc:date>2021-07-25T21:02:00Z</dc:date>
    </item>
  </channel>
</rss>

