2. ubuntu下载编译linux kernel

一. 引言

诚如老罗所言,android源代码里面并没有带linux kernel代码。它使用的是预先编译好的kernel,大家可以使用adb shell cat proc/version就可以查看到,如下:

android@ubuntu:~/working_directory$ adb shell cat proc/version

Linux version 2.6.29-00261-g0097074-dirty ([email protected]) (gcc version 4.4.0 (GCC) ) #20 Wed Mar 31 09:54:02 PDT 2010

android@ubuntu:~/working_directory$ 


从kernel版本可以看到现在使用的还是google在2010编译的kernel,那怎么下载/编译/运行自己的kernel呢?


二. 下载kernel

下载方法请参考老罗的博客

http://blog.csdn.net/luoshengyang/article/details/6564592

不过有个地方要注意,跟第1篇帖子类似,由于地址被墙,不能下载成功(至少我没有成功...)

所以得去清华大学的镜像站下载


下载地址https://aosp.tuna.tsinghua.edu.cn/kernel/goldfish.git

1. 新建kernel目录

mkdir kernel 

cd kernel


2. git clone https://aosp.tuna.tsinghua.edu.cn/kernel/goldfish.git


clone完成后进入goldfish目录

3. cd goldfish


4. git branch -a 查看远程分支

android@ubuntu:~/working_directory/kernel/goldfish$ git branch -a

* master

  remotes/origin/HEAD -> origin/master

  remotes/origin/android-3.10

  remotes/origin/android-3.18

  remotes/origin/android-3.4

  remotes/origin/android-goldfish-2.6.29

  remotes/origin/android-goldfish-3.10

  remotes/origin/android-goldfish-3.10-l-mr1-dev

  remotes/origin/android-goldfish-3.10-m-dev

  remotes/origin/android-goldfish-3.18-dev

  remotes/origin/android-goldfish-3.4

  remotes/origin/android-goldfish-3.4-l-mr1-dev

  remotes/origin/linux-goldfish-3.0-wip

  remotes/origin/master

android@ubuntu:~/kerle_test/goldfish$ 


5. 切换到android-goldfish-2.6.29分支,因为这个分支和2.3版本是最相近的。

git checkout -b android-goldfish-2.6.29 origin/android-goldfish-2.6.29  


6. 查看本地分支和远程分支对应情况

git branch -avv


* android-goldfish-2.6.29                        4bb8fa0 [origin/android-goldfish-2.6.29] goldfish: Add encrypted SD Card support.

  master                                         1b8b73f [origin/master] empty commit

  remotes/origin/HEAD                            -> origin/master

  remotes/origin/android-3.10                    1d0f729 android: base-cfg: Add CONFIG_IP_MULTICAST

  remotes/origin/android-3.18                    2771f08 android: base-cfg: Add CONFIG_IP_MULTICAST

  remotes/origin/android-3.4                     4e97def selinux: nlmsgtab: add SOCK_DESTROY to the netlink mapping tables

  remotes/origin/android-goldfish-2.6.29         4bb8fa0 goldfish: Add encrypted SD Card support.

  remotes/origin/android-goldfish-3.10           1db7499 Merge branch 'android-3.10' into android-goldfish-3.10

  remotes/origin/android-goldfish-3.10-l-mr1-dev 70edbbb ranchu: 32 bit framebuffer support

  remotes/origin/android-goldfish-3.10-m-dev     8839123 mm/pagewalk.c: fix walk_page_range() access of wrong PTEs

  remotes/origin/android-goldfish-3.18-dev       dfc5f3c arm: goldfish: Update goldfish defconfigs

  remotes/origin/android-goldfish-3.4            2011b1c Merge branch 'android-3.4' into android-goldfish-3.4

  remotes/origin/android-goldfish-3.4-l-mr1-dev  2d58ef9 x86: goldfish: Enable required Netfilter features

  remotes/origin/linux-goldfish-3.0-wip          c423bb8 x86: Add x86 support to the golfish framebuffer driver.

  remotes/origin/master                          1b8b73f empty commit



可以看到我们本地所处的android-goldfish-2.6.29分支和远程分支“4bb8fa0 [origin/android-goldfish-2.6.29] goldfish: Add encrypted SD Card support.”是对应的。


至此,kernel代码就下载完成了。


另外,我发现默认下载的kernel文件夹是goldfish,不知道为啥老罗的是common,也许他的git命令指定了文件夹吧。


三. 编译kernel

编译kernel的话请参考老罗的方法,配置交叉编译环境,使用make命令编译

http://blog.csdn.net/luoshengyang/article/details/6564592


ps:

make menuconfig是启动配置菜单,可以配置编译选项。


四. 运行自己的kernel

emulator -kernel ./kernel/common/arch/arm/boot/zImage


老罗的命令是emulator -kernel ./kernel/common/arch/arm/boot/zImage &


但是发现没有这个&也是可以运行的





你可能感兴趣的:(android)