The similarities and differences between Windows USB driver and Linux USB driver are described in detail (1)

Source: Internet
Author: User

Copyright information:

Copyright belongs to smilestone322, and all rights reserved. It is only used for learning. It shall not be used for commercial purposes. You are welcome to reprint it. Please indicate the source for reprinting. Thank you! Attach ing.

 

 

0 Preface

I wanted to write something long ago to summarize the similarities and differences between USB driver development in windows and USB driver development in Linux. Today I will mainly explain the similarities and differences, for the development of the USB driver on two platforms, the USB protocol is the same. Let's start with the USB protocol, and then explain how to develop the USB driver on windows. We mainly introduce three methods, DW
3.2 + DDK; DDK development under WDM and kmdf under WDF
USB driver development.

Although DW has been removed by WDF, I want to talk about DW driver development here, because my first driver is using DW + DDK.
I still remember the development-driven scenario since I was developed in 2600. I really hope that the fairy will show me the way. Before developing the first USB driver, I did not have any driver experience or even did not know what the driver did. However, if you are in danger, you can only go forward and go back.

No documentation, no schematic diagram, or even no data manual was given to me, so I told me about what to do with this project. At that time, I was at a loss. I really hope that the gods will give directions. The requirement for the project is actually verbal. Haha, there is no line of documents. There is no way to analyze the demand while learning, and ask colleagues and classmates who have done these things. I am posting to csdn and Foreign Forums. While searching for development-driven tools, such as DDK and DW, no driver was developed using the WDF Model in China at that time.

At that time, the level was really a word to describe. I searched for a chase and thought it was easy to use DW. After I used a development tool, I learned it day and night. Sometimes at AM, Comrade Lei Feng said that time is like a cleavage. We still have to squeeze it out. Well, we don't have to rest at noon, work, work, and work. A week has passed without any progress. Two weeks have passed and I have finally understood the requirements. At this time, I have also set up the DW + DDK + VC development environment and bought several books, every book has nothing to do with the key.

God, help me! The Boss Asks every day, is there any progress? Alas, I smile at him every time. Fortunately, the boss is still nice to me. Let me calm down and take a look at my thoughts. At that time, he also helped me find information, but it proved to be useless in the future. Haha, because no one in the company has made a USB driver.

Three weeks later, I can finally send control commands to the hardware, but the hardware has not yet sent data back to me. No way, use bus
Hound captured the packet and saw the data. I'm so excited. Haha, I finally saw hope and the future. At that time, I thanked the Party and Chairman Mao for an hour.

Experiment proves that the bigger the hope, the bigger the disappointment, I thought it was coming, but I did not expect that the first step of the long journey is still a long journey, and we must keep it ....... I will write a function later to read the data in the endpoint, but I can't read it all the time. I hope there will be, and there will be bread. I have always believed in myself and never doubted my abilities.

On the morning of the 1949th week, I went to work early. I sat there, quietly writing code, tuning programs, and talking to others, constantly reading others' code, let's look at the example on DW and the example on DDK. At that time, I saw more things in a week than I did in a month. To sum up one sentence, Let me calm down and look at the source code. The source code will be as simple as watching the story. The week of the 1949th week is 3. When I had a lunch in the morning, I finally saw that the hardware was constantly passing data to me.
Hound captured packets, the data was so correct, and the mood was so excited. A driver, an unusual experience, reminds me of one sentence: no pressure, no motivation, no wind and rain, how can I see the rainbow.

The above is my first experience in USB driver development. At that time, DW + DDK was widely used to develop drivers. Now all the companies that develop DW software have stopped developing. What a pity, such an excellent software and so easy-to-use software were eliminated, and its version was finally fixed at 3.2. However, there are still a large number of people in China who are using DW to develop drivers. I think there is a book on the Internet, which is called the circle to teach you how to use USB, that is, the DW development driver. There are still a lot of fans, prove that DW has a certain degree of vitality and a certain market, so this article will continue to talk about how to use DW for drive development.

Although DW is no longer used for formal commercial software, because its version is not updated and no bug is maintained. However, it is quite good to use DW for research. The opening remarks are complete. Start with the question. The main arrangement of this article is as follows: first introduce the USB communication protocol, and introduce a simple USB chip, 68013. Then I will explain the development of the USB driver in windows. Use three different methods to develop USB drivers. At last, we will explain the development of USB drivers in Linux. Of course, the similarities and differences between the two platforms for developing USB drivers are throughout the full text. Otherwise, we will leave the question.

As a driver developer, you do not need to have a high algorithm base, because the algorithms in the driver are basic algorithms. As long as you are familiar with the principle diagram, datesheet, and then learn DDK, the examples provided in wdk can be easily used. For Linux, the source code of Linux is also public. You can compile, install, you can see the source code of various drivers in/usr/src. Learning these source codes can not only improve our programming level, but also make the driver we write more robust. The idea I will explain below is also like this. I will first talk about the USB protocol, CY7C68013 chip, and then explain the examples under DW, DDK, and wdk. As long as I learn these examples, I can say, you have a write-driven level. To become a master, you must sum up your experience and accumulate more experience.

 

Serialization, To be continued .....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.