在Linux下通过dnw来给开发板发送程序。包括驱动程序代码:secbulk.c,应用程序代码:dnw.c。只能运行在32位系统上,在64位系统上提示错误:DNW download Data size is too big。
dnw源代码:
#include <stdio.h> #include <stdlib.h> #include <malloc.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> #include <string.h> const char* dev = "/dev/secbulk0"; int main(int argc, char* argv[]) { unsigned char* file_buffer = NULL; long int addr = 0; if( 3 != argc ) { printf("Usage: dwn <filename> address "); return 1; } int fd = open(argv[1], O_RDONLY); if(-1 == fd) { printf("Can not open file - %s ", argv[1]); return 1; } addr = strtol((char *) argv[2] ,NULL, 16); printf("addr = %lx ", addr); // get file size struct stat file_stat; if( -1 == fstat(fd, &file_stat) ) { printf("Get file size filed! "); return 1; } file_buffer = (unsigned char*)malloc(file_stat.st_size+10); if(NULL == file_buffer) { printf("malloc failed! "); goto error; } //memset(file_buffer, ' ', sizeof(file_buffer)); // bad code ! corrected by Qulory memset(file_buffer, '