Issue while writing data to the flash

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

Issue while writing data to the flash

Jump to solution
532 Views
SAchary11
Contributor I

Hi,

When I tried to write the data to the flash -c55 using emulation software, It is going to an exception,

 

SAchary11_0-1669206747622.png

 

The reason for it because of the value of dest variable(value is 7),

I tried to debug this issue, I noticed that blocks blankspace configuration is assigned to this block, still not understanding how to overcome this issue,

I have configured all the parameter properly as per my understanding It should work. I feel some issue with emaulation software, Please let me know how to resolve this issue

 

 

 

 

My configuration and the code

SAchary11_1-1669207010916.png

 

code: causing problem while writing the data

/* Invalidate flash controller cache */
DisableFlashControllerCache(FLASH_PFCR1, FLASH_FMC_BFEN_MASK, &pflash_pfcr1);
DisableFlashControllerCache(FLASH_PFCR2, FLASH_FMC_BFEN_MASK, &pflash_pfcr2);

/* Unlock all EEPROM blocks */
ret = FLASH_DRV_SetLock(C55_BLOCK_LOW, UNLOCK_LOW_BLOCKS);
ret = FLASH_DRV_SetLock(C55_BLOCK_MID, UNLOCK_MID_BLOCKS);
ret = FLASH_DRV_SetLock(C55_BLOCK_HIGH, UNLOCK_HIGH_BLOCKS);

/* Initialize EPROM emulation */
ret = EEE_DRV_InitEeprom(&userConf, &state);

/*---------------------------------------------------------------------*/
/* Read data from EEPROM-----------------------------------------------*/
/*---------------------------------------------------------------------*/
ret = AppNVM_ReadData(NVM_LH_RIDE_HGT_OFFEST_ID,sizeof(rhs_left_hgt_offset),(uint32_t)&rhs_left_hgt_offset,&recordAddr,EEE_IMMEDIATE_NONE);
ret = AppNVM_ReadData(NVM_RH_RIDE_HGT_OFFEST_ID,sizeof(rhs_right_hgt_offset),(uint32_t)&rhs_right_hgt_offset,&recordAddr,EEE_IMMEDIATE_NONE);

uint8_t data[4]={0,};
uint8_t size = sizeof(data);

/* Write data to the EEPROM------------------------------------------- */
if( pid == PID_LEFT_HT_ZERO)
{

Value2Bytes(UINT32,&Diag_data_LeftHgt_PID,data);

ret = AppNVM_WriteData(NVM_LH_RIDE_HGT_OFFEST_ID,size,(uint32_t)data,EEE_IMMEDIATE_NONE);
//ret = EEE_DRV_WriteEeprom(NVM_LH_RIDE_HGT_OFFEST_ID,size,(uint32_t)data,EEE_IMMEDIATE_NONE);
}
else
{
Value2Bytes(UINT32,&Diag_data_RightHgt_PID,data);
ret = AppNVM_WriteData(NVM_RH_RIDE_HGT_OFFEST_ID,size,(uint32_t)data,EEE_IMMEDIATE_NONE);
//ret = EEE_DRV_WriteEeprom(NVM_LH_RIDE_HGT_OFFEST_ID,size,(uint32_t)data,EEE_IMMEDIATE_NONE);

}

My observation:

I observed that blank space value which is copied from g_eeeState which is having value 4294967295

which is the maximum value uint32_t variable can hold,

SAchary11_0-1669216051746.png

when we add idOffset (value then the due to the range restriction, the function will end up passing value 7

SAchary11_1-1669216308829.png

 

When we divide that 7 by 8 it is end up DEV_ASSERT loop

SAchary11_2-1669216494971.png

 

I am sure that blankspace value is copied from configuration parameter but I am not able to understand why value is 0xFFFFFFFF(max value of uint32 datatype)

 

 

 

 

0 Kudos
1 Solution
516 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @SAchary11 

It's MPC5748G, right?

I would start with your configuration. I can see three issues there:

lukaszadrapa_0-1669275816389.png

Size of block at 0xFB0000 is not 16KB but 32KB:

lukaszadrapa_1-1669275903879.png

Then the masks are not correct. For block at 0xF94000 it's 0x2, for block at 0xFB0000 it's 0x100:

lukaszadrapa_2-1669275973239.png

So, try to fix this configuration as a first step.

Regards,

Lukas

View solution in original post

0 Kudos
3 Replies
517 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @SAchary11 

It's MPC5748G, right?

I would start with your configuration. I can see three issues there:

lukaszadrapa_0-1669275816389.png

Size of block at 0xFB0000 is not 16KB but 32KB:

lukaszadrapa_1-1669275903879.png

Then the masks are not correct. For block at 0xF94000 it's 0x2, for block at 0xFB0000 it's 0x100:

lukaszadrapa_2-1669275973239.png

So, try to fix this configuration as a first step.

Regards,

Lukas

0 Kudos
509 Views
SAchary11
Contributor I

Hi Lukas,

 

yes, it is MPC5748G,

Thanks for the reply! It has worked after correcting the configuration.

I have one more question regarding Endianess,

In the below screenshot the highlighted data variables are written and read from flash, there is a change in the endianess

Do we need to explicitly handle the endianess each time when we write or read the data?

SAchary11_0-1669309895272.png

 

0 Kudos
502 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi Sukesh,

you don't need to consider the endianness at all. It looks rather like an issue related to wrong size of the record or something like that. Because you selected variable length record scheme, could you check if the same size was used for write and read function?

Regards,

Lukas

0 Kudos