How to download and compile Android kernel goldfish?

Source: Internet
Author: User
Tags home screen

Prerequisites

Assuming that we already downloaded the android-ndk-r12b and SDK.

[email protected]: ~/utils$ ls
android-ndk-r12b Android-sdk-linux bin Goldfish nexus7

And then we need to set the environment.
Or You can download the VM has been set up directly. [1]

1. Edit ~/.BASHRC
# Add Android SDK Tools to the Pathexport android_sdk=~/utils/android-sdk-linuxexport path= $PATH: $ANDROID _sdk/tools:$ android_sdk/platform-tools# Add other custom utilities to the Pathexport path= $PATH: ~/utils/bin# set up Debugging Pathsexp ORT path= $PATH: ~/utils/android-ndk-r12b/prebuilt/android-arm64/gdbserver/:~/utils/android-ndk-r12b/prebuilt/ linux-x86_64/bin/# add Toolchain to the Pathexport path= $PATH: ~/utils/android-ndk-r12b/toolchains/x86_64-4.9/ prebuilt/linux-x86_64/bin:~/utils/android-ndk-r12b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/ bin:~/utils/android-ndk-r12b/prebuilt/android-arm64:~/utils/android-ndk-r12b/toolchains/ arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin:~/utils/android-ndk-r12b:~/utils/arm-eabi-4.8/bin:~/utils/ Android-ndk-r10eexport A24_include=~/utils/android-ndk-r12b/platforms/android-24/arch-arm64/usr/include/export A24_link=~/utils/android-ndk-r12b/platforms/android-24/arch-arm64/usr/lib/export A24_SYSROOT=~/utils/ Android-ndk-r12b/platforMs/android-24/arch-arm64/export a23_include=~/utils/android-ndk-r12b/platforms/android-23/arch-arm64/usr/ Include/export A23_link=~/utils/android-ndk-r12b/platforms/android-23/arch-arm64/usr/lib/export A23_SYSROOT=~/ utils/android-ndk-r12b/platforms/android-23/arch-arm64/

Then

$source ~/.bashrc
2. Download android-kernel-goldfish
$git clone http://android.googlesource.com/kernel/goldfish.git   $git branch -a  $git checkout -b debug-android-goldfish-3.18 remotes/origin/android-goldfish-3.18
3. Compile kernel

$make ARCH=arm64 ranchu_defconfig $make -j8 ARCH=arm64 CROSS_COMPILE=aarch64-linux-android-
Hint:adding an alias to your ~/.BASHRC file:

alias armmake="make -j16 KCFLAGS=-ggdb3 ARCH=arm64 CROSS_COMPILE=aarch64-linux-android-"
4. Create the emulator

Create an Android Virtual Device (AVD), and install a custom 3.18 kernel in it.

Run from the android avd terminal
Add a new AVD by clicking "Create"
Pick a suitable name (we chose W4118AVD)
Choose a Galaxy Nexus device
Target and Cpu/abi should self populate
Pick a "Skin with dynamic hardware controls"
Give at least 1500MB of RAM and a 256MB VM Heap
Tick on ' useHost GPU'

Once your AVD is set up, you can start it from the terminal with

$emulator @avdname -show-kernel

You need to open it with default kernel firstly; Otherwise, it cannot start it by above Emulator command.

    • Hardware acceleration must is enabled in your VMS settings for the AVD to boot.
    • The AVD can take up to ten minutes to boot. If the AVD fails to boot, try restarting your VMS and your Host machine and allocating more memory to the VM. Giving more RAM to the AVD can also is helpful.
    • If The emulator shows a completely black screen with a "Process System is ' t responding", click on Wait a few times and yo U'll get to the home screen soon.
5. Start the emulator

After compiling, you can start the emulator again.

$emulator @w4118avd -kernel arch/arm64/boot/Image -show-kernel -no-window -verbose -netfast
On x86_64 Emulator
$make ARCH=x86_64 x86_64_ranchu_defconfig$make -j16 ARCH=x86_64 CROSS_COMPILE=x86_64-linux-android- 2>&1 |tee kernel_make.out$emulator -verbose @x86 -kernel arch/x86/boot/bzImage -show-kernel -no-window -qemu --enable-kvm 2>&1 | tee boot_errors

On Armv7-32bit

kernel:android-goldfish-3.10
Rom:android 7.0
toolchain:arm-eabi-4.8 (doesn ' t include in ndk-r12b)
Command:

$make ARCH=arm ranchu_defconfig$make -j16 ARCH=arm KCFLAGS=-ggdb3 CROSS_COMPILE=arm-eabi-$emulator @arm32 -kernel arch/arm/boot/zImage -show-kernel -no-window -verbose -netfast
On x86 (not used)

kernel:android-goldfish-3.10
Rom:android 7.0
Command:
Edit. config:

  │    [*] KGDB: kernel debugger  --->     │ │    [*] Compile the kernel with debug info                                     │ │    │ │    [*]   Provide GDB scripts for kernel debugging                  
$make ARCH=x86 i386_ranchu_defconfig$make -j7 KCFLAGS=-ggdb3 ARCH=x86 $emulator @x86 -kernel arch/x86/boot/bzImage -show-kernel -no-window -verbose -netfast
Kernel and ROM matched table

Other useful command
#### Android Stop Emulator from Command Line    adb emu kill#### Get the kernel messages    adb shell dmesg    adb shell cat /proc/kmsg#### Redirecting kernel logs:    For Windows:‐> adb shell cat /proc/kmsg > kernelmsg.txt    For Linux:‐‐> adb shell cat /proc/kmsg | tee ‐a kernelmsg.txt    

stop-emulators.sh

#!/bin/bashfor ((PORT=5554; PORT<=5584; PORT+=2)); do    echo killing emulator-$PORT...    adb -s emulator-$PORT emu killdone
Ref:

[1] http://www.cs.columbia.edu/~nieh/teaching/w4118/homeworks/hmwk2.html
[2] Http://blog.chinaunix.net/uid-29616823-id-4891227.html
[3] http://blog.csdn.net/mr_raptor/article/details/7954474
[4] https://github.com/openthos/openthos/wiki/AOSP-6.0-x86_64-kernel-3.10-in-ubuntu-15.04
[5] Http://tic-le-polard.blogspot.fr/2015/06/android-building-android-kernel-for_6.html

How to download and compile Android kernel goldfish?

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.