123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <linux/termios.h>
- #include <stdio.h>
- #include <string.h>
- #include <time.h>
- #include <stdlib.h>
- #include <sys/ipc.h>
- #include <sys/shm.h>
- #include <sys/mman.h>
- #include <linux/sockios.h>
- #include <linux/socket.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <sys/time.h>
- #include <sys/timeb.h>
- #include <math.h>//for pow
- #include "../../define.h"
- int main(int argc,char *argv[])
- {
- unsigned int MaxLen=25*1024*1024, ImageLen=0;
- unsigned char *ptr;
- int fd,wrd;
-
- ptr=malloc(MaxLen);
- if(ptr==NULL)
- {
- printf("UpdateRootfs NG - can not malloc\n");
- return 0;
- }
- memset(ptr,0xFF,MaxLen);
-
- fd = open(argv[1], O_RDONLY);
- if(fd < 0)
- {
- printf("UpdateRootfs NG - can not open rootfs\n");
- free(ptr);
- return 0;
- }
- ImageLen=read(fd,ptr,MaxLen);
- close(fd);
- printf("ImageLen=0x%x\n",ImageLen);
- if(ImageLen<(24*1024*1024))
- {
- printf("ImageLen size mismatch\n");
- free(ptr);
- return 0;
- }
- fd = open("/dev/mtdblock8", O_RDWR);
- if (fd < 0)
- {
- printf("UpdateRootfs NG - can not open mtdblock8\n");
- free(ptr);
- return 0;
- }
- wrd=write(fd, ptr, ImageLen);
- close(fd);
- if(wrd!=ImageLen)
- {
- printf("UpdateRootfs NG - wrd(0x%x) != ImageLen(0x%x)\n",wrd,ImageLen);
- free(ptr);
- return 0;
- }
- free(ptr);
- printf("UpdateRootfs OK\n");
- }
|