In-depth analysis of Linux Device Drivers

Source: Internet
Author: User

Here we will introduce the solution to the Linux Device Driver problem. The basic operation of Linux to be added to the 3ed scull module of Linux driver compiled by ora 7 is designed to give readers a preliminary understanding of Linux. Content involves file management, disk management, user and group management, man help, software package management, File compression, and printer management.

Linux Device Driver (ldd) is an introduction to kernel development. scull is the first example module. therefore, scull learning is very important. kernel development changes rapidly. therefore, some examples in ldd cannot be compiled in the existing development environment. this article describes how to modify the scull program on the fedora7 platform so that it can be compiled smoothly.
There is no kernel development during the installation of the Fedora Linux Device Driver. Therefore, we need to install the kernel development package first.

1. Download the source code and devel package of the same version as your own kernel on the Fedoar Linux driver official site ftp. For example, I can see that my kernel version is 2.6.22.1-41 through the uname-r command. fc7 so I downloaded the kernel-devel-2.6.22.1-41.fc7 kernel-2.6.21-1.3194.fc7.src.rpm and installed the two packages. kernel-devel can be directly installed. rpmbuild is required if src is to be installed. install the patch. there are many articles on Kernel compilation on the Internet about specific methods.

2. Download the source code of the third version of ldd.
The http://examples.oreilly.com/linuxdrive3/examples.tar.gz then decompress tar zxvf examples.tar.gz into the scull directory and we can see that there is main. c. open the file. delete linux/config. h. Since the configuration is later than 2.6.19. the H file is canceled. so there will be config later. an error will be reported in h.
Next, make again. There are still errors. if (! Capable (CAP_SYS_ADMIN) Here. CAP_SYS_ADMIN cannot be found. Check it online and find that this macro is defined in linux/capability. h, so add # include Compilation fails. the reason is that macro is not defined. however, this operation is performed in access. c. search by undefined macro. they are found in inux/capability. h and sched. h. in the two files. add # include in c

# Include After the correction, make and press enter to display the output.
Make-C/lib/modules/2.6.22.1-41. fc7/build M =/home/hide1713/Desktop/kernel/examples/scull LDDINC =/home/hide1713/Desktop/kernel/examples/scull /.. /include modules
Make [1]: Entering directory '/usr/src/kernels/2.6.22.1-41. fc7-i686'
CC [M]/home/hide1713/Desktop/kernel/examples/scull/access. o
LD [M]/home/hide1713/Desktop/kernel/examples/scull. o
Building modules, stage 2.
MODPOST 1 modules
CC/home/hide1713/Desktop/kernel/examples/scull. mod. o
LD [M]/home/hide1713/Desktop/kernel/examples/scull. ko
Make [1]: Leaving directory '/usr/src/kernels/2.6.22.1-41. fc7-i686'

The Linux device driver is compiled. we use chmod + x scull_load scull_unload to change these two scripts to executable. /scull_load/sbin/lsmod. mount the kernel smoothly. the above content is written by memory. if there is any discrepancy with the actual situation, please follow the above method. which definition causes the first deviation. add the corresponding header file. The above is an introduction to Linux device drivers.

  1. Linux Device Driver-communication with hardware
  2. Describe Linux Device File Management hardware devices
  3. Linux device management command setleds
  4. Introduction to qemu using nfs to start Linux
  5. Linux chmod commands

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.