Android Deep Exploration-Volume 1 sixth chapter experience

Source: Internet
Author: User

This chapter mainly introduces the first Linux driver: Count the number of words. The Linux system maps each driver into a single file, which is called a device file or driver file, and is stored in the/dev directory. Most Linux drivers have their corresponding device files, so exchanging data with Linux drives becomes the exchange of data with files, that is, file operations.

Steps to write a Linux driver

First step: Build Linux driver skeleton (load and unload Linux drivers)

Step two: Register and unregister the device files

Step three: Specify driver-related information

Fourth step: Specify the callback function

Fifth step: Writing business logic

Sixth step: Writing the Makefile file

Seventh step: Compiling Linux drivers

Eighth Step: Install and uninstall Linux drivers

Install Linux drivers:

Insmod (driver name, typically a file with a. ko suffix)

To see if Word_count installed successfully:

Lsmod | grep word_count

(Unload L Inux Drive: Rmmod word_count, this step is uninstalled when you don't need it)

To view log information from Linux-driven output:

DMESG | grep Word_count | Tail–n

Compiling the driver into the Linux kernel for testing (using the Word_count driver example)

First step: Put the word_count.c file into the Linux kernel source code

Step Two: Modify the Kconfig file

Step three: Modify the Makefile file (follow the makefile edit rule)

Fourth step: Set the. config file (menu configuration)

Fifth step: Compile the Linux kernel (enter the directory with the makefile file, execute the Make command)

To add the Word_count directory to the Linux kernel source tree

First step: Create a new Kcinfig file (This step is the drag of the file)

Step Two: Modify the makefile file

Step three: Modify the Kconfig file of the upper directory

Fourth step: Modify the Makefile file of the upper directory

Android Deep Exploration-Volume 1 sixth chapter experience

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.