您的位置:首页 > 移动开发 > Android开发

Compile android source and kernel for emulator in Debian

2013-06-23 14:23 701 查看
  1、download the android source code

  Reference from

http://source.android.com/source/downloading.html


  follow the reference:

  Create the dir and export the PATH

$ mkdir ~/bin
$ PATH=~/bin:$PATH


  Download the repo

$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod 775 ~/bin/repo


  Repo init the code version you want

$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1


  finally sync the codes

$ repo sync
// better way
$ repo sync -j16


  if try to stop the repo, just try

Ctrl + z


  and continue the repo

$ repo sync
// or
$ repo sync -j16


  after download, must enter "repo sync" to check the code again.

  2、download the kernel

  Reference from

https://android.googlesource.com/


  click the kernel/common, there would be a instruction on the top:

git clone https://android.googlesource.com/kernel/common[/code] 
  the version for emulator

git clone https://android.googlesource.com/kernel/goldfish[/code] 
  3、Compile the source code

  1) check the build environment

http://source.android.com/source/initializing.html


  2) compile

$ cd ~/Android/source_code/
$ make
// or
$ make -j4


  3) there would be the files in the following dir

$ ls out/host/linux-x86/bin/ | grep emulator
emulator
emulator64-arm
emulator64-mips
emulator64-x86
emulator-arm
emulator-mips
emulator_renderer
emulator-ui
emulator-x86
$ ls out/target/product/generic/ | grep img
ramdisk.img
system.img
userdata.img


  4、 Compile the kernel

$ cd goldfish/
$ ls


  but there is no files now.

  checkout for the real codes.

$ git checkout
android-goldfish-2.6.29          master                           origin/linux-goldfish-3.0-wip
android-goldfish-3.4             origin/android-goldfish-2.6.29   origin/master
HEAD                             origin/android-goldfish-3.4
linux-goldfish-3.0-wip           origin/HEAD


  choose the version you want

$ git checkout android-goldfish-2.6.29
Checking out files: 100% (26821/26821), done.
Branch android-goldfish-2.6.29 set up to track remote branch android-goldfish-2.6.29 from origin.
切换到一个新分支 'android-goldfish-2.6.29'


  then

$ ls
arch     CREDITS        drivers   include  Kbuild  MAINTAINERS  net             samples   sound
block    crypto         firmware  init     kernel  Makefile     README          scripts   usr
COPYING  Documentation  fs        ipc      lib     mm           REPORTING-BUGS  security  virt


  compile the kernel

  1) crrect the Mafile

$ vim Makefile
//correct the following messenge
#ARCH           ?= $(SUBARCH)
ARCH            ?= arm
CROSS_COMPILE   ?= arm-none-linux-gnueabi-


  2) make menuconfig

$ make menuconfig
>> Save an Alternate Configuration File


  3) make

  TIPS : there would be error without libnucurses

$ sudo apt-get install libncurses5 libncurses5-dev
// in AMD64
$ sudo apt-get install libncurses5 libncurses5-dev
$ sudo apt-get install ia32-libs
$ sudo apt-get install lib32ncurses5 lib32ncurses5-dev


  

  

  

  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐