一.code download
$ sudo apt-get install uuid uuid-dev
$ sudo apt-get install zlib1g-dev liblz-dev
$ sudo apt-get install liblzo2-2 liblzo2-dev
$ sudo add-apt-repository ppa:git-core/ppa
$ sudo apt-get install lzop
$ sudo apt-get update
$ sudo apt-get install git-core curl
$ sudo apt-get install u-boot-tools
$sudo apt-get install flex bison gperf libesd0-dev libwxgtk2.8-dev zlib1g-dev build-essential libx11-dev
libncurses5-dev genext2fs u-boot-tools
$sudo apt-get install git git-core
$sudo apt-get install libswitch-perl
sudo apt-get install libxml2-utils
sudo apt-get install gcc-multilib
sudo apt-get install g++
sudo apt-get install xsltproc
# cd /opt (or any other directory where you placed the android_KK4.4.3_2.0.0-
ga_core_source.tar.gz file)
$ tar xzvf android_KK4.4.3_2.0.0-ga_core_source.tar.gz
$ cd android_KK4.4.3_2.0.0-ga_core_source/code/
$ tar xzvf KK4.4.3_2.0.0-ga.tar.gz
mkdir ~/bin
PATH=~/bin/repo:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo/repo
mkdir myandroid
cd myandroid
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest
## 如果提示无法连接到 gerrit.googlesource.com,可以编辑 ~/bin/repo,把 REPO_URL 一行替换成下面的:
## REPO_URL = 'https://gerrit-googlesource.proxy.ustclug.org/git-repo'
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-4.4.3_r1
运行脚本:
#!/bin/sh
repo sync -f -j4
while [ $? -ne 0 ]
do
repo sync -f -j4
done
uboot下载:
$ cd myandroid/bootable/bootloader
$ git clone git://git.freescale.com/imx/uboot-imx.git uboot-imx -b kk4.4.3_2.0.0-ga
$ cd uboot-imx
$ git checkout kk4.4.3_2.0.0-ga
kernel下载:
$ cd myandroid
$ git clone git://git.freescale.com/imx/linux-2.6-imx.git kernel_imx -b kk4.4.3_2.0.0-ga
$ cd kernel_imx
$ git checkout kk4.4.3_2.0.0-ga
二.Patch code for i.MX
1. Assume you have unzipped the i.MX Android release package to /opt/android_KK4.4.3_2.0.0-ga_source .
$ cd ~/myandroid
$ source /opt/android_KK4.4.3_2.0.0-ga_core_source/code/KK4.4.3_2.0.0-ga/and_patch.sh
$ help
2. You should see that the "c_patch" function is available.
$ c_patch /opt/android_KK4.4.3_2.0.0-ga_core_source/code/KK4.4.3_2.0.0-ga imx_KK4.4.3_2.0.0-ga
Here, "/opt/android_KK4.4.3_2.0.0-ga_source/code/KK4.4.3_2.0.0-ga" is the location of the patches, which is the
directory created when you unzip the release package.
"imx_KK4.4.3_2.0.0-ga" is the branch which will be created automatically for you to hold all patches (only in those
existing Google gits).
3. If everything is OK, "c_patch" will generate the following output to indicate the successful patch:
**************************************************************
Success: Now you can build the Android code for FSL i.MX platform
**************************************************************
三.编译环境
下载JDK1.6,链接http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html
脚本如下:
#!/bin/sh
export JAVA_HOME=/opt/jdk1.6.0_45
export JAVA_BIN=/opt/jdk1.6.0_45/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH
source build/envsetup.sh
lunch sabresd_6dq-user
楼主在64位上安装32,把那两个x86的都装了一遍,都错了,哈哈,最后下载文件:jdk-6u45-linux-x64.bin
#uname -a
很明显楼主是:64位操作系统;那么应该下载jdk-6u45-linux-x64.bin
Linux x86:32位操作系统;
Linux x64:64位操作系统;
四.编译出现的疑难杂症
Android源码:科大镜像下载
Android编译版本: PLATFORM_VERSION=4.4.3
OS 操作系统平台:Linux wugn-Inspiron-3542 3.13.0-144-generic #193-Ubuntu SMP Thu Mar 15 17:03:53 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux(Ubuntu14.04 64bit)
1. 要用jdk1.6,不能用jdk1.7
2. /bin/bash: bison: command not found
方法:sudo apt-get install bison
3. /bin/bash: xsltproc: command not found
方法:sudo apt-get install xsltproc
4./bin/bash: flex: command not found
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Error 127
方法:sudo apt-get install flex
5. sh: gperf: not found
calling gperf failed: 32512 at ./makeprop.pl line 140.
方法:sudo apt-get install gperf
6. gcc: error trying to exec 'cc1plus': execvp: No such file or directory
方法:sudo apt-get install g++
7.collect2: error: ld terminated with signal 9
方法:增加ubuntu的虚拟内存。具体操作如下:
setp1:查看系统虚拟内存,命令:free -m
- carson@carson-pc:~$ free -m
- total used free shared buffers cached
- Mem: 1998 1528 469 0 6 423
- -/+ buffers/cache: 1098 900
- Swap: 2036 361 1675
我这是已经增加swap的,一般swap2G左右就足够编译android用的。在编译过程中,虽然增加了2G,但在编译时,若做一些操作比较占用swap的话,也会出现此问题。比如从移动硬盘copy android 源码。
setp2.创建一个 Swap 文件。
mkdir swap
cd swap
sudo dd if=/dev/zero of=swapfile bs=1024 count=100000
出现下列提示,上面命令中的 count 即代表swap文件大小,即增加的虚拟内存大小。此命令出现如下信息
- 100000+0 records in
- 100000+0 records out
- 102400000 bytes (102 MB) copied, 0.377325 s, 271 MB/s
setp3:把生成的文件转换成 Swap 文件
sudo mkswap swapfile
此命令出现如下信息:
- Setting up swapspace version 1, size = 99996 KiB
- no label, UUID=b26fe88c-11c2-40ad-8139-6e69e96b6b68
setp4:激活 Swap 文件。
sudo swapon swapfile
此时free -m 查看Swap信息
- total used free shared buffers cached
- 1998 <span style="font-family:Arial, Helvetica, sans-serif;"> 1189 809 0 34 624span>
- -/+ buffers/cache: 530 1468
- Swap: 2134 986 1148
至此,swap已经增加成功了,如果想卸载刚增加的swap;
sudo swapoff swapfile
如果需要一直保持这个 swap ,可以sudo -s换到root
然后把它写入 /etc/fstab 文件。
swapfilepath swap swap defaults 0 0
8. In file included from /usr/include/semaphore.h:22:0,
from cts/suite/audio_quality/lib/include/Semaphore.h:21,
from cts/suite/audio_quality/lib/src/Semaphore.cpp:17:
/usr/include/features.h:323:26: fatal error: bits/predefs.h: No such file or directory
compilation terminated.
make: In file included from /usr/include/stdlib.h:25:0,
from cts/suite/audio_quality/lib/src/Adb.cpp:16:
/usr/include/features.h:323:26: fatal error: bits/predefs.h: No such file or directory
compilation terminated.
方法:sudo apt-get install libc6-dev:i386
sudo apt-get install build-essential
sudo apt-get install gcc-multilib
9./bin/sh: gcc: not found
方法:sudo apt-get install gcc,gcc是C的编译器
10.gccgcc: error trying to exec 'cc1plus': execvp: gcc: error trying to exec 'No such file or directory
方法:sudo apt-get install g++,g++是C++的编译器
11. /bin/bash: xmllint: command not found
方法:sudo apt-get install libxml2-utils
12.make[1]: lzma: Command not found
方法:sudo apt-get install lzma
未完待续