⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 update.c

📁 2440 下使用SD卡更新firmware 的方法,请参看具体代码.
💻 C
字号:
#include <stdio.h>#include <fcntl.h>#include <unistd.h>#include <sys/ioctl.h>#include <sys/stat.h>#include <stdlib.h>#include <linux/kernel.h>#include <linux/fs.h>#include <linux/poll.h>#include <linux/delay.h>//#include "DisplayInt.h"//#include "einkcmd.h"//int pio_fd = -1;#define READSIZE (2048+64)//int READSIZE= 0;#define def_true 1#define def_false 0#define UpdateAp_only 0//Joe#define UBOOT_SIZE	0x40000L#define KERNEL_SIZE	0x1c0000L#define ROOTFS_SIZE	0x1E00000L#define AP_SIZE	0x1E00000L//#define BMP_SIZE	131072Lint BmpUpdate =0;int UbootUpdte =0;int KernelUpdate =0;int RootUpdate =0;int HasUpdate =0;char *sd_part="/mnt/mmc/";char *ebr_uboot="/dev/mtdblock0";char *ebr_kernel="/dev/mtdblock1";char *ebr_root="/dev/mtdblock2";char *ebr_app="/dev/mtdblock3";char *ebr_openbmp=NULL;const char *uboot_file = "u-boot.bin";const char *kernel_file = "uImage";const char *rootfs_file = "rootfs.img";const char *ap_file       = "qte.img";const char *update_dir = "/mnt/mmc/";static unsigned char Full_buf[READSIZE]= {0};int main (){		unsigned char result, update_file=1;	unsigned long file_len;	FILE *fp;	char tmp[50];		if(access("/mnt/mmc/qte.img", F_OK)==0){		// copy file to update space		system("cp /mnt/mmc/qte.img /usr/update -f");		system("sync");		printf("copy rootfs to /usr/update successful!!\n");		sleep(1);	}else if(access("/mnt/mmc/rootfs.img", F_OK)==0){		// copy file to update space		system("cp /mnt/mmc/rootfs.img /usr/update -f");		system("sync");		printf("copy rootfs to /usr/update successful!!\n");		sleep(1);			}else if(access("/mnt/mmc/uImage", F_OK)==0){		system("cp /mnt/mmc/uImage /usr/update -f");		system("sync");		printf("copy uImage to /usr/update successful!!\n");		sleep(1);	}else if(access("/mnt/mmc/u-boot.bin", F_OK)==0){		system("cp /mnt/mmc/u-boot.bin /usr/update -f");		system("sync");		printf("copy uboot to /usr/update successful!!\n");		sleep(1);	}	else{		printf("Not found update file.\n");			update_file = 0;	}	// tell user turn on and take out sd card.	system("reboot");	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -