Simple Guide for porting Android kernel (portingnote)

Source: Internet
Author: User

Original: Xu Yu Please refer to the outgoing http://blog.csdn.net/colorant/
Increment: rider

1. Android core porting background awareness 1.1 runtime platform

From Google's Android platform to 20020227, the application is still in binary format, its programming standards platform ARM926EJ-S CPU is equivalent to the armv5t version, so the armv4 framework of the CPU platform can not use the second generation. For more information, see the following article. Here, Benno makes a theoretical analysis and representative analysis:Http://benno.id.au/blog/2007/11/21/android-neo1973. However, according to the current scenario, in addition to the Platform Based on armv5 or above, the platform can be used for Android and armv4, please refer to some of benno's bottom links in the article for further operation steps. He has some release patches that can be used by porting.

1.2 experiences (Development Resources)

Android official download:

Kernel, emulator, and development tool:Http://code.google.com/p/android/downloads/list
Android SDK connector: http://developer.android.com/sdk/1.5_r1/index.html

1.2.1 Kernel

Android kernel is developed based on the internal kernel of linux2.6.23, it mainly adds a dedicated CPU named goldfish and a specific dynamic generation required by Android. You need an Eabi-supported internal core as the starting point of your internal core porting (minimum version? I don't know. As long as Eabi is OK, there should be no difference in the quality. However, many Android drivers rely on the internal core API 2.6.23, and the earlier the version, the larger the workload of porting and modifying the core-related token ).

Interested developers canHttp://android.git.kernel.org/Use git's latest Android code to patch or modify it to the kernel that can be run on the platform. for example, I used the GIT patch and then follow Benno release patch to generate a kernel that can be run on the ARM920T board.

1.2.2 toolchain

The core in the SDK uses GCC of version 4.2.1. Basically, you need a tool that supports Eabi. For example, you can use the latest tool provided by codesourcery.Http://www.codesourcery.com/sgpp/lite/arm/portal/release642Run the toolchain for ARM Eabi of ia32 GNU/Linux. You can also run the official toolchain used by benchmark benno's (usage:Http://android.git.kernel.org/pub/android-toolchain-20081019.tar.bz2)

1.2.3 other tools

Android emulator is a good simulation tool. Its bottom layer is based on qemu. You can use the ADB tool in the SDK to log on to the emulator console, and the console in order to obtain the required filing system. You can also let the emulator run the existing kernel.

1.3 references

Http://benno.id.au/blog/

Http://groups.google.com/group/android-internals

Http://groups.google.com/group/android-developers2. Porting basic ideas 2.1 required resources 2.1.1 hardware

First of all, of course, a hardware development board that can be used up to porting is required. In addition to the hardware requirements described above, armv5 + compatible CPU is required, the minimum requirement is 64 m + memory, and 64 m-128 M + flash (depending on how you add the fuse file system, if you can use a NFS-ROOT or mmccard to store file systems through the Web, this should not be done ).

2.1.2 experiences

In addition to the preceding kernel and toolchain, it is recommended that tools such as busybox and strace of kernel be provided to facilitate kernel compaction. You can also download and download the latest version from Benno's blog.

2.2 Basic Process

Android Kernel

  1. Run kernel 2.6.24.
  2. Used as the diff file for Android and 2.6.24 kernels.
  3. Remove the tokens in the diff file that are related to goldfish and qemu. If your system already supports yaffs2, you can also remove this part of the tokens that are related to goldfish and qemu In the diff file, and then patch the diff file to your own core. If necessary, modifying the kernel-related file replacement allows the patch to be completed successfully. Patch the diff file to your core. If necessary, modify the internal core-related file replacement so that the patch can be completed successfully. (This part is probably the main workload, if your core version is worse than your core version ).
  4. If necessary, modify the actions of framebuffer in your core generation, so that its virtual_yres is equal to two times the yres, and allocate two times the resolution of the framebuffer memory.

Configure the core to ensure that the following content is configured (for armv4t ):

Config_aeabi = yconfig_arm_thumb = yconfig_android_binder_ipc = yconfig_android_logger = yconfig_shmem = yconfig_ashmem = yconfig_android_paranoid_network = y
  • Obtain the android file system from the SDK. Basically, you only need the system etc sbin init file system, here, the data category has content, but the content of this category can be created by the Android mobile manual.
  • You can use the ADB tool to tar the package and copy the package to the emulator. M3 release can also directly obtain the file system he captured from Benno.
  • Ensure that your Dev project has enough dynamic configuration points, such as the console, other tracking points android will be automatically created during the tutorial process.
  • Android File System Using nfsroot or chroot.

The General External table partition sections of the dynamic process are as follows:

Ø Android characters are displayed on the LCD. ø blank of the LCD for a short period of time. There is a left-and-Right animated dynamic color on the LCD. (if there is a problem, this step is basically the end of the process. (enter the main interface. Currently, my website is: zookeeper can work, and the screen is shown with response, but not in school, the location is not correct. When the last segment of the callback and the last segment are used to initiate a new program, the problem of vmalloc allocating memory failed occurs, applications such as Brower cannot be completely released. Other websites and other things haven't started to be viewed yet. 3. Some tips
  • Android uses memory mapped to perform operations on files. jffs2 does not support this operation, so it must use a different file system. Of course, there are also methods to analyze the past. Please search for them yourself.
  • You can modify/etc/init. RC, Zookeeper, and other related content such as runtime, kernel-daemon, and xzygote can be manually modified after the init operation starts:

/System/bin/app_process-xzygote/system/bin-zygote & /System/bin/container-Daemon-system-nofork & Sleep 1; sleep 1; /System/bin/runtime &

  • Android init is in the root directory, so if you need to directly invoke init, you can use init =/init in the internal kernel data command line to specify it, or specify the chroot category/init. Of course, it is also possible to manually trigger the/bin/sh operation.
  • Files such as/dev/binder/dev/alarm/dev/log/* are the most important configuration points, because the Primary and Secondary configuration items of these configuration points are automatically allocated, it is best to confirm whether the primary and secondary configuration items in your file system are correct. If you do not know how to confirm the operation, delete it and then re-initiate the operation.
  • If the Flash speed is too slow or the NFS network connection is too slow, you can mount the two data TMP files to the memory, the premise is that you have a large experience.
  • If the process of dynamic motion is too fast (compared with the current table in emulator), the CPU usage rate of the runtime or system_server process is close to 100%, then, you can modify the pan_display function data generation in your framebuffer parameter to ensure that the response time can be used for full synchronization delay. According to Google's swetland, this is usually indicative of lack of vsync/pageflip In the FB driver. the surfaceflinger believes it will be limited by the vsync rate and the startup animation depends on that.
  • The current Android kernel generation has two versions of M3-r20 and M5-r14, these two versions of the binder and Power modified greatly, the file system and core of the upload must be used together. (In addition, on my board, the M5 version can run, and the M3 version will have a failed version. (If a version cannot run, please refer to other versions ). Use strace to track problems!
  • Use strace to track problems!
4. Android Resources & reference
  • Android Development Community:Http://www.anddev.org/
  • Compilation of Android kernel:Http://wiki.droiddocs.net/Compilation_of_Android_kernel
  • Android guide @ TW: Http://code.google.com/p/androidbmi/w/list
  • Android kernel quota method:Http://blog.chinaunix.net/u/26691/showart_468007.html
  • Android news/resources collection:Http://rider51.wordpress.com/2008/05/14/android-news-apps-platform/
5. Android porting on ARM920T Platform Process (by rider ): Step 1:Go to the http://android.git.kernel.org/go to git for an android project source. Step 2:Select the toolchain you want to use. The following links of the Android-toolchain can be captured (it is suggested that the success rate of Android-toolchain is higher than the success rate ), certainly, codesourcery can also be used (with more problems ). of course, if the two toolchains are both secure, and you happen to use Deb system, then you can go to koolu to compile the toolchain they have packaged (which is included below ). if you directly use the package for security protection, the setting of security protection will go to/opt/Android-toolchain/ Step 3:Next, release the Benno's patch and then patch one by one! Because the time points are different, the android project source version is not the same. therefore, many problems may occur during the patch process. Therefore, it is recommended that you understand the modified parts and concepts of the patch and patch them one by one. Step 4:I also used change set 1663, So That Macros (ASM code) Not supprot V4 Instruction Set Issues will not occur during startup. Step 5:You can compile a script to facilitate future operations. I usually use an androidv4.sh (as shown below) (remember to compile: MTD-tools first)

#! /Bin/sh

Make target_arch_version = armv4/ Mkjffs2_cmd = "ssh Nirvana-x/" CD 'pwd'; mkfs. jffs2 /』"/ System_fstype = jffs2/ Userdata_fstype = yaffs/ Target_tools_prefix =/home/rider/Android-toolchain/bin/armv4t-android-eabi-$ @
Step 6:Run this script to start running the script ~ Good luck! XD Step 7:After successful failover, rootfs: ramdisk. IMG, userdata. IMG & system. IMG will be generated.
  • Ramdisk. IMG:The ramdisk image used to boot the system.
  • Userdata. IMG:The initial user-data disk image.
  • System. IMG:The initial Android system image.
Step 8:Then there is the kernel, openmoko users can follow the Benno suggestions to use the OpenMoko-2.6.24 stable to patch into for Android kernel. I directly go to kernel 2.6.24 kernel under kernel .org to patch the kernel. please take the links below kernel patch & config. howto make:
  1. Rider @ embedded :~ /Android/linux-2.6.24 $ patch-P1 <../android-openmoko-kernel.diff
  2. Rider @ embedded :~ /Android/linux-2.6.24 $ make-J 2 zimage arch = arm cross_compile = armv4t-android-eabi-
  3. Then ARCH/ARM/boot/zimage is ready.
Step 9:After installing images, you can use the modulo tool provided by the SDK to view the Kernel & rootfs provided by the kernel. Remember to point to the correct image storage location.
  • Run: Emulator-kernel./zimage-system./system. IMG-ramdisk./ramdisk. IMG-initdata./userdata. img
  • Or run: Emulator-kernel./zimage-system./IMG (store all three IMG files under the img/object)
Reference:
  • Download android_toolchain:Http://android.git.kernel.org/pub/android-toolchain-20081019.tar.bz2
  • Android-toolchain for Debian/Ubuntu:Http://trac.koolu.org/raw-attachment/wiki/Toolchain/android-toolchain_20081019-koolu1_i386.deb
  • Compiling-for-armv4t: http://benno.id.au/blog/2008/10/23/compiling-for-armv4t
  • Android on armv4:Http://benno.id.au/blog/2008/10/27/android-on-armv4-take2
  • Android kernel-config (by Benno): http://benno.id.au/android/android-kernel-config
  • Android Kernel Patch: http://benno.id.au/android/android-openmoko-kernel.diff
  • Changesets to enable compiling for ARM-arch:Https://review.source.android.com/Gerrit#change,1663
Modified by rider

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.