<?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: Writing  a flag to Retention RAM in Hardfault Handler in S32K</title>
    <link>https://community.nxp.com/t5/S32K/Writing-a-flag-to-Retention-RAM-in-Hardfault-Handler/m-p/2033623#M45420</link>
    <description>&lt;P&gt;Hi Julian,&lt;BR /&gt;&lt;BR /&gt;Thanks for the response, In my case the watchdog reset is going to occur if In any case It stuck in Hardfault Handler loop which I am considering a Functional Reset.&lt;BR /&gt;Also for debugging purposes I am resetting using debugger also, which I am supposing also a function reset only.&lt;BR /&gt;Please let me know if I am doing it wrong.&lt;BR /&gt;I am explaining my case below:-&lt;BR /&gt;So you can see I am incrementing the hardFaultCounter inside the hardfault handler. suppose&amp;nbsp; hardFaultCounter is 5 and after incrementing it is 6 and if I put the breakpoint there and reset using debugger then&amp;nbsp;hardFaultCounter is the incremented one(which is 6) and correct.&lt;BR /&gt;Now if I remove the breakpoint and it went to hardfault and I resume the program using debugger It will stop inside the while loop, value of&amp;nbsp;hardFaultCounter is 6(which is incremented as expected supposing previous it was 5) and then doing debugger reset, the value of&amp;nbsp;hardFaultCounter is coming 5 which should be 6.&lt;BR /&gt;&lt;BR /&gt;Hope I cleared the point.&lt;/P&gt;&lt;DIV&gt;void HardFault_Handler(void)&lt;/DIV&gt;&lt;DIV&gt;{&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;hardFaultCounter++;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;__asm volatile("dsb 0xF":::"memory");// If I am putting breakpoint here then do debugger reset value is coming correct&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;__asm volatile ("isb 0xF");&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;while(TRUE)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;};&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;}&lt;/DIV&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 24 Jan 2025 05:51:19 GMT</pubDate>
    <dc:creator>pulkitp</dc:creator>
    <dc:date>2025-01-24T05:51:19Z</dc:date>
    <item>
      <title>Writing  a flag to Retention RAM in Hardfault Handler</title>
      <link>https://community.nxp.com/t5/S32K/Writing-a-flag-to-Retention-RAM-in-Hardfault-Handler/m-p/2032307#M45376</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I am using S32K322 mcu. I am running Application with Bootloader, my aim is to set a flag in Retention RAM inside the Hardfault Handler so that I can detect the Hardfault in Bootloader.&lt;BR /&gt;To achieve this I created a&amp;nbsp; noinit section in SRAM.&lt;BR /&gt;/*Noinit section inside sharable region*/&lt;BR /&gt;.noinit (NOLOAD) :&lt;BR /&gt;{&lt;BR /&gt;__noinit_start = .;&lt;BR /&gt;*(.noinit) /* Variables explicitly placed in the .noinit section */&lt;BR /&gt;. = ALIGN(4);&lt;BR /&gt;__noinit_end = .;&lt;BR /&gt;} &amp;gt; int_sram_shareable&lt;BR /&gt;&lt;BR /&gt;and then done changes in startup_cm7.s to stop reinitialization of noinit section&amp;nbsp;&lt;/P&gt;&lt;P&gt;RamInit:&lt;BR /&gt;/* Initialize SRAM ECC */&lt;BR /&gt;ldr r0, =__RAM_INIT&lt;BR /&gt;cmp r0, 0&lt;BR /&gt;/* Skip if __RAM_INIT is not set */&lt;BR /&gt;beq SRAM_LOOP_END&lt;/P&gt;&lt;P&gt;ldr r0, =MCRGM_DES&lt;BR /&gt;ldr r1, [r0]&lt;BR /&gt;ldr r2, =MCRGM_DES_F_POR&lt;BR /&gt;and r1, r1, r2&lt;BR /&gt;cmp r1, 0&lt;/P&gt;&lt;P&gt;beq NO_INIT_STANDBY_REGION&lt;BR /&gt;ldr r1, =__INT_SRAM_START&lt;BR /&gt;ldr r2, =__NOINIT_SRAM_START // Exclude noinit memory region&lt;BR /&gt;//ldr r2, =__INT_SRAM_END&lt;BR /&gt;b ZERO_64B_RAM&lt;/P&gt;&lt;P&gt;NO_INIT_STANDBY_REGION:&lt;BR /&gt;#if defined(S32K310)||defined(S32M274)&lt;BR /&gt;ldr r1, =__BSS_SRAM_NC_START&lt;BR /&gt;#else&lt;BR /&gt;ldr r1, =__BSS_SRAM_START&lt;BR /&gt;#endif&lt;BR /&gt;ldr r2, =__NOINIT_SRAM_START /* Exclude .noinit */&lt;BR /&gt;//ldr r2, =__INT_SRAM_END&lt;/P&gt;&lt;P&gt;ZERO_64B_RAM:&lt;BR /&gt;subs r2, r1&lt;BR /&gt;subs r2, #1&lt;BR /&gt;ble SRAM_LOOP_END&lt;/P&gt;&lt;P&gt;movs r0, 0&lt;BR /&gt;movs r3, 0&lt;BR /&gt;SRAM_LOOP:&lt;BR /&gt;stm r1!, {r0,r3}&lt;BR /&gt;subs r2, 8&lt;BR /&gt;bge SRAM_LOOP&lt;BR /&gt;SRAM_LOOP_END:&lt;BR /&gt;&lt;BR /&gt;Now I am trying to write Flag inside the HardFault handler&lt;/P&gt;&lt;DIV&gt;__attribute__((section(".noinit"))) volatile uint8_t hardFaultCounter;&lt;/DIV&gt;&lt;DIV&gt;void HardFault_Handler(void)&lt;/DIV&gt;&lt;DIV&gt;{&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;hardFaultCounter++;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;__asm volatile("dsb 0xF":::"memory");&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;__asm volatile ("isb 0xF");&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;while(TRUE)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;};&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;}&lt;BR /&gt;&lt;BR /&gt;My problem is it is retaining the value only if I am putting the breakpoint to&amp;nbsp;&lt;SPAN&gt;hardFaultCounter++; and stepping up but without breakpoint it is not retaining.&lt;BR /&gt;Please note that It is successfully writing the updated value to the retention RAM, I verified by reading back but It is not retaining the value after reset.&lt;BR /&gt;Is Memory Protection Unit is preventing to retain ?&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 22 Jan 2025 11:13:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Writing-a-flag-to-Retention-RAM-in-Hardfault-Handler/m-p/2032307#M45376</guid>
      <dc:creator>pulkitp</dc:creator>
      <dc:date>2025-01-22T11:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: Writing  a flag to Retention RAM in Hardfault Handler</title>
      <link>https://community.nxp.com/t5/S32K/Writing-a-flag-to-Retention-RAM-in-Hardfault-Handler/m-p/2033323#M45409</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/232994"&gt;@pulkitp&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;RAM retention is only supported&amp;nbsp;across functional reset. You mentioned "&lt;SPAN&gt;It is not retaining the value after reset.", are you testing this with the "Power_Ip_PerformReset" function? or with any standby exit options?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Also, there is an existing example for Standby RAM based on S32K312 EVB. Please revise it:&amp;nbsp;&lt;A href="https://community.nxp.com/t5/S32K-Knowledge-Base/Example-S32K312-Standby-mode-amp-Standby-RAM-and-PAD-keeping-DS3/ta-p/1797713" target="_blank"&gt;Example S32K312 Standby mode &amp;amp; Standby RAM and PAD keeping DS3.5 RTD300 - NXP Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;BR /&gt;Julián&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2025 16:52:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Writing-a-flag-to-Retention-RAM-in-Hardfault-Handler/m-p/2033323#M45409</guid>
      <dc:creator>Julián_AragónM</dc:creator>
      <dc:date>2025-01-23T16:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: Writing  a flag to Retention RAM in Hardfault Handler</title>
      <link>https://community.nxp.com/t5/S32K/Writing-a-flag-to-Retention-RAM-in-Hardfault-Handler/m-p/2033623#M45420</link>
      <description>&lt;P&gt;Hi Julian,&lt;BR /&gt;&lt;BR /&gt;Thanks for the response, In my case the watchdog reset is going to occur if In any case It stuck in Hardfault Handler loop which I am considering a Functional Reset.&lt;BR /&gt;Also for debugging purposes I am resetting using debugger also, which I am supposing also a function reset only.&lt;BR /&gt;Please let me know if I am doing it wrong.&lt;BR /&gt;I am explaining my case below:-&lt;BR /&gt;So you can see I am incrementing the hardFaultCounter inside the hardfault handler. suppose&amp;nbsp; hardFaultCounter is 5 and after incrementing it is 6 and if I put the breakpoint there and reset using debugger then&amp;nbsp;hardFaultCounter is the incremented one(which is 6) and correct.&lt;BR /&gt;Now if I remove the breakpoint and it went to hardfault and I resume the program using debugger It will stop inside the while loop, value of&amp;nbsp;hardFaultCounter is 6(which is incremented as expected supposing previous it was 5) and then doing debugger reset, the value of&amp;nbsp;hardFaultCounter is coming 5 which should be 6.&lt;BR /&gt;&lt;BR /&gt;Hope I cleared the point.&lt;/P&gt;&lt;DIV&gt;void HardFault_Handler(void)&lt;/DIV&gt;&lt;DIV&gt;{&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;hardFaultCounter++;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;__asm volatile("dsb 0xF":::"memory");// If I am putting breakpoint here then do debugger reset value is coming correct&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;__asm volatile ("isb 0xF");&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;while(TRUE)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;};&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;}&lt;/DIV&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2025 05:51:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Writing-a-flag-to-Retention-RAM-in-Hardfault-Handler/m-p/2033623#M45420</guid>
      <dc:creator>pulkitp</dc:creator>
      <dc:date>2025-01-24T05:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: Writing  a flag to Retention RAM in Hardfault Handler</title>
      <link>https://community.nxp.com/t5/S32K/Writing-a-flag-to-Retention-RAM-in-Hardfault-Handler/m-p/2033957#M45439</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/232994"&gt;@pulkitp&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;When not using the breakpoint, are you attaching to target when running the debugger a second time? Your issue may be that the debugger re-programs the MCU when connecting again.&lt;/P&gt;
&lt;P&gt;I am unsure what debugger you are using, but in PEMicro's debug configuration, you can find the Attach to Running Target option inside "Startup":&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Julin_AragnM_0-1737736461243.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/321278iAE42A59130BD7070/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Julin_AragnM_0-1737736461243.png" alt="Julin_AragnM_0-1737736461243.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;BR /&gt;Julián&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2025 16:34:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Writing-a-flag-to-Retention-RAM-in-Hardfault-Handler/m-p/2033957#M45439</guid>
      <dc:creator>Julián_AragónM</dc:creator>
      <dc:date>2025-01-24T16:34:38Z</dc:date>
    </item>
  </channel>
</rss>

