Android from hardware to application: Step by Step 3, step by step android

Source: Internet
Author: User

Android from hardware to application: Step by Step 3, step by step android

The Android standard hardware driver is divided into two parts: one is the hardware driver running in the Linux kernel, and the other is the hardware abstraction layer running in the user space. By using this method, the system can be unrelated to hardware and protect the interests of some vendors. From hardware to application in Android: Step by Step, step by step. 1. Write the underlying hardware driver from scratch to the Linux kernel, next, let's take a look at how to add a hardware module to the hardware abstraction layer to interact with our kernel driver to complete hardware control.

Go to the hardware/libhardware/include/hardware directory and create android_gpio.h:

#ifndef ANDROID_ANDROID_GPIO_INTERFACE_H  #define ANDROID_ANDROID_GPIO_INTERFACE_H  #include Set_val and get_val are the APIS provided by the upper-layer applications of the HAL layer.

Cd to the hardware/libhardware/modules directory, create the android_gpio directory, and create the android. c file in it:

#include To prevent calling with Permission denied:

Open the system/core/rootdir directory and open ueventd. rc to add:

/dev/android_gpio 0666 root root
Add the Android. mk file in the android_gpio directory:

LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)LOCAL_MODULE_TAGS := optionalLOCAL_PRELINK_MODULE := falseLOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hwLOCAL_SHARED_LIBRARIES := liblogLOCAL_SRC_FILES := android_gpio.cLOCAL_MODULE := android_gpio.defaultinclude $(BUILD_SHARED_LIBRARY)
Compile the HAL layer:

mmm hardware/libhardware/modules/android_gpio
If an error occurs, refer:

No command 'mmm' found

You can create/lib/liblog. so without rules.

If successful, you can generate android_gpio.default.so

Install: out/target/product/generic/system/lib/hw/android_gpio.default.so
This is the hardware abstraction layer module we need. After this step is completed, we need to go up and finally complete the hardware call.

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.