ARM-Linux驱动移植--Linux下烧写工具DNW和USB驱动安装

主机平台:Gentoo Linux 11.2 with linux kernel 3.0.6

硬件平台:FL2440(S3C2440)with linux kernel 2.6.35

原创作品,转载请标明出处http://blog.csdn.net/yming0221/article/details/7211396

1、首先下载DNW for linuxhttp://download.csdn.net/source/1011140

2、解压文件


3、编译主机的USB驱动

make -C /lib/modules/`uname -r`/build M=`pwd` modules
然后insmod安装驱动并dmesg查看如下


4、修改dnw.c文件并编译

由于FL2440烧写内核需要设置初始地址为0x30800000,修改后文件如下

#include #include #include #include #include #include #include const char* dev = "/dev/secbulk0"; int main(int argc, char* argv[]) { unsigned char* file_buffer = NULL; if( 2 != argc ) { printf("Usage: dwn \n"); return 1; } int fd = open(argv[1], O_RDONLY); if(-1 == fd) { printf("Can not open file - %s\n", argv[1]); return 1; } struct stat file_stat; if( -1 == fstat(fd, &file_stat) ) { printf("Get file size filed!\n"); return 1; } file_buffer = (char*)malloc(file_stat.st_size+10); if(NULL == file_buffer) { printf("malloc failed!\n"); goto error; } if( file_stat.st_size != read(fd, file_buffer+8, file_stat.st_size)) { printf("Read file failed!\n"); goto error; } printf("file name : %s\n", argv[1]); printf("file size : %d bytes\n", file_stat.st_size); int fd_dev = open(dev, O_WRONLY); if( -1 == fd_dev) { printf("Can not open %s\n", dev); goto error; } *((unsigned long*)file_buffer) = 0x30800000; //load address *((unsigned long*)file_buffer+1) = file_stat.st_size+10; //file size unsigned short sum = 0; int i; for(i=8; i0) { size_t to_write = remain_size > block_size ? block_size:remain_size; if( to_write != write(fd_dev, file_buffer+writed, to_write)) { printf("failed!\n"); return 1; } remain_size -= to_write; writed += to_write; printf("\r%d%\t %d bytes ", writed*100/(file_stat.st_size+10), writed); fflush(stdout); } printf("OK\n"); return 0; error: if(-1!=fd_dev) close(fd_dev); if(fd != -1) close(fd); if( NULL!=file_buffer ) free(file_buffer); return -1; }
最后烧写内核





你可能感兴趣的:(ARM-Linux驱动移植--Linux下烧写工具DNW和USB驱动安装)