/* program a patch to a specific file ID. The SP data is assumed to be organized in 2-dimensional. Each line is SP_PORTION_SIZE bytes long. Actual programming is applied in SP_PORTION_SIZE bytes portions. 
nvmem_write_patch */
UINT8 nvmem_write_patch(UINT32 ulFileId, UINT32 spLength, const UINT8 *spData)
/* program a patch to a specific file ID. The SP data is assumed to be organized in 2-dimensional. Each line is SP_PORTION_SIZE bytes long. Actual programming is applied in SP_PORTION_SIZE bytes portions. 
nvmem_write_patch */
UINT8 nvmem_write_patch(UINT32 ulFileId, UINT32 spLength, const UINT8 *spData)
{
	UINT8 	status = 0;
	UINT16	offset = 0;
	UINT8*      spDataPtr = (UINT8*)spData;
	while ((status == 0) && (spLength >= SP_PORTION_SIZE))
	{
		status = nvmem_write(ulFileId, SP_PORTION_SIZE, offset, spDataPtr);
		offset += SP_PORTION_SIZE;
		spLength -= SP_PORTION_SIZE;
		spDataPtr += SP_PORTION_SIZE;
	}
	if (status !=0)
	{
		return status;
	}
	if (spLength != 0)
	{
		status = nvmem_write(ulFileId, spLength, offset, spDataPtr);
	}
	return status;
}