<?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: Retain RAM data during reset on MKW38 in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Retain-RAM-data-during-reset-on-MKW38/m-p/1670384#M65178</link>
    <description>&lt;P&gt;Ill answer here, in case somebody else bumps into this.&lt;/P&gt;&lt;P&gt;First, find in your reference manual a region of SRAM that remains power through a reset. In my case (mx rt 595), thats SRAM partition 0.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="paulM90_0-1686838893949.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/227923iB0BFDEB35EA770C1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="paulM90_0-1686838893949.png" alt="paulM90_0-1686838893949.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;It's address range is:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="paulM90_1-1686838994102.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/227924i433061B0018B105C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="paulM90_1-1686838994102.png" alt="paulM90_1-1686838994102.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First up, modify your linker script.&lt;/P&gt;&lt;P&gt;1. Add a memory region. In our case, m_persistent. I placed it at the beginning of the above-mentioned partition.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;MEMORY
{
  m_flash               (RX)  : ORIGIN = 0x08000000, LENGTH = 0x00300000
  m_interrupts          (RX)  : ORIGIN = 0x00080000, LENGTH = 0x00000180
  m_persistent          (RW)  : ORIGIN = 0x20000000, LENGTH = 0x1000
  m_text                (RX)  : ORIGIN = 0x00080180, LENGTH = 0x7FE80
  m_data                (RW)  : ORIGIN = 0x200C0000, LENGTH = 0x400000
  m_usb_sram            (RW)  : ORIGIN = 0x40140000, LENGTH = 0x00004000
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Add a section in the memory region.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SECTIONS
{
  ...

  .persistent_data (NOLOAD) :
  {
    . = ALIGN(4);
    __persistent_data_start__ = .;
    KEEP(*(.persistent_data))
    KEEP(*(.persistent_data*))
    . = ALIGN(4);
    __persistent_data_end__ = .;
  } &amp;gt; m_persistent
  
  ...
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And place your variables in the newly created section. Here's a quick code to test the functionality. It should print the value, increment it, and reset after 3 seconds.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;__attribute__((section(".persistent_data"))) int persistent_var;

int main(void)
{
    BOARD_InitPins();
    BOARD_BootClockRUN();
    BOARD_InitDebugConsole();


    SDK_DelayAtLeastUs(1000*2500, SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY);
    printf("Hello World %u\n", persistent_var.PersistentValue++);
    NVIC_SystemReset();
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample output:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="paulM90_2-1686839268508.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/227925i512C73D17021C938/image-size/medium?v=v2&amp;amp;px=400" role="button" title="paulM90_2-1686839268508.png" alt="paulM90_2-1686839268508.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jun 2023 14:28:47 GMT</pubDate>
    <dc:creator>paulM90</dc:creator>
    <dc:date>2023-06-15T14:28:47Z</dc:date>
    <item>
      <title>Retain RAM data during reset on MKW38</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Retain-RAM-data-during-reset-on-MKW38/m-p/1458921#M63110</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm working on MKW38 chipset, and want to keep some data in ram instead of flash when the device resets from application to bootloader side. Maybe I missed something in spec, I didn't find some special RAM related to this, and also the description about how to perform a WARM reset which is occasionally mentioned in TRM. Would you please point a way for such purpose through RAM or registers to pass some data from application to bootloader?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Xiaofeng&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 02:05:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Retain-RAM-data-during-reset-on-MKW38/m-p/1458921#M63110</guid>
      <dc:creator>xiaofenglei</dc:creator>
      <dc:date>2022-05-17T02:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: Retain RAM data during reset on MKW38</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Retain-RAM-data-during-reset-on-MKW38/m-p/1459520#M63116</link>
      <description>&lt;P&gt;I tried to reset with watchdog which should be usually regarded as WARM reset, but looks like the ram data is still lost during reboot.&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 20:11:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Retain-RAM-data-during-reset-on-MKW38/m-p/1459520#M63116</guid>
      <dc:creator>xiaofenglei</dc:creator>
      <dc:date>2022-05-17T20:11:52Z</dc:date>
    </item>
    <item>
      <title>Re: Retain RAM data during reset on MKW38</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Retain-RAM-data-during-reset-on-MKW38/m-p/1459538#M63118</link>
      <description>&lt;P&gt;It's my bad, and the memory can retain content with watchdog. I will use this way.&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 21:47:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Retain-RAM-data-during-reset-on-MKW38/m-p/1459538#M63118</guid>
      <dc:creator>xiaofenglei</dc:creator>
      <dc:date>2022-05-17T21:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: Retain RAM data during reset on MKW38</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Retain-RAM-data-during-reset-on-MKW38/m-p/1670384#M65178</link>
      <description>&lt;P&gt;Ill answer here, in case somebody else bumps into this.&lt;/P&gt;&lt;P&gt;First, find in your reference manual a region of SRAM that remains power through a reset. In my case (mx rt 595), thats SRAM partition 0.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="paulM90_0-1686838893949.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/227923iB0BFDEB35EA770C1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="paulM90_0-1686838893949.png" alt="paulM90_0-1686838893949.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;It's address range is:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="paulM90_1-1686838994102.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/227924i433061B0018B105C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="paulM90_1-1686838994102.png" alt="paulM90_1-1686838994102.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First up, modify your linker script.&lt;/P&gt;&lt;P&gt;1. Add a memory region. In our case, m_persistent. I placed it at the beginning of the above-mentioned partition.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;MEMORY
{
  m_flash               (RX)  : ORIGIN = 0x08000000, LENGTH = 0x00300000
  m_interrupts          (RX)  : ORIGIN = 0x00080000, LENGTH = 0x00000180
  m_persistent          (RW)  : ORIGIN = 0x20000000, LENGTH = 0x1000
  m_text                (RX)  : ORIGIN = 0x00080180, LENGTH = 0x7FE80
  m_data                (RW)  : ORIGIN = 0x200C0000, LENGTH = 0x400000
  m_usb_sram            (RW)  : ORIGIN = 0x40140000, LENGTH = 0x00004000
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Add a section in the memory region.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SECTIONS
{
  ...

  .persistent_data (NOLOAD) :
  {
    . = ALIGN(4);
    __persistent_data_start__ = .;
    KEEP(*(.persistent_data))
    KEEP(*(.persistent_data*))
    . = ALIGN(4);
    __persistent_data_end__ = .;
  } &amp;gt; m_persistent
  
  ...
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And place your variables in the newly created section. Here's a quick code to test the functionality. It should print the value, increment it, and reset after 3 seconds.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;__attribute__((section(".persistent_data"))) int persistent_var;

int main(void)
{
    BOARD_InitPins();
    BOARD_BootClockRUN();
    BOARD_InitDebugConsole();


    SDK_DelayAtLeastUs(1000*2500, SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY);
    printf("Hello World %u\n", persistent_var.PersistentValue++);
    NVIC_SystemReset();
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample output:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="paulM90_2-1686839268508.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/227925i512C73D17021C938/image-size/medium?v=v2&amp;amp;px=400" role="button" title="paulM90_2-1686839268508.png" alt="paulM90_2-1686839268508.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 14:28:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Retain-RAM-data-during-reset-on-MKW38/m-p/1670384#M65178</guid>
      <dc:creator>paulM90</dc:creator>
      <dc:date>2023-06-15T14:28:47Z</dc:date>
    </item>
  </channel>
</rss>

