Freescale I.mx 6 Android 4.2.2源码编译环境搭建(基于ubuntu12.04 LTS)

时间:2022-01-04 09:28:39
Freescale I.mx 6  Android 4.2.2源码编译环境搭建    1  安装必要的第三方工具:
$ sudo apt-get install git gnupg flex bison gperf build-essential \
zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \
x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \
libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \
libxml2-utils xsltproc

安装过程中可能出现以下问题:
Note, selecting 'lib32z1-dev' instead of 'lib32z-dev'

Package lib32readline5-dev is not available, but is referred to by another package.

This may mean that the package is missing, has been obsoleted, or

is only available from another source

However the following packages replace it:

lib32readline-gplv2-dev



E: Package 'lib32readline5-dev' has no installation candidate

这个按照提示安装lib32readline-gplv2-dev即可
 
 2  安装JDK1.6
   这个需要到oracle下载文件”jdk-6u45-linux-x64.bin”,将下载文件至于ubuntu下某一目录下,执行如下命令:
 
$chmod +x jdk-6u45-linux-x64.bin
$./jdk-6u45-linux-x64.bin

修改/etc/profile文件:
$ sudo gedit /etc/profile

在末尾加上:
export JAVA_HOME=/home/***/jdk1.6.0_45
export JRE_HOME=/home/***/jdk1.6.0_45/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$JAVA_HOME:$PATH
注:***为你安装jdk的路径名字

可以运行如下指令看jdk是否安装ok:
$ java -version
$ javac -version
如能正确显示jdk版本即安装正确。

3 获取Android源码 以及patch
  3.1 获取Android各部分源码
    Android源码可以从google获取,也可以从其他人那里拷贝,我这里的源码是从网盘下载Android4.2.2源码,大概10G左右。网盘下载地址(在此感谢这位兄弟的分享)。
   
   Kernel部分的源码可以从freescale官网下载到,具体方法:
   进入到上面下载的android源码根目录下,运行:
$ git clone git://git.freescale.com/imx/linux-2.6-imx.git kernel_imx
下载完成后执行:
$ cd kernel_imx

$ git checkout jb4.2.2_1.0.0-ga

同理,u-boot部分源码也可以从freescale官网下载到,在android源码/bootable/bootloader目录下执行:
$ git clone git://git.freescale.com/imx/uboot-imx.git uboot-imx
下载完成后:
$ cd uboot-imx

$ git checkout jb4.2.2_1.0.0-ga

  3.2 Patch Code for i.MX
    从网上获取android_jb4.2.2_1.0.0-ga_source.tar.gz这个packages,执行如下命令:
 
    $ cd /opt (or any other directory where you placed the android_jb4.2.2_1.0.0-ga_source.tar.gzfile)  
$ tar xzvf android_jb4.2.2_1.0.0-ga_source.tar.gz
$ cd android_jb4.2.2_1.0.0-ga_source/code
$ tar xzvf jb4.2.2_1.0.0-ga.tar.gz

在android源码目录下运行:
 
    $ cd ~/myandroid  

$ source /opt/android_jb4.2.2_1.0.0-ga_source/code/jb4.2.2_1.0.0-ga/and_patch.sh

$ help
#Now you should see that the "c_patch" function is available

$ c_patch /opt/android_jb4.2.2_1.0.0-ga_source/code/jb4.2.2_1.0.0-ga imx_jb4.2.2_1.0.0-ga
#Here "/opt/android_jb4.2.2_1.0.0-ga_source/code/jb4.2.2_1.0.0-ga" is the location of thepatches (i.e. directory created when you unzip release package)
#"imx_jb4.2.2_1.0.0-ga" is the branch which will be created automatically for you to hold allpatches (only in those existing Google gits).
#You can choose any branch name you like instead of "imx_jb4.2.2_1.0.0-ga".
如果没有问题的话,你可以看见如下输出信息:

**************************************************************
Success: Now you can build the Android code for FSL i.MX platform
**************************************************************

4 编译
   4.1 编译U-boot:
进入android源码下 bootable/bootloader/uboot-imx 目录,新建编译脚本build_u.sh 并添加可执行权限:
#!/bin/sh
export ARCH=arm
export CROSS_COMPILE=~myandroid/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
make distclean

make mx6q_sabresd_android_config

make

执行编译脚本,编译成功后会在uboot-imx目录下生成相应的文件。
  
    4.2 编译kernel:
进入android源码下kernel-imx目录,新建编译脚本build_k.sh 并添加可执行权限:
#!/bin/sh
export ARCH=arm
export CROSS_COMPILE=~myandroid/android/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
export PATH=~myandroid/bootable/bootloader/uboot-imx/tools/:$PATH
make distclean

make imx6_android_defconfig

make uImage

执行编译脚本,编译成功会生成/arch/arm/boot/uImage。

 4.3 编译bootimage
 进入android源码根目录下,新建编译脚本build_bi.sh并添加可执行权限:
#!/bin/sh
export PATH=~myandroid/bootable/bootloader/uboot-imx/tools/:$PATH

source build/envsetup.sh

lunch sabresd_6dq-user

make bootimage

4.4 编译android
 进入android源码根目录下,新建编译脚本build_a.sh并添加可执行权限:
#!/bin/sh
export PATH=~myandroid/bootable/bootloader/uboot-imx/tools/:$PATH

source build/envsetup.sh

lunch sabresd_6dq-user

make

如果上述四步都编译无误,那么我们的android镜像基本都生成了。