hi carlos.
and also what is block-0 and block-1 flash program.each are 512 kb .so this place i want to change anything?
and flash demo example swap is there is anything i want to change. i attached my flash write,read,erase code.
void internal_flash_write()
{
uint32_t ret; /* Return code from each SSD function */
uint32_t destination; /* Address of the target location */
uint32_t size;
uint32_t end;
uint8_t securityStatus; /* Return protection status */
uint16_t number; /* Number of longword or phrase to be program or verify*/
uint32_t *p_data;
uint32_t margin_read_level; /* 0=normal, 1=user - margin read for reading 1's */
uint8_t sudha_data[200];
uint8_t sudha_data_2[10];
uint32_t i=0, FailAddr;
unsigned char *dst;
unsigned char addr;
unsigned char adj_size;
uint32_t FlashValueAtFA00=0;
uint32_t FlashValueAtFA04=0;
CACHE_DISABLE
/**************************************************************************
* Set CallBack to callback function
***************************************************************************/
flashSSDConfig.CallBack = (PCALLBACK)RelocateFunction((uint32_t)__ram_for_callback , CALLBACK_SIZE , (uint32_t)callback);
g_FlashLaunchCommand = (pFLASHCOMMANDSEQUENCE)RelocateFunction((uint32_t)__ram_func , LAUNCH_CMD_SIZE ,(uint32_t)FlashCommandSequence);
//**************************************************************************
destination = flashSSDConfig.PFlashBase + (flashSSDConfig.PFlashSize - 6*FTFx_PSECTOR_SIZE);
internal_flash_erase();
exist_params=new_params;
size=sizeof(exist_params);//size of flash program must be multiple of 8 so adjust the size
size-=8;// here i am mincing(-) dnt_remove parameter size (confg parameter) because that variable for adjusting purpose only
if((size%8)!=0)//checking size is multiple of 8 or not if not it will adjust
{
adj_size=(size%8);
adj_size=8-adj_size;
size=size+adj_size;
}
ret = FlashProgram(&flashSSDConfig, destination, size, \
&exist_params, g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
}
void internal_flash_read()
{
unsigned char *dst;
unsigned char *exitparam_dst;
uint32_t FlashValueAtFA00=0;
uint32_t FlashValueAtFA04=0;
uint32_t i=0;
dst=flashSSDConfig.PFlashBase + (flashSSDConfig.PFlashSize - 6*FTFx_PSECTOR_SIZE);
exitparam_dst=&exist_params;
for (i = 0; i <sizeof(exist_params); i++)
{
*exitparam_dst=*dst;
dst++;exitparam_dst++;
}
}
void internal_flash_erase()
{
uint32_t ret; /* Return code from each SSD function */
uint32_t destination; /* Address of the target location */
uint32_t size;
uint32_t end;
uint16_t number; /* Number of longword or phrase to be program or verify*/
uint32_t *p_data;
uint32_t margin_read_level;
//on 21-5-15 printf("\n\n\r---->Demo: Running FlashEraseSector() and FlashVerifySection()...");
//***********************************************************************
// Erase several sectors on upper pflash block where there is no code
//***********************************************************************
destination = flashSSDConfig.PFlashBase + (flashSSDConfig.PFlashSize - 6*FTFx_PSECTOR_SIZE);
end = destination + 3*FTFx_PSECTOR_SIZE; // erase and program two sectors
while ((destination + (FTFx_PSECTOR_SIZE)) < end)
{
size = FTFx_PSECTOR_SIZE;
ret = FlashEraseSector(&flashSSDConfig, destination, size, g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
number = FTFx_PSECTOR_SIZE/FSL_FEATURE_FLASH_PFLASH_SECTION_CMD_ADDRESS_ALIGMENT;
for(margin_read_level = 0; margin_read_level < 0x2; margin_read_level++)
{
ret = FlashVerifySection(&flashSSDConfig, destination, number, margin_read_level, g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
}
destination += (size);
}
}
regards,
sudhakar p