D
DevynCJohnson
Guest
Series Index - http://www.linux.org/threads/linux-kernel-reading-guide.5384/
Aloha! Now that we have studied the Linux kernel very well and learned how to make our own, we will move on to a slightly different direction in this series. Many of you may be unaware of this, but Android is Linux. True, they are not quite the same, but Android is Linux. For example, Ubuntu is "GNU/Linux" while Android is "Dalvik/Linux". If an operating system uses the Linux kernel, then it is a Linux system. The userland (GNU and Dalvik) does not determine whether an OS is Linux or not. Android uses a modified Linux kernel. As we know, Android runs on phones. As you may remember from configuring the kernel, there were no drivers for phone devices (like small keypads, 3G/4G cards, SIM cards, etc.). The Linux kernel used in Android lacks drivers that would not be in phones and instead has drivers for phone devices. In other words, no Android system uses a Vanilla Kernel.
NOTE: Some people say "Android/Linux" instead of "Dalvik/Linux". However, both are valid.
Linux kernels for Android can be downloaded or viewed here - (https://android.googlesource.com/?format=HTML). Just like the Vanilla kernel, the Android kernel is open-source software (due to the GPL license on the Vanilla kernel). The generic Android kernel can be seen here - (https://android.googlesource.com/kernel/common.git/ /android-3.10) [for kernel v3.10] which looks very similar to the Vanilla kernel.
NOTE: In this article and series, "Android Kernel" will be used interchangeably with "Linux kernel for Android" and other similar phrases.
The ./android/ directory contains a configuration file for making the Android kernel. These files tell the configuration tool which features/modules/drivers to enable or disable (https://android.googlesource.com/kernel/common.git/ /android-3.10/android/configs/android-base.cfg).
Some proprietary or special hardware may have a kernel designed specifically for them. For instance, kernels for Samsung phones can be downloaded here (https://android.googlesource.com/kernel/samsung/).
DOWNLOAD: To download an Android kernel, look to the "tgz" hyperlink near "Commit" around the top of the screen. Here is a download link - https://android.googlesource.com/kernel/common.git/ archive/android-3.10.tar.gz
As seen in the ./security/ folder of the kernel's source code, Android supports the same Linux Security Modules (LSMs) that a desktop/server kernel would. By looking at any part of the Android kernel, the Android and Vanilla kernel are nearly the same. For illustration, the same filesystems are seen in Android's filesystem driver directory (./fs/) as in the Vanilla kernel.
To configure the kernel, do as you would for a Vanilla kernel - open a terminal in the source code directory and type "make <PREFERRED CONFIG TOOL>". I will use "make menuconfig" for my screenshots. Here is the most important step, load an alternate configuration file such as "./android/configs/android-base.cfg". Now, you can configure the kernel. However, be careful not to undo a feature/option that is important to Android (like ashmem). Also, you may see in the configuration tool (after loading the proper config file) that Android is an embedded Linux system. Keep this in mind when configuring the kernel. When configuring the Android kernel, it is very important to note that it must be cross-compiled.
NOTE: To know which features should not be changed, open the loaded configuration file in a text-editor (such as Gedit, Leafpad, etc.). The listed features should not be manipulated unless you have a specific purpose for doing so.
Once you have finished configuring the system, save the configuration as "./.config". Overwrite the file if needed (make a backup if the original "./.config" is important).
Before compiling, the host system must have JDK 6, Python2.7, and various developer's libraries installed on your system. Many developers recommend compiling the kernel on a 64-bit system (doing so on a 32-bit system is possible, but more difficult). Also, remember to set these variables before executing the "make" command -
The developer libraries I mentioned can be installed like this (for RedHat-based systems, use "yum" instead of "apt-get") -
Also, make sure that the proper cross-compiler is installed on your system (arm-eabi).
Making a symbolic link for this library may help on some systems -
NOTE: Some other libraries or links may be needed. If so, the compiler will give an error that a library or file is missing. Install or link as needed.
If the configuration and compiling process went well, the Android kernel is ready for a device. The process of installing an Android kernel is a process that requires more knowledge in Android development and many more steps. So, I will not discuss the Android kernel that far.
Patches can be applied to the Android kernel's source code the same way as the Vanilla kernel, except the patches must be Android patches. The patches on Kernel.org will not work. They may work in some instances, but you must know what you are doing and only apply them to drivers/modules that are still Vanilla (unaltered from the original).
There are a few different kinds of Android kernels as seen on the Android kernel's Git page (https://android.googlesource.com/?format=HTML).
The Goldfish kernel (https://android.googlesource.com/kernel/goldfish/) is for emulated platforms like running a virtual Android system within a host system on a desktop computer.
The MSM kernel (https://android.googlesource.com/kernel/msm/) is for Qualcomm MSM chipsets.
The OMAP kernel is for the TI OMAP chipsets (https://android.googlesource.com/kernel/omap/).
Samsung hummingbird chipsets use the Samsung kernel (https://android.googlesource.com/kernel/samsung/).
The NVIDIA Tegra chipsets run on the Tegra chipset kernel (https://android.googlesource.com/kernel/tegra/).
The Exynos kernel is used by Samsung Exynos chipsets.
These various kernels mainly variety in their driver availability. For example, the Exynos kernel will have drivers for Exynos Samsung devices while the OMAP kernel does not.
Now, your understanding of Android should be larger than it was before. Feel free to send me more ideas on this article series or any Linux article in general. I hope to make this series continue for as long as I can. Mahalo!
Aloha! Now that we have studied the Linux kernel very well and learned how to make our own, we will move on to a slightly different direction in this series. Many of you may be unaware of this, but Android is Linux. True, they are not quite the same, but Android is Linux. For example, Ubuntu is "GNU/Linux" while Android is "Dalvik/Linux". If an operating system uses the Linux kernel, then it is a Linux system. The userland (GNU and Dalvik) does not determine whether an OS is Linux or not. Android uses a modified Linux kernel. As we know, Android runs on phones. As you may remember from configuring the kernel, there were no drivers for phone devices (like small keypads, 3G/4G cards, SIM cards, etc.). The Linux kernel used in Android lacks drivers that would not be in phones and instead has drivers for phone devices. In other words, no Android system uses a Vanilla Kernel.
NOTE: Some people say "Android/Linux" instead of "Dalvik/Linux". However, both are valid.
Linux kernels for Android can be downloaded or viewed here - (https://android.googlesource.com/?format=HTML). Just like the Vanilla kernel, the Android kernel is open-source software (due to the GPL license on the Vanilla kernel). The generic Android kernel can be seen here - (https://android.googlesource.com/kernel/common.git/ /android-3.10) [for kernel v3.10] which looks very similar to the Vanilla kernel.
NOTE: In this article and series, "Android Kernel" will be used interchangeably with "Linux kernel for Android" and other similar phrases.
The ./android/ directory contains a configuration file for making the Android kernel. These files tell the configuration tool which features/modules/drivers to enable or disable (https://android.googlesource.com/kernel/common.git/ /android-3.10/android/configs/android-base.cfg).
Some proprietary or special hardware may have a kernel designed specifically for them. For instance, kernels for Samsung phones can be downloaded here (https://android.googlesource.com/kernel/samsung/).
DOWNLOAD: To download an Android kernel, look to the "tgz" hyperlink near "Commit" around the top of the screen. Here is a download link - https://android.googlesource.com/kernel/common.git/ archive/android-3.10.tar.gz
As seen in the ./security/ folder of the kernel's source code, Android supports the same Linux Security Modules (LSMs) that a desktop/server kernel would. By looking at any part of the Android kernel, the Android and Vanilla kernel are nearly the same. For illustration, the same filesystems are seen in Android's filesystem driver directory (./fs/) as in the Vanilla kernel.
To configure the kernel, do as you would for a Vanilla kernel - open a terminal in the source code directory and type "make <PREFERRED CONFIG TOOL>". I will use "make menuconfig" for my screenshots. Here is the most important step, load an alternate configuration file such as "./android/configs/android-base.cfg". Now, you can configure the kernel. However, be careful not to undo a feature/option that is important to Android (like ashmem). Also, you may see in the configuration tool (after loading the proper config file) that Android is an embedded Linux system. Keep this in mind when configuring the kernel. When configuring the Android kernel, it is very important to note that it must be cross-compiled.
NOTE: To know which features should not be changed, open the loaded configuration file in a text-editor (such as Gedit, Leafpad, etc.). The listed features should not be manipulated unless you have a specific purpose for doing so.
Once you have finished configuring the system, save the configuration as "./.config". Overwrite the file if needed (make a backup if the original "./.config" is important).
Before compiling, the host system must have JDK 6, Python2.7, and various developer's libraries installed on your system. Many developers recommend compiling the kernel on a 64-bit system (doing so on a 32-bit system is possible, but more difficult). Also, remember to set these variables before executing the "make" command -
Code:
export ARCH=arm
export SUBARCH=arm
export CROSS_COMPILE=arm-eabi-
The developer libraries I mentioned can be installed like this (for RedHat-based systems, use "yum" instead of "apt-get") -
Code:
sudo apt-get install git gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386
Also, make sure that the proper cross-compiler is installed on your system (arm-eabi).
Making a symbolic link for this library may help on some systems -
Code:
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
NOTE: Some other libraries or links may be needed. If so, the compiler will give an error that a library or file is missing. Install or link as needed.
If the configuration and compiling process went well, the Android kernel is ready for a device. The process of installing an Android kernel is a process that requires more knowledge in Android development and many more steps. So, I will not discuss the Android kernel that far.
Patches can be applied to the Android kernel's source code the same way as the Vanilla kernel, except the patches must be Android patches. The patches on Kernel.org will not work. They may work in some instances, but you must know what you are doing and only apply them to drivers/modules that are still Vanilla (unaltered from the original).
There are a few different kinds of Android kernels as seen on the Android kernel's Git page (https://android.googlesource.com/?format=HTML).
The Goldfish kernel (https://android.googlesource.com/kernel/goldfish/) is for emulated platforms like running a virtual Android system within a host system on a desktop computer.
The MSM kernel (https://android.googlesource.com/kernel/msm/) is for Qualcomm MSM chipsets.
The OMAP kernel is for the TI OMAP chipsets (https://android.googlesource.com/kernel/omap/).
Samsung hummingbird chipsets use the Samsung kernel (https://android.googlesource.com/kernel/samsung/).
The NVIDIA Tegra chipsets run on the Tegra chipset kernel (https://android.googlesource.com/kernel/tegra/).
The Exynos kernel is used by Samsung Exynos chipsets.
These various kernels mainly variety in their driver availability. For example, the Exynos kernel will have drivers for Exynos Samsung devices while the OMAP kernel does not.
Now, your understanding of Android should be larger than it was before. Feel free to send me more ideas on this article series or any Linux article in general. I hope to make this series continue for as long as I can. Mahalo!
Attachments
Last edited: