AnsweredAssumed Answered

C90 SSD Driver

Question asked by chen xiubo on Nov 14, 2016
Latest reply on Nov 15, 2016 by Lukas Zadrapa

Hi,

     I am using MPC5634 MCU  Flash module for bootloader, but  there are two versions:

for example :

1. BlankCheck.c     

vertion 1: 

/*****************************************************************
* PROJECT : Standard Software Driver (SSD) for M10ST based devices
* FILE : blankcheck.c
*
* DESCRIPTION : This file contains BlankCheck function implementation
*
* COPYRIGHT :(c) 2008, Freescale & STMicroelectronics
*
* VERSION : EAR 0.2
* DATE : 04.18.2008
* AUTHOR : ...
*
* HISTORY :
* 2007.12.11 Arvind Awasthi Initial Version
* 2008.04.18 Leonardo Colombo Changed header in agreement with JDP SW
* template
******************************************************************/

#include "ssd_c90fl.h"
#include "ssd_c90fl_internal.h"


/*******************************************************************
| external declarations
|------------------------------------------------------------------*/

/*******************************************************************
| defines and macros (scope: module-local)
|------------------------------------------------------------------*/

/*******************************************************************
| typedefs and structures (scope: module-local)
|------------------------------------------------------------------*/

/*******************************************************************
| global variable definitions (scope: module-exported)
|------------------------------------------------------------------*/

/*******************************************************************
| global variable definitions (scope: module-local)
|------------------------------------------------------------------*/

/*******************************************************************
| function prototypes (scope: module-local)
|------------------------------------------------------------------*/

/*******************************************************************
| function implementations (scope: module-local)
|------------------------------------------------------------------*/

/*******************************************************************
| function implementations (scope: module-exported)
|------------------------------------------------------------------*/

/************************************************************************
* *
* FUNCTION : BlankCheck *
* DESCRIPTION : This function will verify a specified flash range *
* to be erased. *
* PARAMETERS : *
* pSSDConfig - Flash driver configuration structure *
* dest - start flash addr to be programmed *
* size - number of bytes to be programmed *
* (need to be dword-aligned) *
* pFailAddress - pointer to first failing address *
* pFailData - pointer to first failing actual data *
* CallBack - Callback function pointer for timeout *
* checking. *
* RETURN : C90FL_OK - passes *
* C90FL_ERROR_VERIFY - failed verify *
* C90FL_ERROR_RANGE - Invalid addr range *
* C90FL_ERROR_ALIGNMENT - Invalid alignment *
* *
*************************************************************************/
UINT32 BlankCheck ( PSSD_CONFIG pSSDConfig,
UINT32 dest,
UINT32 size,
UINT32 *pFailAddress,
UINT64 *pFailData,
void (*CallBack)(void))
{
register UINT32 returnCode; /* return code */
UINT32 destIndex; /* destination address index */
UINT32 shadowRowEnd; /* shadow row base + shadow size */
UINT32 mainArrayEnd; /* main array base + main array size */
UINT32 temp; /* dest + size, or CallBack step */

returnCode = C90FL_OK;

/* Check alignments */
if ( ((dest | size) % C90FL_DWORD_SIZE) != 0 )
{
returnCode = C90FL_ERROR_ALIGNMENT;
goto EXIT;
}

/* The flash range should fall within either shadow row or main array */
shadowRowEnd = pSSDConfig->shadowRowBase + pSSDConfig->shadowRowSize;
mainArrayEnd = pSSDConfig->mainArrayBase + pSSDConfig->mainArraySize;
temp = dest + size;

if ( !((dest >= pSSDConfig->shadowRowBase) && (dest < shadowRowEnd) &&
(size <= pSSDConfig->shadowRowSize) && (temp <= shadowRowEnd))
&&
!((dest >= pSSDConfig->mainArrayBase) && (dest < mainArrayEnd) &&
(size <= pSSDConfig->mainArraySize) && (temp <= mainArrayEnd)) )
{
returnCode = C90FL_ERROR_RANGE;
goto EXIT;
}

temp = 0;

/* Blank check by double word */
for (destIndex = 0; destIndex < (size / C90FL_DWORD_SIZE); destIndex++)
{
if ( (*(UINT64 *)dest) != 0xFFFFFFFFFFFFFFFF )
{
returnCode = C90FL_ERROR_NOT_BLANK;
*pFailAddress = dest;
*pFailData = *(UINT64 *)dest;
break;
}

dest += C90FL_DWORD_SIZE;

/* CallBack */
if ( (CallBack != NULL_CALLBACK) && (destIndex == temp) )
{
CallBack();
temp += CALLBACK_BC;
}
}

EXIT:
if (pSSDConfig->BDMEnable)
{
//asm ( "mr r3,returnCode" ); /* save the return code to R3 */
#ifdef VLE_ASM
asm ( "se_sc " ); /* generate system call interrupt */
#else
asm ( "sc " );
#endif
}

return returnCode;
}

 

Vertion 2:


const unsigned long BlankCheck_C[] =
{

0x9421FFA0, 0x7C0802A6, 0xBEA10034, 0x90010064, 0x7C7F1B78,
0x7C9E2378, 0x7CBD2B78, 0x7CDC3378, 0x7CFB3B78, 0x7D1A4378,
0x57CC077E, 0x2B0C0000, 0x57AB07BE, 0x280B0000, 0x4C5A1202,
0x4182000C, 0x3B200100, 0x48000130, 0x819F000C, 0x817F0010,
0x7F0C5A14, 0x815F0004, 0x813F0008, 0x7EEA4A14, 0x7EDEEA14,
0x817F0004, 0x7C0BF040, 0x41810020, 0x7C1EB840, 0x40800018,
0x819F0008, 0x7C0CE840, 0x4180000C, 0x7C16B840, 0x4081002C,
0x819F000C, 0x7C0CF040, 0x418100DC, 0x7C1EC040, 0x408000D4,
0x819F0010, 0x7C0CE840, 0x418000C8, 0x7C16C040, 0x418100C0,
0x3B200000, 0x3AC00050, 0x57B5E8FE, 0x3AE00000, 0x7C17A840,
0x40800068, 0x817E0000, 0x819E0004, 0x3920FFFF, 0x3940FFFF,
0x7C0B4840, 0x40820008, 0x7C0C5040, 0x41820020, 0x3B200600,
0x93DC0000, 0x813E0000, 0x815E0004, 0x913B0000, 0x915B0004,
0x4800002C, 0x3BDE0008, 0x2C1AFFFF, 0x41820018, 0x7C17B040,
0x40820010, 0x7F4903A6, 0x4E800421, 0x3AD60050, 0x3AF70001,
0x4BFFFF98, 0x57B6077E, 0x2C160000, 0x4182003C, 0x2C190000,
0x40820034, 0x819E0000, 0x2C0CFFFF, 0x41820028, 0x3B200600,
0x93DC0000, 0x817E0000, 0x7D6A5B78, 0x39200000, 0x913B0000,
0x915B0004, 0x48000008, 0x3B200200, 0x819F0024, 0x2C0C0000,
0x41820014, 0x7F23CB78, 0x60000000, 0x00000000, 0x60000000,
0x7F23CB78, 0xBAA10034, 0x80010064, 0x7C0803A6, 0x38210060,
0x4E800020, 0x4D504339, 0x30424331, 0x3130FFFF
};
/* Total Data Size = 436 bytes */

 

 

 

One vertion is function,the other is array.Is there any different between them? 

Also you can see  attachment files.

Original Attachment has been moved to: Flash.rar

Outcomes