zoukankan      html  css  js  c++  java
  • Ubuntu 14.04 编译 Android 4.2.2 for Tiny4412

    .

    .

    .

    .

    .

    在学校里是用 Redhat 6.4 编译的 Android 4.2.2 很顺利,把源码包拷贝到笔记本上的 Ubuntu 14.04 上再编译遭遇了各种坑,所以便有了这篇博客记录解决每一个坑的过程。所幸这些坑解决起来还不算复杂,稍微 Google 一下就找到了解决方案。

    1.首先是安装 JDK 和 arm-linux-gcc 工具链,这两步只是解压缩之后配置环境变量就行了,所以这里就不再赘述了。
     注意 JDK 必须采用 1.6 版本的,据说 android 4.x 都需要使用标准的 JDK 1.6 编译,也就是说 OpenJDK 是不行的,必须用 Sun 的 JDK,这一点我没有亲测过。

    2.安装 gperf,我这里用的是 3.0.4,采用源码编译安装。

    [yuhuashi@local android]$ tar xvzf gperf-3.0.4.tar.gz
    [yuhuashi@local android]$ cd gperf-3.0.4/
    [yuhuashi@local gperf-3.0.4]$ ./configure
    [yuhuashi@local gperf-3.0.4]$ make -j4
    [yuhuashi@local gperf-3.0.4]$ make install
    [yuhuashi@local android]$ man gperf

    OK,如果没有报错的话,那么恭喜你第二步成功了。

    3.接下来便进入正题了,开始编译 android 源码,版本是 4.4.2。

    因为是在 Tiny4412 开发板上运行,所以代码包可能被修改过,具体有没有被修改过我也不知道,因为还没有研究过 android 移植,暂时先把步骤记录下来。

    [yuhuashi@local android]$ tar xvf android-4.2.2_r1-fs-20140526.tar.gz
    [yuhuashi@local android]$ cd android-4.2.2_r1/

    设置环境变量

    [yuhuashi@local android-4.2.2_r1]$ source setenv

    选择编译适用的平台

    [yuhuashi@local android-4.2.2_r1]$ lunch

    发现出现了一串"无法找到 bison 命令"的错误提示,于是安装 bison

    [yuhuashi@local android-4.2.2_r1]$ sudo apt-get install bison

    注意 千万不要手贱把 bison++ 也装上了,否则编译的时候会出现一个 double free 的错误!

    接下来要开始编译了:    ====前方高能预警,请无关人员立即撤离,关闭所有非必要运行的程序,并确保散热器正常工作!!!====

    [yuhuashi@local android-4.2.2_r1]$ make -j4

    过程中出现了 Switch.pm 的错误,具体的错误信息没有记录下来,如果各位也遇到了同样的错误,make 会自动停止,所以只写一下解决的方法吧。

    其实只需要安装一下 perl 的 switch 库即可:

    sudo apt-get install libswitch-perl

    安装好 switch 库后重新 make -j4 继续编译。

    过了一会儿出现了一个这样的错误:

    byteswap.h:22:3: error: #error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead.

    解决办法是安装 GCC 的 multilib 库,然后 make -j4 继续编译。

    sudo apt-get install gcc-multilib

    OK,所有的坑都解决了,经过将近2个小时的高速运转之后终于见到了如下提示:

    Creating filesystem with parameters:
    Size: 685768704
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 6976
    Inode size: 256
    Journal blocks: 2616
    Label:
    Blocks: 167424
    Block groups: 6
    Reserved block group size: 47
    Created filesystem with 1104/41856 inodes and 52043/167424 blocks
    + '[' 0 -ne 0 ']'
    Running: simg2img out/target/product/tiny4412/obj/PACKAGING/systemimage_intermediates/system.img out/target/product/tiny4412/obj/PACKAGING/systemimage_intermediates/unsparse_system.img
    Running: e2fsck -f -n out/target/product/tiny4412/obj/PACKAGING/systemimage_intermediates/unsparse_system.img
    e2fsck 1.41.14 (22-Dec-2010)

    Pass 1: Checking inodes, blocks, and sizes
    Pass 2: Checking directory structure
    Pass 3: Checking directory connectivity
    Pass 4: Checking reference counts
    Pass 5: Checking group summary information
    out/target/product/tiny4412/obj/PACKAGING/systemimage_intermediates/unsparse_system.img: 1104/41856 files (0.0% non-contiguous), 52043/167424 blocks
    Install system fs image: out/target/product/tiny4412/system.img
    out/target/product/tiny4412/system.img+ maxsize=700123776 blocksize=4224 total=203674048 reserve=7075200

    如果你也看到了类似的提示消息,恭喜你成功了!

    编译的结果在out文件夹下。

    4.接下来生成刷机需要的 img 镜像文件

    不过这需要依赖 UBoot 的一个工具:mkimage,如果你之前编译过 UBoot,可以在 UBoot 的 tools 目录下找到这个程序,也可以通过 apt-get 来安装它:

    [yuhuashi@local android-4.2.2_r1]$ sudo apt-get install u-boot-tools

    有了这个工具我们便可以制作 img 镜像文件了

    [yuhuashi@local android-4.2.2_r1]$ ./gen-img.sh

    OK,看看是不是在当前目录下出现了下面这几个文件:

    [yuhuashi@local android-4.2.2_r1]$ ls
    system.img
    userdata-16g.img
    userdata-4g.img
    userdata-8g.img
    userdata.img
    ramdisk-u.img
    ......
    隐藏了若干不相关文件

    如果出现了这几个文件,那么说明刷机必要的镜像文件我们已经有了,恭喜你,还差一个内核就可以在开发板上烧写系统了。

    现在只是编译了 android 本身,内核还没有编译,明天继续记录编译内核的过程。

  • 相关阅读:
    MySQL锁系列3 MDL锁
    MySQL锁系列2 表锁
    MySQL锁系列1
    MySQL open table
    MySQL优化器join顺序
    MySQL优化器cost计算
    MySQL源码 优化器
    MySQL源码 解析器
    MySQL源码 数据结构hash
    微信小程序爬坑日记
  • 原文地址:https://www.cnblogs.com/0xcafebabe/p/4278127.html
Copyright © 2011-2022 走看看