Hi all,
As usual, we need to performs multiple Flash Program operation during, for eg, ECU firmware updates.
Below the interface
sint16 FLASH_Program (uint32 address, uint32 size, uint8 * source)
{
sint16 res = 0;
C40_Ip_VirtualSectorsType virtualSector = 0u;
C40_Ip_StatusType C40Status = STATUS_C40_IP_SUCCESS;
/* Get virtual Sector number from address */
virtualSector = C40_Ip_GetSectorNumberFromAddress(address);
/****************************************************/
/* USE MAIN INTERFACES FOR FLASH JOBS */
/****************************************************/
/* Unlock sector if needed */
if (STATUS_C40_IP_SECTOR_PROTECTED == C40_Ip_GetLock(virtualSector))
{
C40Status = C40_Ip_ClearLock(virtualSector, FLS_MASTER_ID);
if(STATUS_C40_IP_SUCCESS != C40Status)
{
return(sint16)C40Status;
}
}
/* Write data */
C40Status = C40_Ip_MainInterfaceWrite(address,size,source,FLS_MASTER_ID);
if(STATUS_C40_IP_SUCCESS != C40Status)
{
return(sint16)C40Status;
}
do
{
C40Status = C40_Ip_MainInterfaceWriteStatus();
}
while (STATUS_C40_IP_BUSY == C40Status);
/* Re-lock sector after program operation */
C40Status = C40_Ip_SetLock(virtualSector,FLS_MASTER_ID);
if(STATUS_C40_IP_SUCCESS != C40Status)
{
return(sint16)C40Status;
}
return(res);
}
After putting the function call inside a for(;;) in the main translation unit, I try to update the address 0x500000, w/o any problem
ziomocci_0-1666198391330.png
Calling the API a second time on address 0x500070 with the same input source, this is the result
ziomocci_1-1666198511449.png
It seems like the C40 driver does not write four lines of Flash.
Then I use the address 0x5000A0, and the driver works as expected
ziomocci_2-1666198728621.png
I have repeated multiple tests using different address, and sometimes not all the flash lines are programmed as expected. In the picture below you could find the flash layout after 80 bytes programming on 0x500000/500080/500100/500160
ziomocci_3-1666199417436.png
All suggestions would be very appreciated!
B.R.
Andrea