ARM-Linux驱动移植--Linux下烧写工具DNW和USB驱动安装
时间:11-20
来源:互联网
点击:
主机平台:Gentoo Linux 11.2 with linux kernel 3.0.6
然后insmod安装驱动并dmesg查看如下
最后烧写内核
硬件平台: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`/buildM=`pwd`modules
然后insmod安装驱动并dmesg查看如下
4、修改dnw.c文件并编译
由于FL2440烧写内核需要设置初始地址为0x30800000,修改后文件如下
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- constchar*dev="/dev/secbulk0";
- intmain(intargc,char*argv[])
- {
- unsignedchar*file_buffer=NULL;
- if(2!=argc)
- {
- printf("Usage:dwn
\n"); - return1;
- }
- intfd=open(argv[1],O_RDONLY);
- if(-1==fd)
- {
- printf("Cannotopenfile-%s\n",argv[1]);
- return1;
- }
- structstatfile_stat;
- if(-1==fstat(fd,&file_stat))
- {
- printf("Getfilesizefiled!\n");
- return1;
- }
- file_buffer=(char*)malloc(file_stat.st_size+10);
- if(NULL==file_buffer)
- {
- printf("mallocfailed!\n");
- gotoerror;
- }
- if(file_stat.st_size!=read(fd,file_buffer+8,file_stat.st_size))
- {
- printf("Readfilefailed!\n");
- gotoerror;
- }
- printf("filename:%s\n",argv[1]);
- printf("filesize:%dbytes\n",file_stat.st_size);
- intfd_dev=open(dev,O_WRONLY);
- if(-1==fd_dev)
- {
- printf("Cannotopen%s\n",dev);
- gotoerror;
- }
- *((unsignedlong*)file_buffer)=0x30800000;//loadaddress
- *((unsignedlong*)file_buffer+1)=file_stat.st_size+10;//filesize
- unsignedshortsum=0;
- inti;
- for(i=8;i
- {
- sum+=file_buffer[i];
- }
- printf("Writingdata...\n");
- size_tremain_size=file_stat.st_size+10;
- //size_tblock_size=remain_size/100;
- size_tblock_size=512;
- size_twrited=0;
- while(remain_size>0)
- {
- size_tto_write=remain_size>block_size?block_size:remain_size;
- if(to_write!=write(fd_dev,file_buffer+writed,to_write))
- {
- printf("failed!\n");
- return1;
- }
- remain_size-=to_write;
- writed+=to_write;
- printf("\r%d%\t%dbytes",writed*100/(file_stat.st_size+10),writed);
- fflush(stdout);
- }
- printf("OK\n");
- return0;
- error:
- if(-1!=fd_dev)close(fd_dev);
- if(fd!=-1)close(fd);
- if(NULL!=file_buffer)
- free(file_buffer);
- return-1;
- }
最后烧写内核
ARM-Linux驱动移植DNWUSB驱 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)