Android kernel and driver

Source: Internet
Author: User

From: http://gmier.com/books/understanding-android-system/chapter2-kernel

 

We say that android is based on Linux, and the most fundamental reason is that android uses the Linux kernel.

2.1 Android kernel features

The android kernel is based on the Linux 2.6 kernel (the latest version is 2.6.31). It is an enhanced kernel version. Apart from modifying some bugs, it provides device drivers for supporting Android platforms, including:

  • Android Binder

A Driver Based on the openbinder framework, used to provide inter-process communication (IPC, inter-process communication) on the Android platform ).

The source code is in drivers/staging/Android/binder. c

  • AndroidPower Management (PM)

A lightweight Android power management Driver Based on the standard Linux Power Management System has been optimized for embedded devices.

The source code is located

Kernel/power/earlysuspend. c
Kernel/power/consoleearlysuspend. c
Kernel/power/fbearlysuspend. c
Kernel/power/wakelock. c
Kernel/power/userwakelock. c

  • Low Memory Manager (Low memory killer)

The out of memory mechanism is more flexible than the Linux Standard OOM (out of memory) mechanism. It can kill processes as needed to release the required memory.

The source code is in drivers/staging/Android/lowmemorykiller. c

  • Anonymous shared memory (Ashmem)

Provides a large shared memory for processes and a mechanism for the kernel to reclaim and manage the memory.

The source code is located in mm/ashmem. C.

  • Android pmem(Physical)

Pmem is used to provide continuous physical memory areas to the user space. DSPs and some devices can only work on continuous physical memory,

The source code is in drivers/MISC/pmem. c

  • Android Logger

A lightweight Logging Device used to capture various logs of the android System

The source code is in drivers/staging/Android/logger. c

  • Android alarm

A timer is provided to wake up a device from its sleep state, and a clock benchmark that runs even when the device is sleeping,

The source code is in drivers/RTC/alarm. c

  • USB GadgetDriver

A Device Driver Based on the standard Linux USB Gadget driver framework. The Android USB driver is based on the gaeget framework,

The source code is in drivers/USB/gadget/

  • Android Switch
  • Android Ram Console

To provide debugging functions, Android allows you to write debugging log information into a device called the ram console, which is a ram-based buffer.

The source code is in drivers/staging/Android/ram_console.c.

  • Android timed device

Provides timed Control for devices. Currently, vibrator and LED devices are supported.

The source code is in drivers/staging/Android/timed_output.c (timed_gpio.c ).

  • Yaffs2File System

Android uses yaffs2 as the mtd nand flash file system

The source code is located in the FS/yaffs2/directory.

Yaffs2 is a fast and stable cross-platform embedded device file system for NAND and nor flash. Compared with other flash file systems, yaffs2 uses smaller memory to save its running status, therefore, it occupies a small amount of memory. The garbage collection of yaffs2 is very simple and fast, so it can achieve better performance. The performance of yaffs2 is particularly significant in the large-capacity NAND Flash, suitable for large-capacity flash storage.

2.2 Android Kernel configuration

Android is based on Linux. For a new device, we must first compile a kernel that supports Android. How can we make your kernel android? In addition to the driver mentioned above, you need to configure your kernel to support the Android platform. For details, refer to the goldfish Kernel configuration file-ARCH/ARM/configs/goldfish_defconfig.

In general, we will configure the android kernel based on a standard Kernel configuration option. You can select the android Kernel configuration option based on the specific hardware platform. refer to the following Android Kernel configuration list:

Table 2-1: Required Enabled)

Android_paranoid_network
Ashmem
Config_fb_mode_helpers
Config_font_8x16
Config_font_8x8
Config_yaffs_short_names_in_ram
Dab
Earlysuspend
FB
Fb_cfb_copyarea
Fb_cfb_fillrect
Fb_cfb_imageb.pdf
Fb_deferred_io
Fb_tileblitting
High_res_timers
Inotify
Inotify_user
Input_evdev
Input_gpio
Input_misc
Leds_class
Leds_gpio
Lock_kernel
Lkogger
Low_memory_killer
Misc_devices
New_leds
No_hz
Power_Supply
Preempt
Ramfs
Rtc_class
Rtc_lib
Switch
Switch_gpio
Tmpfs
Uid_stat
Uid16
Usb_function
Usb_function_adb
User_wakelock
Video_output_control
Wakelock
Yaffs_auto_yaffs2
Yaffs_fs
Yaffs_yaffs1
Yaffs_yaffs2

Table 2-2: Required disabled)

Config_yaffs_disable_lazy_load
Dnotify

Table 2-3: Recommended Enabled)

Android_pmem
Android_ram_console
Android_ram_lele_error_correction
Schedstats
Debug_preempt
Debug_mutexes
Debug_spinlock_sleep
Debug_info
Frame_pointer
Cpu_freq
Cpu_freq_table
Cpu_freq_default_gov_ondemand
Cpu_freq_gov_ondemand
Crc_ccitt
Embedded
Input_touchscreen
I2C
I2c_boardinfo
Log_buf_shift = 17
Serial_core
Serial_core_console

After configuration, you can use toolchain to compile the kernel. It is relatively simple to compile the kernel. Take the emulator's kernel as an example:

-Git clone git: // android.kernel.org/kernel/common.git kernel-emulator
-CD kernel-emulator
-Git checkout original/Android-goldfish-2.6.29-B Android-goldfish-2.6.29
-Export arch = arm
-Export cross_compile = arm-Eabi-
-Export Path = <cross_compil_toolchain_path_dir>: $ path
-Make goldfish_defconfig
-Make

After compilation, the android emulator (goldfish) kernel is obtained.ARCH/ARM/boot/zimage

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.