Android Deep Explore Reading notes

Source: Internet
Author: User

Android Deep Exploration ( volume 1) HAL reading notes with drive development

The fifth chapter of the Building s3c6410 Development Board test environment can be divided into the following parts:

1 initializing Cdev with Cdev_init

2 Specifying the device number

3 using the Cdev_add function to add a character device to a character device group in the kernel

4 Creating a struct class using Class_creat macros

5 Creating a device file using the Device_creat function

then uninstall the LED-driven device files to uninstall LED-driven device files:

void Device_destory (Sruct class *class,dev_t devt)

void Clss_dsetroy (struct class *class)

void Unregister_chrdex_region (dev_t from,unsigned count)

When setting registers and initializing led drivers, it is understood that LEDs have two pins: GPB0 and GPB1. One of the pins is connected to the ARM processor's GPI0 port, and the other pin is connected to the power supply via a current-limiting resistor. The control LEDs need to be completed by 3 registers, Gpmcon, Gpmdat, Gpmpud, respectively. Each register can use 4 bytes.

the sixth chapter first one Linux Programs: Count the number of words mainly about how to design a statistical word number of the program, the following is the steps:

1th Step: Build Linu x Drive skeleton (load and unload Linu x drive); 2nd step: Register and unregister the device files; step 3rd : Specify driver-related information; 4th step : specify the callback function; 5th step : write the business logic; 6th step: Write the makefile file; 7th step z compile the Linux driver; Step 2 install and uninstall Linux drivers ;

The printf function runs in user space, and the PRINTK function runs in kernel space.

testing Linux Driver steps :

First step: Import the Test_count.c file ; Step Two: Set the include path ; Step three: Set up target ; Fourth Step: Build Project ; Fifth Step: Run the test program ;

Using the Android NDK test

Use Java code to directly manipulate device file tests: You need to have root privileges.

The seventh chapter of the control light emitting diode can be divided into the following parts:

1. a complete Linux driver mainly consists of internal processing and hardware interaction, in which the internal processing mainly refers to the Linux driver loading, unloading, device file-related action processing and business logic, etc., and the hardware interaction mainly refers to the function and the hardware register to interact with the data.

2. LED Driver Implementation principle: Although the Linux driver deals directly with the hardware, it is not the Linux driver that writes data directly to the memory in the hardware, but interacts with the native I/O memory. Every hardware that connects to Linux has a mapped first address in I/O memory.

3. led has two pins: GPB0 and GPB1, control LEDs need to be completed by 3 registers, 3 registers are gpmcon,gpmdat and gpmpud, each register can use 4 bytes ; Use the low 16 bits of the Gpmcon register to set the two port properties of the led to output, the low 4 bits of the Gpmdat register to control the light off of 4 LEDs, and the low 8 bits of the GPMPUD register to turn on the pull-up circuit of the 4 LEDs respectively.

4. To create an LED-driven device file: The first step is to initialize the Cdev with the Cdev_init function; The second step is to specify the device number, and the device number is specified in the code and assigned dynamically in two ways, and the third step is to use the CDEV_ The Add function adds a character device to the character device array in the kernel; Fourth, create a struct class using the Class_create macro, and fifth step, create the device file using the Device_create function. http://www.cnblogs.com/xcswdd/

Android Deep Explore Reading notes

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.