"Android Deep Exploration" (Vol. 1) Hal and Driver development

Source: Internet
Author: User

6th: The first Linux driver counts the number of words

Starting with this chapter will be the most exciting time to start writing Linux drivers for the first time. First, briefly describe what a Linux driver is. An example is given to detail the steps to write a Linux program.

Summarized as follows:

How to write Linux drivers:

1th Step: Build Linux driver skeleton (load and unload Linux drivers)

2nd step: Registering and unregistering device files

3rd Step: Specify driver-related information

4th step: Specify the callback function

5th step: Writing Business logic

6th step: Writing the Makefile file

7th step: Compiling Linux drivers

8th step: Install and Uninstall Linux drivers

There are a variety of methods for Linux driver testing:

1. Testing Linux drivers with Ubuntu Linux

2. Test the Linux driver with the original (Native) C program on the Android emulator

3. Testing Linux drivers with the Android NDK

4. Use Java code to directly manipulate device files to test Linux drivers

5. Test Linux drivers using the board:

Test Linux drivers on the board using an executable program

Used on the Development Board. Android NDK Test Linux Driver

Test Linux drivers on the development Board using Java code

6. Compile the driver into the Linux kernel for testing

1th step: Put the source file file into the Linux kernel source code

2nd Step: Modify the Kconfig file

3rd Step: Modify the Makefile file

4th step: Set the. config file

5th step: Compiling the Linux kernel

Developing and testing Linux drivers using eclipse

1th Step: Build C Project

2nd step: Establish C source code file link

3rd Step: Set the Include path

4th step: Compiling Linux drivers

With the CDT plugin installed, Eclipse can develop not only Java programs, but also common C/D + + programs. It's a good idea to use eclipse to develop a C + + program. Because there are many benefits, such as highlighting code, formatting code, tracking code, Content Assist list, debugging code, and so on.

The Word_count driver for counting the number of words is the first complete Linux drive implemented in this book. Although the functionality of the Word_count drive is not complex, it is enough to allow developers who have never been in touch with Linux drivers to understand the complete development of Linux drivers. This chapter not only introduces an example, but also describes how to test Linux drivers using different methods. These methods are mainly differentiated by platform. For example, you can test Linux drivers directly using Ubuntulinux. There are many drivers that can be installed directly on Android, Linux and other embedded systems once they are compiled again with the appropriate Linux kernel. Of course, you can also test Linux drivers directly on the Android emulator, the Development Board, or even your phone.

For the development of Linux drive, the key is to be diligent and focus on practice. Can be improved by hands-on.

http://www.cnblogs.com/Mr-zsj/

"Android Deep Exploration" (Vol. 1) Hal and Driver development

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.