ARM-Linux driver transplantation--Linux burning tool DNW and USB driver installation

Publisher:冷漠之心Latest update time:2016-04-26 Source: eefocusKeywords:ARM-Linux Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Host platform: Gentoo Linux 11.2 with linux kernel 3.0.6

Hardware platform: FL2440 (S3C2440) with linux kernel 2.6.35

Original work, please indicate the source when reprinting http://blog.csdn.net/yming0221/article/details/7211396

1. First download DNW for linux  http://download.csdn.net/source/1011140

2. Unzip the file

3. Compile the host's USB driver

 

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

Then install the driver with insmod and check with dmesg as follows

 

4. Modify the dnw.c file and compile

Since the FL2440 needs to set the initial address to 0x30800000 when burning the kernel, the modified file is as follows

 
  1. #include   
  2. #include   
  3. #include   
  4. #include   
  5. #include   
  6. #include   
  7. #include   
  8.   
  9. const char* dev = "/dev/secbulk0";  
  10.   
  11.   
  12. int main(int argc, char* argv[])  
  13. {  
  14.     unsigned char* file_buffer = NULL;  
  15.     if( 2 != argc )  
  16.     {  
  17.         printf("Usage: dwn \n");  
  18.         return 1;  
  19.     }  
  20.   
  21.     int fd = open(argv[1], O_RDONLY);  
  22.     if(-1 == fd)  
  23.     {  
  24.         printf("Can not open file - %s\n", argv[1]);  
  25.         return 1;  
  26.     }  
  27.   
  28.     struct stat file_stat;  
  29.     if( -1 == fstat(fd, &file_stat) )  
  30.     {  
  31.         printf("Get file size filed!\n");  
  32.         return 1;  
  33.     }     
  34.       
  35.     file_buffer = (char*)malloc(file_stat.st_size+10);  
  36.     if(NULL == file_buffer)  
  37.     {  
  38.         printf("malloc failed!\n");  
  39.         goto error;  
  40.     }  
  41.     if( file_stat.st_size !=  read(fd, file_buffer+8, file_stat.st_size))  
  42.     {  
  43.         printf("Read file failed!\n");  
  44.         goto error;  
  45.     }  
  46.   
  47.     printf("file name : %s\n", argv[1]);  
  48.     printf("file size : %d bytes\n", file_stat.st_size);  
  49.   
  50.     int fd_dev = open(dev, O_WRONLY);  
  51.     if( -1 == fd_dev)  
  52.     {  
  53.         printf("Can not open %s\n", dev);  
  54.         goto error;  
  55.     }  
  56.       
  57.     *((unsigned long*)file_buffer) = 0x30800000;    //load address  
  58.     *((unsigned long*)file_buffer+1) = file_stat.st_size+10;    //file size  
  59.     unsigned short sum = 0;  
  60.     int i;  
  61.     for(i=8; i
  62.     {  
  63.         sum += file_buffer[i];  
  64.     }  
  65.       
  66.     printf("Writing data...\n");  
  67.     size_t remain_size = file_stat.st_size+10;  
  68. //  size_t block_size = remain_size / 100;  
  69.         size_t block_size = 512;  
  70.     size_t writed = 0;  
  71.     while(remain_size>0)  
  72.     {  
  73.         size_t to_write = remain_size > block_size ? block_size:remain_size;  
  74.         if( to_write != write(fd_dev, file_buffer+writed, to_write))  
  75.         {  
  76.             printf("failed!\n");  
  77.             return 1;  
  78.         }  
  79.         remain_size -= to_write;  
  80.         writed += to_write;  
  81.         printf("\r%d%\t %d bytes     ", writed*100/(file_stat.st_size+10), writed);  
  82.         fflush(stdout);  
  83.           
  84.     }     
  85.   
  86.     printf("OK\n");  
  87.     return 0;  
  88.   
  89. error:  
  90.     if(-1!=fd_dev) close(fd_dev);  
  91.     if(fd != -1) close(fd);  
  92.     if( NULL!=file_buffer )  
  93.         free(file_buffer);  
  94.     return -1;  
  95. }  

Finally burn the kernel

 

 

 

 

Keywords:ARM-Linux Reference address:ARM-Linux driver transplantation--Linux burning tool DNW and USB driver installation

Previous article:ARM-Linux driver--ADC driver (interrupt mode)
Next article:ARM-Linux driver--MTD driver analysis (Part 3)

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号