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.
This is using a S32K312 and RTD4 software base.
Example:
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, &RAMVariables_DEFAULT, sizeof(RAMVariables_DEFAULT));
uint8_t* dest = (uint8_t *)ramVariables;
uint8_t* source = (uint8_t *)&RAMVariables_DEFAULT;
uint8_t len = sizeof(RAMVariables_DEFAULT);
while (len>0U) {
*dest = *source;
dest++;
source++;
len--;
}
}
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.
