// checksum.cpp : Defines the entry point for the console application. /* Compile command: gcc -m32 -o tools/linux/checksum tools/linux/src/checksum.c -static */ #if 1 #include #include #include int main(int argc, char *argv[]) { FILE *fp; unsigned int checksum = 0; //unsigned char buf[502000]; //MAX FW Size = 512K-44K/2 = 501760 unsigned char *buf; int i; int size = 0; if(argc != 2) return -1; fp = fopen(argv[1], "rb+"); if(!fp) return -2; fseek(fp,0L,SEEK_END); size = ftell(fp); fseek(fp,0L,SEEK_SET); buf = malloc(size+100); if(!buf){ fclose(fp); return -3; } printf("size = %d \n\r", size); memset(buf, 0, size+100); fread(buf, 1, size, fp); for(i=0;i #include #include #include #include #include int main(int argc, char *argv[]) { //FILE *fp; int fd; unsigned int checksum = 0; if(argc != 2) return -1; //fp = fopen(argv[1], "r+"); //if(!fp) return -2; fd = open(argv[1], O_RDWR); if(fd<0) return -2; //fseek(fp, 0, SEEK_SET); lseek(fd, 0, SEEK_SET); int size = lseek(fd, 0, SEEK_END); lseek(fd, 0, SEEK_SET); printf("size = %d \n\r", size); unsigned char buf[size+100]; memset(buf, 0, size+100); read(fd, buf, size); for(int i=0;i