Validation of FlexRAM as EEPROM and EEPROM backup in S32K144

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Validation of FlexRAM as EEPROM and EEPROM backup in S32K144

Jump to solution
5,926 Views
mrajanna
Contributor V

Hi,

I am trying to validate the working of FlexRAM and EEPROM backup(E-Flash).

First I executed below commands and made sure partitions are successful.

pastedImage_1.png

Then to make FlexRAM available for EEPROM, I executed below command,

   FCCOB0 = 0x81

As per my understanding, if I perform any write operation on 0x1400_0000(FlexRAM base address), then EEE state machine should write those memory values to E-Flash(FlexNVM). So when MCU is powered off, the values should persist in E-Flash and during next boot values are copied from E-flash to FlexRAM and values are available for reading.

If my understanding is correct, then I am not able to replicate this behavior. Please clarify.

One more question, FlexRAM is 4KB and E-Flash is 64KB. Suppose if I want to copy more than 4KB from E-Flash to FlexRAM, how do I realize it?

Thanks

Mohan

Labels (1)
1 Solution
4,435 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Mohan,

The size of EEPROM is 4KB, so you cannot store more than 4KB.

FlexNVM that is allocated for E-Flash (backup) is accessible only for the internal EEPROM state machine, not for users.

 

Regards,

Daniel

View solution in original post

15 Replies
4,435 Views
sakthivelkuland
Contributor III

@ Daniel Martynek & @ Daniel Martynek

I have gone through all your comments,

I'm new to this MCU, I have a requirement to store the system configuration data(sensor ID, User Configuration Data etc). My understanding about S32K144 to use the FlexNVM to back up those configurations during the power-OFF _ON.

sequence.

gone through the Document  AN1198 Using the S32K1xx EEPROM Functionality?

But still, I Have not got clarity how use applies this code snipe to my project. 

Note: I have not used any SDK for my project, I that possible to use the FlexNVM in Non-SDK then how to start coding for this EEPROM usage.

Please share ant example code for my reference.I'm seeking help from long days.

 

Thanks in advance.

Sakthivel K

0 Kudos
4,434 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

Your understanding is correct, however, you cannot copy more than 4KB from E-Flash to FlexRam.

Have you seen AN1198 Using the S32K1xx EEPROM Functionality?

Regards,

Daniel

4,434 Views
mrajanna
Contributor V

Hi Daniel,

Thank you for the document. I followed the document and performed memory partition(FlexRAM to 4KB, E-flash to 64KB). But what ever the data I write to FlexRAM is not saved in EEPROM backup.

I have a requirement of writing battery status, ignition status, device status to EEPROM backup(E-flash). Suppose if MCU resets due to unknown condition, I should be able to know the previous status values.

Can you provide sample code snippet to write these 3 bytes of data to EEPROM backup.

Regards

Mohan

0 Kudos
4,434 Views
shyamalasundar
Contributor II

I am new to the microcontroller S32K116. could you provide me with a example code snippet of how to write data (inbytes) to eeprom.

That would be of great help.

Thankyou

0 Kudos
4,434 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

Have you tried the flash_partitioning_s32k144 SDK example code?

Regards,

Daniel

0 Kudos
4,434 Views
mrajanna
Contributor V

Hi Daniel,

Yes I tried that example.

From Flash programming perspective, everything works fine.

However from EEPROM backup(E-flash), FlexRAM perspective , I could only create partition for FlexRAM and EEPROM backup(E-flash). But what ever the data written to FlexRAM is not copied to EEPROM backup.

Thanks

Mohan

0 Kudos
4,434 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

The example code writes data to FlexRAM at 0x14000000 configured for EEPROM and then it verifies the written data by reading from the address.

/* Try to write data to EEPROM if FlexRAM is configured as EEPROM */
 if (flashSSDConfig.EEESize != 0u)
 {
 address = flashSSDConfig.EERAMBase;
 size = sizeof(uint32_t);
 ret = FLASH_DRV_EEEWrite(&flashSSDConfig, address, size, sourceBuffer);
 if (ret != STATUS_SUCCESS)
 {
 return ret;
 }
/* Verify the written data */
 if (*((uint32_t *)sourceBuffer) != *((uint32_t *)address))
 {
 /* Failed to write data to EEPROM */
 exit_code = 1u;
 return exit_code;
 }
/* Try to update one byte in an EEPROM address which isn't aligned */
 address = flashSSDConfig.EERAMBase + 1u;
 size = sizeof(uint8_t);
 sourceBuffer[0u] = 0xFFu;
 ret = FLASH_DRV_EEEWrite(&flashSSDConfig, address, size, sourceBuffer);
 if (ret != STATUS_SUCCESS)
 {
 return ret;
 }
/* Then verify */
 if (sourceBuffer[0u] != *((uint8_t *)address))
 {
 /* Failed to update data to EEPROM */
 exit_code = 1u;
 return exit_code;
 }
 }

Regards,

Daniel

0 Kudos
4,434 Views
mrajanna
Contributor V

Hi Daniel,

Yes I had executed this before and it worked.

I could write the buffer to FlexRAM. When the same was cross checked with source buffer and FlexRAM base address, it was correct. 

pastedImage_1.png

My question is how to write this data from FlexRAM to EEPROM backup(E-flash). So on reset, how these data are copied back from EEPROM backup to FlexRAM ?

Thanks

Mohan

0 Kudos
4,434 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Mohan,
 
Please read AN11983, Chapter 3.5.1 EEE writes,

“Writes to the EEE space (FlexRAM) launch a EEE operation to store the data within the E-flash memory (backup)”.

This is a background operation.
 
Regards,
Daniel

0 Kudos
4,431 Views
mrajanna
Contributor V

Hi Daniel,

In the flash program, sourceBuffer is used to demonstrate writing to p-Flash and FlexRAM.

pastedImage_4.png

For your Information: I have captured below screenshots after running the complete program in debug mode and when execution is at the end of main().

With reference to writing sourceBuffer to 6th sector(6*4096 = 0x00006000) of p-Flash, everything works good.

pastedImage_3.png

Below is the screenshot captured after writing some values to FlexRAM.

pastedImage_7.png

According to you EEE operation will take place in background and whenever data is written to FlexRAM it will update E-Flash. But in below screenshot, I don't see the values updated in E-Flash. This is my doubt.

But when board is rebooted above values are available in FlexRAM at same memory locations :smileyhappy:

pastedImage_1.png

I would like to write a log file(10KB size) which goes beyond FlexRAM size. In this case to which address of E-flash is log written ?

If EEPROM backup size is more than 4KB, then what part of E-flash is copied to FlexRAM ?

I understand E-flash size is 64KB, I want to make use of complete E-flash for saving critical data as EEPROM backup. Please guide.

Thanks

Mohan

0 Kudos
4,436 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Mohan,

The size of EEPROM is 4KB, so you cannot store more than 4KB.

FlexNVM that is allocated for E-Flash (backup) is accessible only for the internal EEPROM state machine, not for users.

 

Regards,

Daniel

4,431 Views
shyamalasundar
Contributor II

Could you provide me with a example code of how to write data in eeprom of S32K116 microcontroller.

0 Kudos
4,431 Views
mrajanna
Contributor V

Hi Daniel,

Thanks it is very clear now.

To summarize, E-Flash memory will not be available for user for saving the data. It is explicitly used by EEPROM state machine.

If user wants to save any log(more than 4KB) then they have to use P-flash.

Then I am planning to configure FlexNVM as 32KB for D-flash and 32KB for E-flash, So in this case I can save logs to D-flash. Please suggest your opinion.

Once again thanks for the clarification.

Thanks

Mohan

0 Kudos
4,431 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Mohan,

Yes, that's correct. Just note that the FlexNVM endurance is impacted by the ratio between E-flash size and EEE size.
As you can see in the datasheet, Table 22 NVM reliability specification.
You may also use Flex Memory Endurance Calculator.

Regards,
Daniel

4,435 Views
jiri_kral
NXP Employee
NXP Employee

Hi Mohan, 

if you like to write more than 4kB of data - it is better idea write data directly into program flash (512 kB) or into FlexNVM used as a data flash (starting on address 0x10000000). To avoid re-write your data during debugging (re-flashing) - you can preserve part of Flash in advanced debug settings.

pastedImage_1.png

Jiri

0 Kudos