新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > ARM-Linux驅(qū)動(dòng)移植--Linux下燒寫工具DNW和USB驅(qū)動(dòng)安裝

ARM-Linux驅(qū)動(dòng)移植--Linux下燒寫工具DNW和USB驅(qū)動(dòng)安裝

作者: 時(shí)間:2016-11-20 來(lái)源:網(wǎng)絡(luò) 收藏
主機(jī)平臺(tái):Gentoo Linux 11.2 with linux kernel 3.0.6

硬件平臺(tái):FL2440(S3C2440)with linux kernel 2.6.35

本文引用地址:http://butianyuan.cn/article/201611/319015.htm

原創(chuàng)作品,轉(zhuǎn)載請(qǐng)標(biāo)明出處http://blog.csdn.net/yming0221/article/details/7211396

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

2、解壓文件

、

3、編譯主機(jī)的USB驅(qū)動(dòng)

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

然后insmod安裝驅(qū)動(dòng)并dmesg查看如下

4、修改dnw.c文件并編譯

由于FL2440燒寫內(nèi)核需要設(shè)置初始地址為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:dwnn");
  15. return1;
  16. }
  17. intfd=open(argv[1],O_RDONLY);
  18. if(-1==fd)
  19. {
  20. printf("Cannotopenfile-%sn",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:%sn",argv[1]);
  41. printf("filesize:%dbytesn",file_stat.st_size);
  42. intfd_dev=open(dev,O_WRONLY);
  43. if(-1==fd_dev)
  44. {
  45. printf("Cannotopen%sn",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("OKn");
  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. }

最后燒寫內(nèi)核




評(píng)論


相關(guān)推薦

技術(shù)專區(qū)

關(guān)閉