Prerequisites

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

w4118@w4118:~/utils$ ls

android-ndk-r12b android-sdk-linux bin goldfish nexus7

And then we need to set up the environment.

Or you can download the vm having been set up directly. [1]

1. Edit ~/.bashrc

# add Android SDK Tools to the path
export ANDROID_SDK=~/utils/android-sdk-linux
export PATH=$PATH:$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools # add other custom utilities to the path
export PATH=$PATH:~/utils/bin # set up debugging paths
export PATH=$PATH:~/utils/android-ndk-r12b/prebuilt/android-arm64/gdbserver/:~/utils/android-ndk-r12b/prebuilt/linux-x86_64/bin/ # add toolchain to the path
export 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-r10e export 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 android avd from the 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 "Use Host 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 be enabled in your VM settings for the AVD to boot.
  • The AVD can take up to 10 minutes to boot. If the AVD fails to boot, try restarting your VM and your Host machine and allocating more memory to the VM. Giving more RAM to the AVD can also be helpful.
  • If the emulator shows a completely black screen with a "Process System isn't responding", click on Wait a few times and you will 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/bash
for ((PORT=5554; PORT<=5584; PORT+=2)); do
echo killing emulator-$PORT...
adb -s emulator-$PORT emu kill
done

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 ?的更多相关文章

  1. [原]Ubuntu 14.04编译Android Kernel

    如何编译android kernel参考官方文档:https://source.android.com/source/building-kernels.html   在Ubuntu 14.04上编译a ...

  2. Compile android source and kernel for emulator in Debian

    1.download the android source code Reference from http://source.android.com/source/downloading.html ...

  3. 【Android 系统开发】下载 编译 Android源代码 和 Android kernel源代码

    下载Android源码简要流程 : a. 获取repo文件: curl http://commondatastorage.googleapis.com/git-repo-downloads/repo ...

  4. 下载 编译 Android源代码 和 Android kernel源代码

    下载Android源码简要流程 : a. 获取repo文件: curl http://commondatastorage.googleapis.com/git-repo-downloads/repo ...

  5. 下载Android kernel

    方法一: https://source.android.com/setup/building-kernels 方法二: 在按照https://source.android.com/setup/down ...

  6. How to: Compile Linux kernel 2.6

      Compiling custom kernel has its own advantages and disadvantages. However, new Linux user / admin ...

  7. Android Kernel save defalut config

    /********************************************************************************* * Android Kernel ...

  8. Compile Linux Kernel on Ubuntu 12.04 LTS (Detailed)

    This tutorial will outline the process to compile your own kernel for Ubuntu. It will demonstrate bo ...

  9. How to compile Linux kernel in fedora 6

    前提:已裝好Fedora 6 core 2.6.18 ,在 Fedora 6 中compile linux kernel.1.下載 Fedora 6 core 2.6.18 http://www.ke ...

随机推荐

  1. linux-网络管理-6

    Hub 集线器 物理层设备 多端口中继器,不记忆MAC地址 以太网桥 OSI第二层数据链路层 扩展了网络带宽 分割了网络冲突域,使网络冲突被限制在最小的范围内 交换机作为更加智能的交换设备,能够提供更 ...

  2. Codeforces Round #287 (Div. 2) E. Breaking Good 路径记录!!!+最短路+堆优化

    E. Breaking Good time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  3. windows Apache ab安装及压力测试

    一:安装 ab是Apache自带的网站压力测试工具.使用起来非常的简单和方便.不仅仅是可以Apache服务器进行网站访问压力测试,还可以对其他类型的服务器进行压力测试.比如nginx,tomcat,I ...

  4. Codechef SEAARC Sereja and Arcs (分块、组合计数)

    我现在真的什么都不会了呢...... 题目链接: https://www.codechef.com/problems/SEAARC 好吧,这题其实考察的是枚举的功力-- 题目要求的是\(ABAB\)的 ...

  5. 聊聊 Vue 的双向数据绑定,Model 如何改变 View,View 又是如何改变 Model 的

    todo defineProperty() 参考: https://www.cnblogs.com/wangjiachen666/p/9883916.html

  6. 在JS中统计函数执行次数

    一.统计函数执行次数 常规的方法可以使用 console.log 输出来肉眼计算有多少个输出 不过在Chrome中内置了一个 console.count 方法,可以统计一个字符串输出的次数.我们可以利 ...

  7. serlvet操作数据库

    工具:eclipse 数据库工具:mysql java ee操作数据库,首先要导入数据库驱动文件,我用的是mysql 刚开始,很多人代码正确但是就是连接不上,原因就是忘了驱动文件的导入. 我的驱动文件 ...

  8. Centos7系统备份与恢复教程

    原文地址:https://www.cnblogs.com/fang888/p/8473485.html Centos系统备份与恢复教程 tar: 特点 1.保留权限 2.适合备份整个目录 3.可以选择 ...

  9. ffmpeg摄像头推流

    ffmpeg -f dshow -i video="Integrated Camera" -vcodec libx264 -preset:v ultrafast -tune:v z ...

  10. leetcode-mid-sorting and searching - 33. Search in Rotated Sorted Array

    mycode class Solution(object): def search(self, nums, target): """ :type nums: List[i ...