Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android Linux內核編譯

Android Linux內核編譯

編輯:關於Android編程

平台:

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的編譯可以參考:

遇到的問題

 

需要使用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

 


 

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved