mpiControlFlashLoadFromFile

Definition

      MPI_DECL1 MPI_RESULT MPI_DECL2
         mpiControlFlashLoadFromFile(MPIControl                    control,
                                     const MPIControlFlashFiles    *filesIn,
                                     MPIControlFlashFilesStatus    *filesOut,
                                     MPIControlFlashLoadPrgressFn  progressCallback,
                                     void*                         userData);

 

Required Header: stdmpi.h
Change History: Added in 04.00.

Description

mpiControlFlashLoadFromFile reads the firmware image files pointed to by filesIn and copies the binary images into the controller's flash memory. The structure pointed to by filesOut is filled in with names of the files that is used by mpiControlFlashLoadFromFile along with status information regarding the success of loading the images. Progress status is reported by using the optional progressCallback callback function.

control The MPIControl handle associated with the controller that will receive new firmware images.
filesIn A pointer to the MPIControlFlashFiles structure holding the information of the files to load.
If filesIn is NULL, then the MPI library will attempt to locate and load the default files for the current MPI release.
filesOut An optional argument pointing to the MPIControlFlashFilesStatus structure where the full path and name of files used by mpiControlFlashLoadFromFile are written as well as the success status of the loading operation.
If filesOut is NULL, then no status is reported.
progressCallback An optional argument that points to the callback function where the progress of the function is reported.
If progressCallback is NULL, no progress is reported.
userData A user supplied pointer that is passed to the progressCallback callback function. Useful when the callback function needs to be associated with a particular C structure or C++ class instance.
Return Values
MPIControlMessageFLASH_INVALID
MPIMessageFILE_OPEN_ERROR
MPIMessageFILE_READ_ERROR
MPIMessageFILE_MISMATCH
MPIPlatformMessageDEVICE_ERROR

Sample Code

void MPI_DECL2 myLoadProgressFn (void* userData, size_t percent)
{
	printf("Firmware load progress: %2d\r", percent);
	fflush(stdout);
}

void loadDefaultFirmware (MPIControl control)
{
	MPI_RESULT returnValue =
		mpiControlFlashLoadFromFile(
			control,
			NULL,				/* Use default names */
			NULL,				/* No additional paths to search */
			NULL,				/* Don't use file status */
			myLoadProgressFn,
			NULL);				/* no user data */

	msgCHECK(returnValue);
}

void loadMyFirmware (MPIControl control)
{
	MPIControlFlashFiles files;
	MPI_RESULT           returnValue;

	files.binFile  = "myFirmware.bin";
	files.FPGAFile = NULL; /* Use default FPGA file */

	returnValue =
		mpiControlFlashLoadFromFile(
			control,
			&files,
			NULL,			/* No additional paths to search */
			NULL,			/* Don't use file status */
			NULL,			/* Don't report progress */
			NULL);			/* no user data */
	        msgCHECK(returnValue);
}

void loadDefaultFirmwareWithStatus (MPIControl control)
{
	MPIControlFlashFilesStatus	    filesStatus;
	MPI_RESULT		    returnValue;
	char			    binFilename[512];
	char			    FPGAFilename[512];

	filesStatus.binFile.filenameBuffer = binFilename;
	filesStatus.binFile.filenameBufferSize = sizeof(binFilename);

	filesStatus.FPGAFile.filenameBuffer = FPGAFilename;
	filesStatus.FPGAFile.filenameBufferSize = sizeof(FPGAFilename);

	returnValue =
		mpiControlFlashLoadFromFile(
			control,
			NULL,				/* Use default names */
			NULL,				/* No additional paths to search */
			&filesStatus,
			myLoadProgressFn,
			NULL);				/* no user data */

	printf("\nBIN file loaded: %s\n", binFilename);
	printf("\nFPGA file loaded: %s\n", FPGAFilename);

	msgCHECK(returnValue);
}

See Also

mpiControlFlashSaveToFile | MPIControlFlashFiles | MPIControlFlashFilesStatus | MPIControlFlashLoadPrgressFn