Sixth chapter
This chapter is the first section of Android's bottom-up development, which is the first Linux driver to count the number of words.
In this chapter, as the first chapter, the first thing to do is to understand what the Linux driver is, first of all, to understand how the Linux driver works, Linux system will each drive is mapped to a file, save in/dev, and then use the C function ioctl to drive the device file to send print commands. To write Linux drivers, you need to accept the data that is written, and send them to the printer via the PC's port, USB, and so on, which requires the data sent by the Linux response application.
Then write the steps for the Linux driver as follows:
1 build Linux drive skeleton.
Module_init and MODULE_EXIT Macro development
2 registering and unregistering device files
Misc_register Mics_deregister
3. Specify driver-related information
Module_author Module_license Module_alias module_description
4. Develop callback functions
5. Writing business logic
6. Writing the makefile file
7. Compiling Linux Drivers
8. Install and uninstall Linux drivers
Then we can actually start our program and use the device files as media to interact with the application. The application passes a space-delimited string to the device file, and then reads from the device file the number of words that the string contains. Before writing, first establish the directory of the driver, and then build the driver source code file and write a makefile file, then write a skeleton, such as a series of operations, through the book content can be perfectly compiled.
The last Test drive, you can use the method is:
1 Ubuntu Linux for testing
2 native C program test on Android simulator
3 using the Android NDK test
4 using Java code to directly manipulate device file testing
5 Testing with the s3c6410 Development Board
6 compiling the driver into the Linux kernel for testing
The last section describes the development and testing of Linux drivers using Eclipse, which facilitates deeper understanding of kernel technology.
The development steps are as follows:
1. Building C Project
2 establish C source code file link
3 Setting the Include path
4 Compiling Linux drivers
The test steps are as follows
1 Importing TEST_WORD_COUNT.C files
2 Setting the Include path
3 Setting up target
4build Engineering
5 Running the test program
Although the drive is not complex, it is enough to let me understand the driver's completion of the development process. Although this chapter is just a simple example, it contains a lot of content,
Android Deep explore HAL and Driver Development sixth chapter