Partition S32K142 with EEPROM and D-Flash, D-Flash erased

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

Partition S32K142 with EEPROM and D-Flash, D-Flash erased

Jump to solution
1,050 Views
BriceC
Contributor II

Hello,

We are looking for partitionning our S32K142 with 16kB Data flash which contain ROM calibration, and have an EEPROM in 48kB.

What we have to do this is this function 

/* Configure FlexRAM as EEPROM and FlexNVM as EEPROM backup region,
* DEFlashPartition will be failed if the IFR region isn't blank.
* Refer to the device document for valid EEPROM Data Size Code
* and FlexNVM Partition Code. For example on S32K144:
* - EEEDataSizeCode = 0x02u: EEPROM size = 4 Kbytes
* - DEPartitionCode = 0x0Au: Data flash Size = 16 Kbytes, EEPROM backup size = 48 Kbytes */
l_eRet = FLASH_DRV_DEFlashPartition(&g_stFlashSSDConfig, 0x02, 0x0A, 0x0, false, true);

But after we do that, our D-flash partition is replaced with FF.

I saw in an application note (AN12130) that

When the PGMPART command executes it will cause all of the FlexNVM to be erased,
even sectors that will not be used for EEPROM backup

So my first question is: how can i keep my ROM calibrations in D-Flash that i partitionned ? Because they are erased.

I tried to copy in RAM, do my partition, and then copy from RAM to ROM (D-Flash), but it raised a DefaultISR when i want to copy from RAM. Do you know why ?

Here is what i did 

 

void RAM2ROM(void) {
uword i;

uint8 * Ram_Startptr; //RAM APP START
uint8 * Rom_Startptr; //ROM APP START

Ram_Startptr = (uint8 *) (app_program_data_RAM_address); //RAM APP start
//RAM APP end
Rom_Startptr = (uint8 *) (app_program_data_address); //POM APP

DisableInterrupts

/* Assigns the client's calibration data ROM region to the RAM region */
for (i = 0; i < 0x1000; i++) {
*(Rom_Startptr + i) = *(Ram_Startptr + i);
}

EnableInterrupts
}

Best regards,

Labels (1)
0 Kudos
1 Solution
1,029 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

It is needed to perform program partition command once (for blank new device or with performed mass erase operation before programming the example code). There is an example code in S32DS (flash_partitioning_s32k1..).

For any other use, it is needed to perform flash_partitioning operation according user configuration. Pay attention to AN11983 - Using the S32K1xx EEPROM Functionality:
https://www.nxp.com/docs/en/application-note/AN11983.pdf

EEPROM portion of FlexNVM will be accesses over FlexRAM memory address space.
Data flash portion of FlexNVM will be accesses ordinary way i.e. reading of flash address directly and erasing/programming of flash address.

View solution in original post

0 Kudos
4 Replies
995 Views
BriceC
Contributor II

Hi David,

Yes it is all clear to me now, thank you for your help !

0 Kudos
1,023 Views
BriceC
Contributor II

Hi David,

Thanks for your help, i used the SDK function FLASH_DRV_Program to write to my D-Flash in FlexNVM and it worked

 

void RAM2ROM(void) {
__attribute((unused)) status_t l_eRet; // Store the driver APIs return code
u32 l_u32Address;
u32 l_u32Size;

u8 * l_pu8Ram_Startptr; //RAM APP START
l_pu8Ram_Startptr = (u8 *) (APP_PROGRAM_DATA_RAM_ADDRESS);

l_u32Address = (u32) (g_stFlashSSDConfig.DFlashBase);
l_u32Size = 0x1000;

l_eRet = FLASH_DRV_Program(&g_stFlashSSDConfig, l_u32Address, l_u32Size, l_pu8Ram_Startptr);
DEV_ASSERT(STATUS_SUCCESS == l_eRet);
}

But why D-Flash can't be preserved when we partition FlexNVM between D-Flash and EEPROM ?

Also how can i be sure that my D-Flash will not be erased or modified again ?

Best regards,

0 Kudos
1,010 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

Partitioning will redo the FlexMemory structure, I cannot maintain D-flash data. But how I said, it is supposed to be done only once per device life time (or several times). It is not something about to be done during every MCU startup.

0 Kudos
1,030 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

It is needed to perform program partition command once (for blank new device or with performed mass erase operation before programming the example code). There is an example code in S32DS (flash_partitioning_s32k1..).

For any other use, it is needed to perform flash_partitioning operation according user configuration. Pay attention to AN11983 - Using the S32K1xx EEPROM Functionality:
https://www.nxp.com/docs/en/application-note/AN11983.pdf

EEPROM portion of FlexNVM will be accesses over FlexRAM memory address space.
Data flash portion of FlexNVM will be accesses ordinary way i.e. reading of flash address directly and erasing/programming of flash address.

0 Kudos