1 Android-SDKinclude:

sdk/avd manager,emulator,adb,fastboot...etc.

在下

platform-tools/├── adb├── api├── dmtracedump├── etc1tool├── fastboot├── hprof-conv├── NOTICE.txt├── source.properties├── sqlite3└── systrace2 directories, 8 files
 
tools/├── android├── ant├── apps├── ddms├── draw9patch├── emulator├── emulator64-arm...(others)因此这两个目录加到系统的¥PATH中去

命令主要有

#Display manager windowandroid avdandroid sdk#run emulator using our own img, and show kernel msgemulator -avd  -system ./img/system.img  -data ./img/userdata.img -ramdisk ./img/ramdisk.img -kernel /home/nmt/buildingandroid/android-kernel/goldfish-3.x/goldfish/arch/arm/boot/zImage -partition-size 128 -show-kernel#adb tool & fastboot....adb shelladb pushadb pull

2 Toolchain:交叉编译工具

我涉及到了2种交叉编译工具 arm-eabi-4.4.3 (编译kernel) 和arm-none-linux-gnueabi-gcc-4.3.3(编译用户态程序)

原则上可以就使用一个,要看实际程序是否需要指定某版本的交叉编译工具。

安装过程总结起来就是-下载-解压-放到任意的地方-加入这个地方的路径到PATH,(根据需要添加几个软连接),然后测试一下是否成功

参考:

点击打开链接

点击打开链接

3 Kbuild System 基础知识

单独编译模块 or 编译进内核img

参考官方文档:

(待续)

有事没事可以多浏览:

http://lwn.net/Kernel/Index/#Development_model-Loadable_modules

[Android 开发3] android kernel 编译&加入模块&基础知识&总结_第1张图片


4 git & repo

git clone https://android.googlesource.com/kernel/common.gitgit clone https://android.googlesource.com/kernel/goldfish.gitgit clone https://android.googlesource.com/kernel/msm.gitgit clone https://android.googlesource.com/kernel/omap.gitgit clone https://android.googlesource.com/kernel/samsung.gitgit clone https://android.googlesource.com/kernel/tegra.git/*git 使用...tag什么的*/


5 编译android kernel

(1)应当知道自己正要编译的内核是哪个版本的:

/*除了git branch查看分支,还可以通过下面的命令*/make kernelversion 3.4.67

我要编译的是3.4.67的kernel


(2)应当知道kernel版本号的意义:

x.y.z-b-xxx

例如:

uname -a3.13.0-44-generic #73-Ubuntu SMP Tue Dec 16 00:22:43 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
表示大版本 - 3

小版本13

基于3.13.0没有加补丁(上面的是有打67号补丁)

后面的-b表示第几次build(build number)不同的build number可能会相差了一些驱动/模块等

最后的generic表示一个名字吧,generic表示工具生成的。假如自己编译一个linux kernel会发现这个名字就变了。

etc.

PS:我也不是很懂,把自己理解的写上来,有错误欢迎指正:)

参考:Chapter 14 The Linux Kernel Sources

"

Where to Get The Linux Kernel Sources

All of the major Linux distributions ( Craftworks, Debian, Slackware, Red Hat etcetera) include the kernel sources in them.Usually the Linux kernel that got installed on your Linux systemwas built from those sources.By their very nature these sources tend to be a little out of date soyou may want to get the latest sources from one of the web sitesmentioned in chapter  www-appendix.They are kept on ftp://ftp.cs.helsinki.fiand all of the other web sites shadow them.This makes the Helsinki web site the most up to date, but sites likeMIT and Sunsite are never very far behind.

If you do not have access to the web, there are many CD ROM vendors whooffer snapshots of the world's major web sites at a very reasonablecost. Some even offer a subscription service with quarterly or evenmonthly updates. Your local Linux User Group is also a good source of sources.

The Linux kernel sources have a very simple numbering system. Any even number kernel (for example2.0.30) is a stable, released,kernel and any odd numbered kernel (for example2.1.42 is a development kernel.This book is based on the stable2.0.30 source tree.Development kernels have all of the latest features and supportall of the latest devices. Although they can be unstable, which may not be exactly what you want it,is important that the Linux community tries the latest kernels.That way they are tested for the whole community.Remember that it isalways worth backing up your system thoroughly if you do try out non-production kernels.

Changes to the kernel sources are distributed as patch files. The patchutility is used to apply a series of edits to a set of source files. So, for example, if you have the 2.0.29 kernel source tree and you wanted to moveto the 2.0.30 source tree, you would obtain the 2.0.30 patch file and apply thepatches (edits) to that source tree:

$ cd /usr/src/linux$ patch -p1 < patch-2.0.30

This saves copying whole source trees, perhaps over slow serial connections.A good source of kernel patches (official and unofficial) is thehttp://www.linuxhq.com web site.

"

(3)  编译需要一个.config文件

可以通过

#自己配置选项make menuconfig#使用某些默认配置make goldfish_armv7_defconfigmake goldfish_defconfig#(我第一次编译时,上面2个配置都无法在android5.0的模拟器上成功)"make oldconfig :类似于make config,只是要求用户参与的配置项更少,大多配置会给出默认值。" #甚至可以从模拟器里拖一个.config出来adb  pull  /proc/config.gzgunzip  config.gz#有了 .config 就可以编译了make -j4

可以参考

"知耻而后勇的蜗牛"

"vipclx"


(4) so 应当知道哪个android版本使用哪个版本的内核。

...

(5) 内核中加入自己的模块


(6) 编译Android src(完整源码)


(7) 编译一些external 工具如 blktrace (用手指想一下,应该至少有2种方法:

    1. 直接编译进Android5.0系统img --> 第一次没成功编译

    2.在外部单独编译出来 --> 使用NDK工具可编译

 

更多相关文章

  1. (4.2.15.1)【android开源工具】安卓图表引擎AChartEngine(三) - 示
  2. 解决安卓9.0版本不能访问http请求问题
  3. Android下内核配置make menuconfig出现一大堆未定义的错误
  4. Android前端通过Http协议与J2EE后端数据交互。工具eclipse、MySQ
  5. apktool高版本产生compileSdkVersion等错误
  6. Android最新的各个分支版本号(2013-10-27)

随机推荐

  1. ProgressBar播放动画
  2. Android(Java):focus
  3. Android 多媒体
  4. android打电话,接电话,挂电话过程
  5. 关于"match_parent"这个xml的布局设定值
  6. Android JNI介绍
  7. 2011.11.22——— android jni简单用法
  8. android - Content-Type大全
  9. php android json
  10. Android zip解压