全志V5平台升级bootlogo

不多说,先直接贴代码

#include 
#include 
#include 
#include 
#include 
#include 
#include 

#define     INT8    char
#define         INT32   int


#define     FILE_NAME          "/mnt/nfs/test3app/writebootlogo/bootlogo.bmp"
#define     PARTITION_NAME          "/dev/mmcblk0p11"


int mywrite(char * FileName,char * DevName)
{
	FILE	*fp = NULL;
	int  flash_handle = 0;
	INT8 *ptBuff = NULL;
	INT32 niReadLen = 0;
	INT32 niWriteLen = 0;

	if(FileName == NULL || DevName == NULL)
	{
		printf("UpdateExt4File  input  invalid!!!\n");
		return -1;
	}
	ptBuff = (INT8  *)malloc(1024*1024);
	if(ptBuff)
	{
		fp = fopen(FileName, "r");
		if (NULL != fp)
		{

			flash_handle = open(DevName,O_RDWR);
			 if(flash_handle < 0)
			 {
			 	printf("open  %s failed!!!\n",DevName);
			}
			while(!feof(fp))
			{
				niReadLen =fread(ptBuff,1,1024*1024,fp);
				if(niReadLen > 0)
				{
					niWriteLen = write(flash_handle,ptBuff,niReadLen);
					}
				}
			}
			fdatasync(flash_handle);
			close(flash_handle);
			fclose(fp);
		}
		else
		{
			printf("UpdateExt4File  fopen %s failed!!!\n",FileName);
			return -3;
		}
		free(ptBuff);
		ptBuff = NULL;
		printf("write bootlogo Partition OK !! \n");
	}
	else
	{
		printf("UpdateExt4File  malloc failed!!!\n");
		return -2;
	}
	return 0;
}

int main(int argc, char **argv)
{
	printf("Main start !!\n");
	mywrite(FILE_NAME,PARTITION_NAME);
	 
    return 0;
}


 

全志平台的bootlogo是以文件的形式直接存放到/dev/mmcblk0p11这个分区上的(此分区只存放bootlogo.bmp文件),所以我们直接将要替换的图片以文件的形式写到此分区对应的设备上就行了

你可能感兴趣的:(全志V5平台升级bootlogo)