Android Linux内核编译

平台:

Wind7_64 + Ubuntu12_04_64 + VMware

这里以Android5.0为例:

Android5.0 可以到这里下载:
115网盘礼包码:5lbd7crtk1wz
http://115.com/lb/5lbd7crtk1wz

Linux_source_goldfish 可以到这里下载:
115网盘礼包码:5lbd76rru5or
http://115.com/lb/5lbd76rru5or

Android5.0的编译可以参考:

遇到的问题

http://www.cnblogs.com/pengdonglin137/p/4197969.html

需要使用openjdk7

apt-get install openjdk-7-jdk
apt-get install openjdk-7-jre

编译:

技术分享
root@ubuntu:~/work/android/android5/android-5.0# . build/envsetup.sh 
including device/moto/shamu/vendorsetup.sh
including device/samsung/manta/vendorsetup.sh
including device/generic/mini-emulator-x86/vendorsetup.sh
including device/generic/mini-emulator-arm64/vendorsetup.sh
including device/generic/mini-emulator-mips/vendorsetup.sh
including device/generic/mini-emulator-x86_64/vendorsetup.sh
including device/generic/mini-emulator-armv7-a-neon/vendorsetup.sh
including device/lge/mako/vendorsetup.sh
including device/lge/hammerhead/vendorsetup.sh
including device/asus/tilapia/vendorsetup.sh
including device/asus/deb/vendorsetup.sh
including device/asus/grouper/vendorsetup.sh
including device/asus/flo/vendorsetup.sh
including device/asus/fugu/vendorsetup.sh
including sdk/bash_completion/adb.bash
root@ubuntu:~/work/android/android5/android-5.0# choosecombo 
Build type choices are:
     1. release
     2. debug

Which would you like? [1] 1


Which product would you like? [full] 


Variant choices are:
     1. user
     2. userdebug
     3. eng
Which would you like? [eng] 

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=5.0
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86_64
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.5.0-23-generic-x86_64-with-Ubuntu-12.04-precise
HOST_BUILD_TYPE=release
BUILD_ID=LRX21M
OUT_DIR=out
============================================

root@ubuntu:~/work/android/android5/android-5.0# make 
技术分享

编译完成后,设置工具链路径,为编译内核方便:

export PATH=$PATH:/root/work/android/android-5.0/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/bin

编译内核:

下载内核后,解压

技术分享
root@ubuntu:~/work/android/android5/goldfish# git branch -a
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/android-3.10
  remotes/origin/android-3.4
  remotes/origin/android-goldfish-2.6.29
  remotes/origin/android-goldfish-3.10
  remotes/origin/android-goldfish-3.4
  remotes/origin/linux-goldfish-3.0-wip
  remotes/origin/master
技术分享

由于Android5.0的模拟器使用的内核是3.4(可以用模拟器自带的内核启动一个模拟器,然后看一下内核版本 cat /proc/version ), 所以我们也是用3.4:

root@ubuntu:~/work/android/android5/goldfish# git checkout remotes/origin/android-goldfish-3.4 -b linux-3.4


然后修改Makefile

ARCH        ?= arm
CROSS_COMPILE    ?= arm-eabi-

配置内核

root@ubuntu:~/work/android/android5/goldfish# make goldfish_armv7_defconfig

注意:这个默认的内核并没有配置模块加载功能,需要执行make menuconfig设置,否则无法编译和加载内核模块

编译内核

make zImage -j2

用我们编出的内核启动模拟器:

root@ubuntu:~/work/android/android5/android-5.0# emulator64-arm -kernel ../goldfish/arch/arm/boot/zImage

其他精彩文章文章

android学习笔记(41)android选项菜单和子菜单(SubMenu )

android学习笔记(40)Notification的功能与用法

android学习笔记(42)android使用监听器来监听菜单事件

android学习笔记(43)android创建单选菜单和复选菜单

 jQuery教程(12)-ajax操作之基于请求加载数据

 jQuery教程(13)-ajax操作之追加 HTML

更多关于android开发文章

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。