A chunk of that file included in the sti5517 toolset stburner files.
It shows the readfile function is available.
| Code: |
/*-------------------------------------------------------------------------
* Function : ReadFile
* Read HEX file into memory
* Input :
* Output :
* Return : File size
* ----------------------------------------------------------------------*/
U32 FLASH_ReadFile( char *Filename )
{
long int HexFile_p; /* datafile descriptor */
long int HexFileSize; /* size in bytes of the file */
/* Open and Read file into memory */
HexFileSize = 0;
HexFile_p = debugopen(Filename, "rb");
if (HexFile_p < 0)
{
STTBX_Print(("Error opening file \'%s\'\n", Filename ));
}
else
{
HexFileSize = debugfilesize(HexFile_p);
/* allocate File data buffer */
FreeFileDataBuffer();
FlashData_p = (char*) memory_allocate( SystemPartition, (U32) HexFileSize );
if ( FlashData_p != NULL )
{
STTBX_Print(("Loading \'%s\' into memory, wait .. ", Filename ));
debugread(HexFile_p, FlashData_p, (size_t) HexFileSize);
STTBX_Print(("%d bytes\n", HexFileSize ));
}
debugclose(HexFile_p);
}
if ( HexFileSize > 0 )
{
/* convert buffer to binary and resize memory */
STTBX_Print(("Converting file in memory, wait .. "));
FlashSize = ConvertMemory( HexFileSize );
STTBX_Print(("Now %d bytes\n", FlashSize ));
if ( FlashSize > 0 )
{
FlashData_p = (char*) memory_reallocate( SystemPartition, FlashData_p, FlashSize );
}
}
if ( FlashData_p == NULL )
{
STTBX_Print(("Not enough memory for HEX file\n"));
FlashSize = 0;
}
return( FlashSize );
} /* end of FLASH_ReadFile */
|