<?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 Hardfault when using eeprom in KW36 BLE demo in Wireless MCU</title>
    <link>https://community.nxp.com/t5/Wireless-MCU/Hardfault-when-using-eeprom-in-KW36-BLE-demo/m-p/1092204#M9961</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to&amp;nbsp;use eeprom in KW36 BLE demo. In&amp;nbsp;frdmkw36_wireless_examples_bluetooth_hrs_freertos, I set&amp;nbsp;&lt;STRONG&gt;gAppUseNvm_d&lt;/STRONG&gt; and&amp;nbsp;&lt;STRONG&gt;gNvUseFlexNVM_d&amp;nbsp;&lt;/STRONG&gt;to 1. In&amp;nbsp;__NvModuleInit(), it configures eeprom and reset. However, after it reset, in hardware_init(), it calls&amp;nbsp;NV_ReadHWParameters(&amp;amp;gHardwareParameters), and then it run into&amp;nbsp;HardFault_Handler()! How to use&amp;nbsp;eeprom in&amp;nbsp;BLE demo?&lt;/P&gt;&lt;P&gt;in&amp;nbsp;&lt;SPAN&gt;__NvModuleInit(), before I call&amp;nbsp;FLASH_ProgramPartition(...)，the data at 0x7f800:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/115693i6416B370B418D62B/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;after I call&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;FLASH_ProgramPartition(...):&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/115694i13E087F6C46FF0C8/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_2.png" alt="pastedImage_2.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_3.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/115691iEC1C836F064A8472/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_3.png" alt="pastedImage_3.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 13 Jul 2020 06:24:47 GMT</pubDate>
    <dc:creator>jictannu</dc:creator>
    <dc:date>2020-07-13T06:24:47Z</dc:date>
    <item>
      <title>Hardfault when using eeprom in KW36 BLE demo</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/Hardfault-when-using-eeprom-in-KW36-BLE-demo/m-p/1092204#M9961</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to&amp;nbsp;use eeprom in KW36 BLE demo. In&amp;nbsp;frdmkw36_wireless_examples_bluetooth_hrs_freertos, I set&amp;nbsp;&lt;STRONG&gt;gAppUseNvm_d&lt;/STRONG&gt; and&amp;nbsp;&lt;STRONG&gt;gNvUseFlexNVM_d&amp;nbsp;&lt;/STRONG&gt;to 1. In&amp;nbsp;__NvModuleInit(), it configures eeprom and reset. However, after it reset, in hardware_init(), it calls&amp;nbsp;NV_ReadHWParameters(&amp;amp;gHardwareParameters), and then it run into&amp;nbsp;HardFault_Handler()! How to use&amp;nbsp;eeprom in&amp;nbsp;BLE demo?&lt;/P&gt;&lt;P&gt;in&amp;nbsp;&lt;SPAN&gt;__NvModuleInit(), before I call&amp;nbsp;FLASH_ProgramPartition(...)，the data at 0x7f800:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/115693i6416B370B418D62B/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;after I call&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;FLASH_ProgramPartition(...):&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/115694i13E087F6C46FF0C8/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_2.png" alt="pastedImage_2.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_3.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/115691iEC1C836F064A8472/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_3.png" alt="pastedImage_3.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jul 2020 06:24:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/Hardfault-when-using-eeprom-in-KW36-BLE-demo/m-p/1092204#M9961</guid>
      <dc:creator>jictannu</dc:creator>
      <dc:date>2020-07-13T06:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: Hardfault when using eeprom in KW36 BLE demo</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/Hardfault-when-using-eeprom-in-KW36-BLE-demo/m-p/1092205#M9962</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The last 2KB in flash is production data, as you pointed out already. I heard it is advised not to touch this flash sector.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And when calling &lt;SPAN&gt;FLASH_ProgramPartition&lt;/SPAN&gt;(), the comments say:&lt;/P&gt;&lt;P&gt;(around line 2557, NV_Flash.c)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* If no EEPROM set, partition the device as follows:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt; DFLASH size = 0,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt; EEPROM backup size = 256KB,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt; EEPROM dataset size = 2KB,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt; FLEXRAM = 8KB&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So all 256KB including the PROD_DATA are reconfigured as EEPROM backup memory.&lt;/P&gt;&lt;P&gt;I suspect there must be some conflicts between the PROD_DATA and EEPROM backup memory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you have a hard_fault, could you take some more analysis to see how the hard_fault is entered? Which function was executing before hard fault triggered?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2020 06:16:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/Hardfault-when-using-eeprom-in-KW36-BLE-demo/m-p/1092205#M9962</guid>
      <dc:creator>Xiang_Li</dc:creator>
      <dc:date>2020-07-14T06:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: Hardfault when using eeprom in KW36 BLE demo</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/Hardfault-when-using-eeprom-in-KW36-BLE-demo/m-p/1092206#M9963</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for youe response!&lt;/P&gt;&lt;P&gt;When I try to read the data in&amp;nbsp;FREESCALE_PROD_DATA, it will&amp;nbsp;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;trigger&amp;nbsp;&lt;SPAN&gt;hard fault. Such as&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;STRONG&gt;NV_ReadHWParameters(&amp;amp;gHardwareParameters)&lt;/STRONG&gt;, or&amp;nbsp;&lt;STRONG&gt;seed = *((uint32_t*)gRngSeedStorageAddr_d); &lt;/STRONG&gt;in&amp;nbsp;RNG_Init().&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2020 06:51:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/Hardfault-when-using-eeprom-in-KW36-BLE-demo/m-p/1092206#M9963</guid>
      <dc:creator>jictannu</dc:creator>
      <dc:date>2020-07-14T06:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: Hardfault when using eeprom in KW36 BLE demo</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/Hardfault-when-using-eeprom-in-KW36-BLE-demo/m-p/1092207#M9964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am not an expert (yet) with FlexNVM. I did some check today, but couldn't find definite answer.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: line-through;"&gt;Our colleagues designed FlexNVM in a relatively complicated way to learn and use. (Just search FlexNVM, there are many questions raised.) also documentation on this can be further improved.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 2 guesses for your issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(1) is that after partitioning, with default values in codes, all 256KB D-Flash are turned into EEPROM backup space. My guess is in this case, the flash space is no longer accessible with addresses. So when trying to load data in FREESCALE_PROD_DATA area (e.g. *((uint32_t*)gRngSeedStorageAddr_d) ), a bus access error would occur and results as a hard fault.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is easy to test this, just try: * (uint32_t *) 0x0007F7F8&lt;/P&gt;&lt;P&gt;This would read the address in the previous flash sector (shown in your picture as 0xFFFFFFFF). Or try any other address in the D-FLASH area. If all accesses can trigger hard fault, then this region is no longer accessible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Btw, in your debugger (memory) window, it shows values of 0xFFFFFFFFs, but this maybe cached. And could become ???????? as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(2) is that in KW36 user manual, section 29.4.11.16 Program Partition command.&lt;/P&gt;&lt;P&gt;It says "Prior to launching the Program Partition command, the data flash IFR must be in an erased state, which can be accomplished by executing the Erase All Blocks command or by an external request ..."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The "external request" is probably submitted by a debugger. Then, from user codes, the only way is to issue an Erase All Blocks command to the whole D-Flash area. (This is my understanding to the sentence.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And when looking at the KW36 demo codes, this is clearly not done before the partition command. And it is not designed this way, because the FREESCALE_PROD_DATA is placed at the end of the D-FLASH. A Erase-All would remove the factory production data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Summary, I would do it this way,&lt;/P&gt;&lt;P&gt;- copy out the FREESCALE_PROD_DATA, and relocate it to a different flash sector&lt;/P&gt;&lt;P&gt;- do a full erase of D-flash, and then partition the flash. (Note that this is only need 1 time, can be done at factory manufacturing)&lt;/P&gt;&lt;P&gt;- then don't access the EEPROM Backup space with address, but only via the FlexRAM.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jul 2020 12:15:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/Hardfault-when-using-eeprom-in-KW36-BLE-demo/m-p/1092207#M9964</guid>
      <dc:creator>Xiang_Li</dc:creator>
      <dc:date>2020-07-15T12:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: Hardfault when using eeprom in KW36 BLE demo</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/Hardfault-when-using-eeprom-in-KW36-BLE-demo/m-p/1092208#M9965</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;Thanks for youe response!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;I set the flash as below:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/116172i8315EE16B19A2280/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.jpg" alt="pastedImage_1.jpg" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&amp;nbsp;and I set the backup size to 128KB:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/116174i61943BCBBE2B5A43/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_2.jpg" alt="pastedImage_2.jpg" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;It looks like work.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jul 2020 08:09:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/Hardfault-when-using-eeprom-in-KW36-BLE-demo/m-p/1092208#M9965</guid>
      <dc:creator>jictannu</dc:creator>
      <dc:date>2020-07-17T08:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: Hardfault when using eeprom in KW36 BLE demo</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/Hardfault-when-using-eeprom-in-KW36-BLE-demo/m-p/1092209#M9966</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Glad it works!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just want to point out small things in your picture.&lt;/P&gt;&lt;P&gt;- FREESCALE_PROD_DATA only needs 2KB I think, but you assigned a size of 7KB (0x1C00). Seemingly unnecessary.&lt;/P&gt;&lt;P&gt;- After 128KB reserved for EEPROM, there should be 128KB (0x20000) left in D-Flash. But now you are only use 0x4000 + 0x1C00 of those. About ~100KB in the device not allocated and not seen from the current memory map.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jul 2020 10:53:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/Hardfault-when-using-eeprom-in-KW36-BLE-demo/m-p/1092209#M9966</guid>
      <dc:creator>Xiang_Li</dc:creator>
      <dc:date>2020-07-17T10:53:15Z</dc:date>
    </item>
  </channel>
</rss>

