The Linux Kernel: Android?

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.

android_03.png


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).

android_01.png


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.

android_04.png


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).

android_02.png


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.

android_05.png


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

  • slide.JPG
    slide.JPG
    21.5 KB · Views: 122,287
Last edited:


Thanks @ryanvade for the great link.

Here is a quote from that page that I find very interesting -

Android runs the same kind of Linux kernel that embedded Linux runs and shares the same drivers, memory management and networking capabilities. But it also includes some kernel modifications that make it ideal for mobile systems. And it comes loaded with extra features pulled from other open source projects.
 
You can post "Android is Linux" as many times as you like, but it's not going to get any truer...

Android is a Linux kernel based embedded OS, that's just about where the similarity ends.

Comparing the GNU userland with something like Dalvik is an erroneous and misleading comparison. You need only read briefly about the two to find that there is no analogue between them.

GNU/Linux is the operating system we use and why we are here posting on this forum. Distributions are "packagers" for this OS - including what they want to include, excluding what they don't want to include - but the vast bulk of a GNU/Linux system is the same, the same kernel, one of a handful of init systems, libc,

Linux is just a kernel. Android is not the only embedded Linux based system. Cisco and many other routers, kindle, TomTom, etc all fit the bill... it goes on and on...

GNU/Linux is a true Linux based computer operating system. Many of the apps, window managers, desktop environments and tools you take for granted are UNIX stuff or *BSD stuff as well as GNU stuff like glibc, gcc, coreutils, binutils, bash, etc. Many apps, X.org, most X apps and the desktops/WMs for example, are cross platform *nix software, not GNU/Linux software.

GNU/Linux belongs to a family of UNIX-like operating systems - but few *nix systems are fully POSIX compliant. Android and other Linux based embedded systems certainly do not belong simply by virtue of being Linux based - and none are even remotely close to POSIX compliancy.
 
I have been downloaded android generic kernel 3.10 and tried to compile it ussing android-x86 2.2.1. I can create android generic kernel 3.10 config file succesfully and build iso image successfully too. But I had a problem with mouse.I can move mouse pointer but the click function of mouse didnt work. Any suggestion to solve this problem.When I used default kernel from android-x86 2.2.1. The mouse was working fine.I had same problem with android generic kernel 3.4 too.Thanks
 
I have been downloaded android generic kernel 3.10 and tried to compile it ussing android-x86 2.2.1. I can create android generic kernel 3.10 config file succesfully and build iso image successfully too. But I had a problem with mouse.I can move mouse pointer but the click function of mouse didnt work. Any suggestion to solve this problem.When I used default kernel from android-x86 2.2.1. The mouse was working fine.I had same problem with android generic kernel 3.4 too.Thanks

On Android systems, not all mice will work. Also, some people claim that the hardware must use "USB-on-the-Go" or "USB OTG" (http://www.androidpit.com/usb-otg-what-it-means-and-how-to-use-it). It may also help if you use the newest Android kernels if you are wanting better support for mice.
 
You meant i should buy USB hub which supported OTG and connect to my netbook that ran android-x86 2.2.1 on usb flashdisk with android generic kernel 3.10.The question is why can I use my mice and keyboard when I still used android kernel 2.6.35 on android-x86 2.2.1. When I ran android-x86 2.2.1 with kernel 3.10. I can move my mouse pointer but I cant execute it by clicking the mice.So I can solve this problem with usb hub supported OTG and connect to the mice ? I also added synaptics touchpad module in kernel 3.10 but it didnt work.
 
Last edited:
You meant i should buy USB hub which supported OTG and connect to my netbook that ran android-x86 2.2.1 on usb flashdisk with android generic kernel 3.10.The question is why can I use my mice and keyboard when I still used android kernel 2.6.35 on android-x86 2.2.1. When I ran android-x86 2.2.1 with kernel 3.10. I can move my mouse pointer but I cant execute it by clicking the mice.So I can solve this problem with usb hub supported OTG and connect to the mice ? I also added synaptics touchpad module in kernel 3.10 but it didnt work.

The USB on the Android device itself must support USB OTG.
 
The USB on the Android device itself must support USB OTG.
What I knew from android-x86 2.3 ( gingerbread) until kitkat supported USB OTG. Android generic kernel 3.10 was kernel for android-x86 kit-kat. I just used it for android-x86 2.2.1.I will try it your suggestion.Because i need usb converter micro usb to standard usb for my netbook.Thanks
 
By the way, all of the Google's changes to the Linux kernel for Android are included in the latest vanilla kernels. You can run the Android stack on top of the latest kernels.
 
I have been tried vanilla kernel since kernel 3.6.39 until 3.10.
And I got some drivers problem on vanilla kernel.For example android generic kernel 3.10 had a problem with intel gma500, wireless driver wil 6210.For standard linux kernel 3.10 will not have this kind of problem.When I loaded intel gma500 into android generic kernel 3.10. The display will be blank screen and I only can use vesa driver.Because I had added all drivers into android generic kernel 3.10 like standard ubuntu kernel 3.10.
 
I already used USB OTG on Android-x86 lollipop and Android-x86 Froyo with vanilla kernel 3.18.But it didn't change any mouse performance. I can't execute it too. I just can move mouse pointer smoothly
 
Anyone can fix a missing link between vanilla kernel and. Java GUI on android-x86 when I used custom kernel for existing android-x86 ? I can move mouse pointer but I cant execute it...:)...thanks
 


Top