<?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>S32KのトピックS32K312 SRAM WRITE INCONSISTENT</title>
    <link>https://community.nxp.com/t5/S32K/S32K312-SRAM-WRITE-INCONSISTENT/m-p/2122488#M50211</link>
    <description>&lt;P&gt;I have run into a problem where I am getting inconsistent writes to SRAM from Flash. This is if I have defined my own "memcpy" to attempt to write SRAM. If I attempt to use memcpy the MCU will hardfault. I have went through the linker and for all bss (sram) section defined them as 4 byte aligned as well to meet the 32bit alignment requirement. I am lost as what could be causing this. As far as im aware I have no memory protection enabled.&lt;/P&gt;&lt;P&gt;This is using a S32K312 and RTD4 software base.&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;RAMVariables_T RAMVariables ;
const RAMVariables_T RAMVariables_DEFAULT = {
  55,                                  /*INIT_RAM_Variables*/
  11UL,                                /* EcuAddr_RAM */
  1536UL,                              /* UDSServerAddr_RAM */
  1616UL,                              /* UDSClientAddr_RAM */
  0U,                                  /* EEPROM_State */
};

void initRAMVariables(RAMVariables_T* ramVariables)
{
  //test_memcpy(ramVariables, &amp;amp;RAMVariables_DEFAULT, sizeof(RAMVariables_DEFAULT));
  uint8_t* dest = (uint8_t *)ramVariables;
  uint8_t* source = (uint8_t *)&amp;amp;RAMVariables_DEFAULT;
  uint8_t len = sizeof(RAMVariables_DEFAULT);
  while (len&amp;gt;0U) {
    *dest = *source;
    dest++;
    source++;
    len--;
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Sometimes it will write all of the data but most of the time it will write any random pieces of the data it should which is usually 1/3 of the variables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mcallaway_0-1750796530037.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/344442iC27425FE2C001B4E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mcallaway_0-1750796530037.png" alt="mcallaway_0-1750796530037.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 24 Jun 2025 20:24:05 GMT</pubDate>
    <dc:creator>mcallaway</dc:creator>
    <dc:date>2025-06-24T20:24:05Z</dc:date>
    <item>
      <title>S32K312 SRAM WRITE INCONSISTENT</title>
      <link>https://community.nxp.com/t5/S32K/S32K312-SRAM-WRITE-INCONSISTENT/m-p/2122488#M50211</link>
      <description>&lt;P&gt;I have run into a problem where I am getting inconsistent writes to SRAM from Flash. This is if I have defined my own "memcpy" to attempt to write SRAM. If I attempt to use memcpy the MCU will hardfault. I have went through the linker and for all bss (sram) section defined them as 4 byte aligned as well to meet the 32bit alignment requirement. I am lost as what could be causing this. As far as im aware I have no memory protection enabled.&lt;/P&gt;&lt;P&gt;This is using a S32K312 and RTD4 software base.&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;RAMVariables_T RAMVariables ;
const RAMVariables_T RAMVariables_DEFAULT = {
  55,                                  /*INIT_RAM_Variables*/
  11UL,                                /* EcuAddr_RAM */
  1536UL,                              /* UDSServerAddr_RAM */
  1616UL,                              /* UDSClientAddr_RAM */
  0U,                                  /* EEPROM_State */
};

void initRAMVariables(RAMVariables_T* ramVariables)
{
  //test_memcpy(ramVariables, &amp;amp;RAMVariables_DEFAULT, sizeof(RAMVariables_DEFAULT));
  uint8_t* dest = (uint8_t *)ramVariables;
  uint8_t* source = (uint8_t *)&amp;amp;RAMVariables_DEFAULT;
  uint8_t len = sizeof(RAMVariables_DEFAULT);
  while (len&amp;gt;0U) {
    *dest = *source;
    dest++;
    source++;
    len--;
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Sometimes it will write all of the data but most of the time it will write any random pieces of the data it should which is usually 1/3 of the variables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mcallaway_0-1750796530037.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/344442iC27425FE2C001B4E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mcallaway_0-1750796530037.png" alt="mcallaway_0-1750796530037.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jun 2025 20:24:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K312-SRAM-WRITE-INCONSISTENT/m-p/2122488#M50211</guid>
      <dc:creator>mcallaway</dc:creator>
      <dc:date>2025-06-24T20:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: S32K312 SRAM WRITE INCONSISTENT</title>
      <link>https://community.nxp.com/t5/S32K/S32K312-SRAM-WRITE-INCONSISTENT/m-p/2123113#M50248</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/179267"&gt;@mcallaway&lt;/a&gt;,&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Are you sure the MPU is not enabled?&amp;nbsp;In S32DS IDE, there is a default configuration in system.c. Because this sounds like a cache issue.&lt;/LI&gt;
&lt;LI&gt;Can you check the stack for overflows?&lt;/LI&gt;
&lt;LI&gt;Is the sizeof() value correct?&lt;/LI&gt;
&lt;LI&gt;Compiler options (like optimization) must be set as per RTD release notes.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jun 2025 10:56:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K312-SRAM-WRITE-INCONSISTENT/m-p/2123113#M50248</guid>
      <dc:creator>danielmartynek</dc:creator>
      <dc:date>2025-06-25T10:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: S32K312 SRAM WRITE INCONSISTENT</title>
      <link>https://community.nxp.com/t5/S32K/S32K312-SRAM-WRITE-INCONSISTENT/m-p/2126472#M50446</link>
      <description>&lt;P&gt;Daniel,&lt;/P&gt;&lt;P&gt;Thank you for your reply. It did end up being a combination of two things as the issue. Even though I did not have the MPU enabled via the compiler flag, I did have the data cache enabled (&lt;SPAN&gt;-DD_CACHE_ENABLE -DI_CACHE_ENABLE). After removing this the issue seemed to be less present but was still running into random hard faults when accessing or writing from SRAM. I then looked into the RTD platform implementation guide and it recommends using the -Os optimization flag. Well I had optimizations set to -O0 and after changing this everything is running as expected.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thank you for your reply.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jul 2025 13:42:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K312-SRAM-WRITE-INCONSISTENT/m-p/2126472#M50446</guid>
      <dc:creator>mcallaway</dc:creator>
      <dc:date>2025-07-01T13:42:43Z</dc:date>
    </item>
  </channel>
</rss>

