微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > ARM-Linux驱动移植--Linux下烧写工具DNW和USB驱动安装

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

时间:11-20 来源:互联网 点击:
主机平台: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驱动

  1. make-C/lib/modules/`uname-r`/buildM=`pwd`modules


然后insmod安装驱动并dmesg查看如下

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

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

  1. #include
  2. #include
  3. #include
  4. #include
  5. #include
  6. #include
  7. #include
  8. constchar*dev="/dev/secbulk0";
  9. intmain(intargc,char*argv[])
  10. {
  11. unsignedchar*file_buffer=NULL;
  12. if(2!=argc)
  13. {
  14. printf("Usage:dwn\n");
  15. return1;
  16. }
  17. intfd=open(argv[1],O_RDONLY);
  18. if(-1==fd)
  19. {
  20. printf("Cannotopenfile-%s\n",argv[1]);
  21. return1;
  22. }
  23. structstatfile_stat;
  24. if(-1==fstat(fd,&file_stat))
  25. {
  26. printf("Getfilesizefiled!\n");
  27. return1;
  28. }
  29. file_buffer=(char*)malloc(file_stat.st_size+10);
  30. if(NULL==file_buffer)
  31. {
  32. printf("mallocfailed!\n");
  33. gotoerror;
  34. }
  35. if(file_stat.st_size!=read(fd,file_buffer+8,file_stat.st_size))
  36. {
  37. printf("Readfilefailed!\n");
  38. gotoerror;
  39. }
  40. printf("filename:%s\n",argv[1]);
  41. printf("filesize:%dbytes\n",file_stat.st_size);
  42. intfd_dev=open(dev,O_WRONLY);
  43. if(-1==fd_dev)
  44. {
  45. printf("Cannotopen%s\n",dev);
  46. gotoerror;
  47. }
  48. *((unsignedlong*)file_buffer)=0x30800000;//loadaddress
  49. *((unsignedlong*)file_buffer+1)=file_stat.st_size+10;//filesize
  50. unsignedshortsum=0;
  51. inti;
  52. for(i=8;i
  53. {
  54. sum+=file_buffer[i];
  55. }
  56. printf("Writingdata...\n");
  57. size_tremain_size=file_stat.st_size+10;
  58. //size_tblock_size=remain_size/100;
  59. size_tblock_size=512;
  60. size_twrited=0;
  61. while(remain_size>0)
  62. {
  63. size_tto_write=remain_size>block_size?block_size:remain_size;
  64. if(to_write!=write(fd_dev,file_buffer+writed,to_write))
  65. {
  66. printf("failed!\n");
  67. return1;
  68. }
  69. remain_size-=to_write;
  70. writed+=to_write;
  71. printf("\r%d%\t%dbytes",writed*100/(file_stat.st_size+10),writed);
  72. fflush(stdout);
  73. }
  74. printf("OK\n");
  75. return0;
  76. error:
  77. if(-1!=fd_dev)close(fd_dev);
  78. if(fd!=-1)close(fd);
  79. if(NULL!=file_buffer)
  80. free(file_buffer);
  81. return-1;
  82. }


最后烧写内核


Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top