Use of linux device drivers in the Third Edition

Source: Internet
Author: User
Linux general technology-Linux programming and kernel information. For more information, see the following section. When I first read the driver of the linux device, I downloaded the driver included in the book and tried to use the gcc command instead of makefile to compile the driver. As a result, I attended the issue when I first compiled the driver with gcc, the following are the issues:

Run the following command:

$ Gcc-O2-DMODULE-d1_kernel _-c test. c
No, there are a lot of errors. I should have not connected to the library file of the kernel. Then I will use the accompanying makefile. As long as I make it, there will also be a problem. Here is the problem:

Make is the program in the scull folder. The error message is:
[Root @ azuo scull] # make
Make-C/lib/modules/2.6.15-1.2054 _ FC5/build M =/myfile/examples/scull LDDINC =/myfile/examples/scull/../include modules
Make: ***/lib/modules/2.6.15-1.2054 _ FC5/build: the file or directory does not exist. Stop.
Make: *** [modules] Error 2

I went to the path "/lib/modules/2.6.15-1.2054 _ FC5" and checked the file "build", but the file shows a link error. I checked the build attributes, it's linked to the/usr/src/kernels/2.6.15-1.2054 _ FC5-i686, and I'll check it under/usr/src again, indeed no/kernels/2.6.15-1.2054 _ FC5-i686, some are the redhat folder, which contains several folders: BUILD, RPMS, SPECS, SOURCES, and SRPMS. And it is empty.

In this case, I directly went to the kernel version 2.6.20, decompress it to/usr/src, and there was a folder named linux2.6.20. I went directly to start compiling the kernel, for details about how to compile the kernel, refer to one of my articles: Compile the kernel.

After that, go to/lib/modules/2.6.15-1.2054 _ FC5/build and check that the build file is not a wrong connection, but a folder connection, I guess it's almost the same.

With the psychological protection, you can directly go to the scull folder and make it. You can use it. There is no problem. You can see that the "make" process tells you that scull has been created. ko has other things. In fact, this is the executable file of the driver.

According to the LDD3 author, insmod scull. ko

Yes, but no response. There are no printed statements. I can't figure it out. I went back to LDD3, my English version, which is an electronic document, the first driver introduced how to compile and view the results. He said that if you use the text control terminal, you can see it, if the xwindow is used for controlling disconnections, you can see it in/var/log/messages. I can see it in both compiling and Loading modules. I have made a special discussion.

Another problem is that it seems that the author's makefile can be used in a general sense. You just need to change the name of the o point after obj. I did this.

In fact, it is not necessary to upgrade and compile the kernel. You can download the rpm package of the corresponding kernel, because kernel development package is not installed during system installation. Download a kernel-devel-2.6.15-1.2054_FC5.i686.rpm.
Download from the Internet:
Http://download.fedora.redhat.co .. 1.2054 _ FC5.i686. rpm
It should also be included in the installation disc.

However, I have already compiled the kernel to know the problem. I do not know the specific solution.
Related Article

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.