Linux device driver third edition use problem

  
 

When I saw the Linux device driver, I downloaded the driver that came with the book. I always wanted to use the gcc command instead of the makefile to compile the driver. The first time I used gcc to compile the problem, the following is the problem:

Beginning I use this command:

$gcc -O2 -DMODULE -D__KERNEL__ -c test.c

No, there are so many errors, there should be no library connected to the kernel. File, then I use the included makefile, anyway, as long as make, there is a problem, the following is the problem:

make is the program under 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: There is no such file or directory. stop.

make: *** [modules] Error 2

I went to the /lib/modules/2.6.15-1.2054_FC5 path and checked the build file but the link is wrong. , I checked the properties of the build, its link target is /usr/src/kernels/2.6.15-1.2054_FC5-i686, I will go to /usr/src to see, there is really no /kernels/2.6.15-1.2054_FC5 -i686, some redhat this folder, there are several folders, BUILD, RPMS, SPECS, SOURCES, SRPMS. And it's empty inside.

I handled this, directly under a kernel version of 2.6.20, and then extract to /usr/src there is a folder called linux2.6.20, directly enter, start compiling the kernel, specifically how Compile a reference to my article called compiling the kernel.

After completion, go to /lib/modules/2.6.15-1.2054_FC5/build. Below you can see that the build file is not a wrong connection, but a folder connection, I guess it should be almost.

With psychological support, go directly to the scull folder and go to make it, and you can pass it. There is no problem. You can see the make process inside and tell the longevity of scull.ko and other things. In fact, this is the driver executable file.

According to the author of LDD3, insmod scull.ko

can pass, but there is no response. Did not appear those statements to be printed, I really can't figure out, I can't go and look at LDD3, my English version, which is electronic document, there is in the introduction of the first driver, how to compile, and how View the results, he said that if you use the text control terminal, you can see, if you use the control under xwindow can not see, you have to look inside /var/log/messages, I am in two The modules compiled and loaded inside can be seen. Hehe succeeded in sharing it.

There is another problem as if the author's makefile is universal, huh, huh, just change the name of the o after the obj, I did this.

In fact, you don't have to upgrade and compile the kernel. You can download the corresponding kernel rpm package, because the kernel development package is not installed when the system is installed. Download a kernel-devel-2.6.15-1.2054_FC5.i686.rpm.

Download from the Internet:

http://download.fedora.redhat.com/pub/fedora/linux/core/5/i386/os/Fedora/RPMS/kernel-devel- 2.6.15-1.2054_FC5.i686.rpm

There should also be in the installation CD.

But this I have compiled the kernel to know, and I can solve the problem without knowing it.

Oh, come on! ! !

Copyright © Windows knowledge All Rights Reserved