First knowledge of Android driver porting

Source: Internet
Author: User

Purpose

Because Biji wants to go to the company to do the company's question: the Android platform-based elevator advertising machine. The communication between the Android platform and the embedded system is implemented through the CAN bus. The specific hardware is MarsBoard-imx6q Mars Development Board, Phillip22 inch display, usb to CAN transceiver. Although it is an electronic professional, it was previously the main MCU and assembly. I have never touched on Android embedded systems. As the project progresses, I will write a series of blogs to record the confusions, solutions to the problems, and understandings of the problems. This method is used to record the path that has been taken.

Why Android embedded systems are open but not open-source

In the first two weeks, apart from specialized word specification training and AD6 PCB Drawing training, the remaining task is to go to Google and Baidu to understand the specific requirements and capabilities of the project. After some searches, I realized that the Android driver is basically the same as the Linux Driver (in fact, it is more complicated ). The Android kernel is the Linux kernel. To avoid the Hardware abstraction layer (HAL -- Hardware Abstarct Level) that Google adds to Android, it is to encapsulate specific Hardware logical operations. Because the Linux kernel must follow the GPL Protocol requirements to be open-source. If Android is completely open-source, hardware shanzhai cannot be imagined, which has a devastating impact on hardware vendors.

The Android framework must have seen the following figure before. But when I was working on this project, I had a different understanding of this image.

The kernel of the Android system is the Linux kernel. The figure also lists the important drivers in the Android system. On the top is the hardware abstraction layer, which is also made in C. on the top is the application framework and service program, which is written in C ++ and java, the top layer is APP, of course, written in java. Let's talk about the specific tasks we need to do: commonly used communication protocols in the industry include RS485 Ethernet CAN, etc. Because the company CAN bus is doing well, therefore, the communication protocol of the Android elevator advertisement machine uses the CAN bus. Therefore, we need to always use the CAN bus. For Linux drivers with several can Bus protocols under drivers/net/CAN/, we choose the freescale Flexcan. I will introduce the process of compiling the Android system and setting up the development environment in another blog. Set the Flexcan driver when running make menuconfig during Android kernel compilation ). The remaining task is to write the hardware abstraction layer and access the Flexcan device of the kernel through the hardware abstraction layer. With the hardware abstraction layer, the next step is to compile the JAVA Local interface. The Java Local interface JNI is used to connect the hardware abstraction layer and Framework layer. I will write several blog posts about JNI to consolidate my foundation. I will not repeat them here. My personal understanding is to convert local C/C ++ code to java. After writing JNI, we also need to write AndroidFramework Service, write Service programs to connect APP calls and JNI. Finally, you need to write an APP to call the Service-call JNI-call HAL-call the CAN driver .. It's troublesome .. Android adds three layers (compared with Linux) to obtain data, but we have to admire the Android UI interface. The user experience is really good, and the Android cross-platform is also good. In the future introduction, I plan to introduce some blog posts, such as the basic understanding of the CAN bus and the basic understanding of JNI programming, the simple Linux driver, and the specific operation of the Android hardware abstraction, sort out your specific ideas and methods.

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.