您的位置 首页 5G

ARM-Linux驱动移植–Linux下烧写东西DNW和USB驱动装置

主机平台:GentooLinux11.2withlinuxkernel3.0.6硬件平台:FL2440(S3C2440)withlinuxkernel2.6.35原创作品,转载请标…

主机渠道: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. }

最终烧写内核

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/yingyong/5g/264568.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部