Android driver development and debugging environment Configuration

Source: Internet
Author: User

This article uses the source code in the book "android Deep Exploration (Volume 1): Hal and driver development" as an example to describe how to configure the android driver development and test environment, and how to use build in the source code. the sh script file is used to compile, install, and test the Linux driver on various platforms (Ubuntu Linux, Android simulator, and cloud6410 Development Board. We recommend that you use Ubuntu linux12.04 or later to experiment with this article. It is best to log on to Linux with the root account.

1. Install the Cross Compiler

If you want to test the Linux driver on Ubuntu Linux, you do not need to install the cross compiler. However, to test the driver on the android simulator or the cloud6410 Development Board, you must install the cross compiler.

First download the Cross Compiler (volume compression)

Shard 1

Shard 2

Split Volume 3

After downloading and decompressing the package, you will find two tgz files. You can put these two files in the/root/compilers directory and enter the directory on the Linux terminal. Run the following command to install the cross compiler.

# tar zxvf arm-linux-gcc-4.3.2.tgz    -C    /# tar jxvf arm-none-linux-gnueabi-arm-2008q3-72-for-linux.tar.bz2     -C     /

Ii. Compile and test the Linux Kernel

Here there are two linux kernels, one is goldfish, that is, the Linux Kernel used by the android simulator, and the other is the Linux Kernel used by the s36410 Development Board (linux2.6.36 ). You must first download these two linux kernels.

Linux kernel source code for Android simulator (volume-based compression)

Goldfish (Volume 1)

Goldfish (vol. 2)

Goldfish (Volume 3)

Goldfish (Vol. 4)

Linux kernel source code (volume-based compression) USED FOR THE DEVELOPMENT BOARD)

Shard 1

Shard 2

Because the word_count driver in the book code has established symbolic links in goldfish and linux2.6.36 respectively, so that the word_count driver can be compiled during Linux kernel compilation, therefore, the Linux kernel and source code directory should be the same as the directory on the author's machine. The two Linux kernel directories and source code directories are as follows:

Linux Kernel Directory

/Root/kernel/goldfish

/Root/kernel/linux_kernel_2.6.36

Source code directory

/Root/Drivers

Note that the source code of each chapter is directly in the/root/DRIVERS directory, such as/root/Drivers/ch06 and/root/Drivers/ch07.

Now you need to add the/usr/local/ARM-None-Linux-gnueabi/bin path to the path environment variable of Linux (this is the basic function of Linux)

Finally, enter the/root/compilers/goldfish directory and execute the make command to compile the Linux kernel. If it is fully compiled, it may take about 20 minutes. After compilation, A zimage file is generated in the/root/kernel/goldfish/ARCH/ARM/boot directory, with the code 1.7 MB. This is the Linux Kernel File used for the android simulator.

3. Compile the Linux driver

Compile the driver of the CD. Here we use the word_count driver as an example. Go to the/root/Drivers/ch06/word_count directory on the Linux terminal. Do not compile it. First, set/root/Drivers/Common. sh file, modify the value of the ubuntu_kernel_path variable in the first line to the Ubuntu Linux kernel path installed on your machine. You only need to run the "ls/usr/src" command to view the available Linux Kernel on the current machine. For example, you can set the following path.

Ubuntu_kernel_path =/usr/src/linux-headers-3.2.0-23-generic

If you extract the source code of the Linux kernel from the preceding paths, you do not need to set the remaining two (initi6410_kernel_path and/root/kernel/goldfish.

Run the "source build. Sh" command in the word_count directory. the driver can be compiled on which platform. Press enter to compile the driver on Ubuntu Linux. If the compilation is successful, you will find one more word_count.ko file (driver file) in the current directory ).

Compile the word_count driver running on. Do not be busy. Before compiling, you need the ADB command in Android. Because build. SH is enough. After compilation, if multiple Android devices are connected to the PC, the user can select the device to which the upload is loaded. Here, you need to select the Development Board and then upload it directly to the Development Board, 1.

Figure 1

You can directly use the ADB shell command to enter the Development Board, or use/root/Drivers/shell. the sh script completes the same job, but if the latter has multiple Android devices, it will allow you to select, rather than entering the corresponding device ID. Makes operations more convenient. Many such scripts (shell. Sh, push. Sh, pull. Sh, etc.) are provided in the/root/DRIVERS directory. These scripts allow users to select the Android device to operate.

We usually use the ADB command in the android SDK to download the android SDK for Linux on the official website, and then add <androidsdk root directory>/platform-tools to the PATH environment variable.

Now execute the "source build. Sh" command again and select 2nd items (Development Board). if the system does not find the Development Board, unplug the USB cable and re-plug it. Then you can enter the terminal of the Development Board and enter the lsmod command to view the driver installation.

If the test is performed on the simulator, select 3rd items. For more information about the test method, see the relevant chapter in the document.

4. Test the Linux driver

There are many ways to test the word_count driver. For more information about how to test the word_count driver, see the corresponding chapter in the book. There is a test_word_count program in the word_count directory. You can test the word_count driver by executing the following command, the method book for compiling the test_word_count.c program has been described in detail.

Test_word_count "abc bb cc"

The preceding command outputs three words.

To compile Android Hal, the android source code is required. When purchasing the s36410 Development Board, merchants usually bring some CDs with the android source code for the Development Board. If the merchant does not give the CD, don't forget to ask for it!

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.