天嵌TQ_E9卡片电脑移植飞思卡尔 android_N7.1.1_1.0.0

系统:16.04 64-bit version

以下步骤如果出现网络链接不通的情况请自行使用VPN翻墙再次尝试。

1.建立ubuntu环境

安装必要软件:

$ sudo apt-get update
$ sudo apt-get install openjdk-8-jdk

安装锁雾程序包(Ubuntu 14.04及以上)

$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
  zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \
  lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache \
  libgl1-mesa-dev libxml2-utils xsltproc unzip

安装额外的包:

$ sudo apt-get install uuid uuid-dev
$ sudo apt-get install zlib1g-dev liblz-dev
$ sudo apt-get install liblzo2-2 liblzo2-dev
$ 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 mtd-utils
$ sudo apt-get install android-tools-fsutils

配置git:

git config --global user.name "First Last"
git config --global user.email "first.last@company.com"

解压NXP官方源码包:
$cd /opt/
$ tar xzvf
android_N7.1.1_1.0.0_source.tar.gz

2.建立IMX ANDROID平台

获得安卓源码:

$ cd /opt
$ mkdir myandroid
$ mkdir ~/bin
$ cd myandroid
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
$ ~/bin/repo init -u https://android.googlesource.com/platform/manifest -b android-7.1.1_r13
$ ~/bin/repo sync # 这一步可能需要花费数小时

$ git clone git://git.freescale.com/imx/linux-imx.git kernel_imx#获取kernel
$ cd kernel_imx
$ git checkout n7.1.1_1.0.0-ga#签出kernel版本

$ cd /opt/myandroid/bootable
$ mkdir bootloader
$ cd bootloader
$ git clone git://git.freescale.com/imx/uboot-imx.git uboot-imx
$ cd uboot-imx
$ git checkout  
n7.1.1_1.0.0-ga

#获取uboot
$ cd /opt/myandroid/bootable
$ mkdir bootloader 
$ cd bootloader 
$ git clone git://git.freescale.com/imx/uboot-imx.git uboot-imx
$ cd uboot-imx
$ git checkout
n7.1.1_1.0.0-ga



$ cd   /opt/myandroid
$ source /opt/android_N7.1.1_1.0.0_source/code/N7.1.1_1.0.0/and_patch.sh #
建立环境

$ c_patch  /opt/android_N7.1.1_1.0.0_source/code/N7.1.1_1.0.0/ imx_N7.1.1_1.0.0#打上飞思卡尔补丁 并进入imx_ N7.1.1_1.0.0分支
如果出现下面输出则说明打补丁成功
*****************************************************************
Success: Now you can build the Android code for FSL i.MX platform
*****************************************************************


$ source build/envsetup.sh #建立编译环境
$ lunch sabresd_6dq-user #指定板型
$ make 2>&1 | tee build-log.txt  #编译

编译完成后将在myandroid/out/target/product/sabresd_6dq目录下生成一下内容

 root/: root file system (including init, init.rc). Mounted at /.
  system/: Android system binary/libraries. Mounted at /system.
  data/: Android data area. Mounted at /data.
  recovery/: root file system when booting in "recovery" mode. Not used directly.
  boot-imx6q.img: composite image for i.MX 6Dual/6Quad SABRE-SD, which includes the kernel zImage, ramdisk,
board's device tree binary, and boot parameters.

 boot-imx6qp.img: composite image for i.MX 6QuadPlus SABRE-SD, which includes the kernel zImage, ramdisk,
board's device tree binary, and boot parameters.
  boot-imx6dl.img: composite image for i.MX 6DualLite SABRE-SD, which includes the kernel zImage, ramdisk,
board's device tree binary, and boot parameters.
  boot-imx6q-ldo.img: a composite image for i.MX 6Dual/6Quad 1.2 G Hz SABRE-SD, which includes the kernel
zImage, ramdisk, board's device tree binary, and boot parameters.
 ramdisk.img: ramdisk image generated from "root/". Not used directly.
  system.img: EXT4 image generated from "system/". It can be programmed to "SYSTEM" partition on SD/eMMCcard with "dd".
  recovery-imx6q.img: EXT4 image for i.MX 6Dual/6Quad SABRE-SD, which is generated from "recovery/". Can be
programmed to the "RECOVERY" partition on SD/eMMC card with "dd".
  recovery-imx6qp.img: EXT4 image for i.MX 6QuadPlus SABRE-SD, which is generated from "recovery/". Can be
programmed to the "RECOVERY" partition on SD/eMMC card with "dd".
  recovery-imx6q-ldo.img: EXT4 image for i.MX 6Dual/6Quad 1.2 G Hz SABRE-SD, which is generated from
"recovery/". Can be programmed to "RECOVERY" partition on SD/eMMC card with "dd".
  recovery-imx6dl.img: EXT4 image for i.MX 6DualLite SABRE-SD, which is generated from "recovery/". Can be
programmed to the "RECOVERY" partition on SD/eMMC card with "dd".
  u-boot-imx6q.imx: U-Boot image with no padding for i.MX 6Dual/6Quad SABRE-SD.
  u-boot-imx6qpimx: U-Boot image with no padding for i.MX 6QuadPlus SABRE-SD.
  u-boot-imx6dl.imx: U-Boot image with no padding for i.MX 6DualLite SABRE-SD
 

注意: 在上面我们指定板型时使用了  lunch sabresd_6dq-user  命令,相对的 还可以用sabresd_6dq-eng,区别是:
• Limited Android System image access for security reasons.
• Lack of debugging tools.
• Installation modules tagged with user

• APKs and tools according to product definition files, which are found in PRODUCT_PACKAGES in the sources
folder ~/myandroid/device/fsl/imx6/imx6.mk. To add customized packages, add the package MODULE_NAME or
PACKAGE_NAME to this list.
• The properties are set as:
ro.secure=1andro.debuggable=0.
adb is disabled by default.

默认的配置使用emmc作为启动介质,通过以下步骤设置sd启动:

1. 移除out/target/product/sabresd_6dq/root 目录和 boot*.img镜像.
2. 移除 out/target/product/sabresd_6dq/recovery目录 和 recovery*.img镜像.
3. 构建 the boot.img and recovery.img as follows:
$make bootimage BUILD_TARGET_DEVICE=sd
$make recoveryimage BUILD_TARGET_DEVICE=sd
 

3.构建 U-Boot 镜像 


$ cd /opt/myandroid/bootable/bootloader/uboot-imx
$ export ARCH=arm
$ export CROSS_COMPILE=/opt/myandroid/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-
arm-linux-androideabi-
$ make distclean
For i.MX 6Quad/6QuadPlus SABRE-SD:
$ make mx6qsabresdandroid_defconfig
$ make


注意:
任何一个可被uboot加载的镜像都必须有一个唯一镜像头。例如,必须在镜像头加入一些能告诉uboot有关该镜像(内核或ramfs)信息以及镜像加载/执行地址的信息。在uboot加载任何镜像到ram之前,你需要一个工具来添加这些信息从而生成一个新的可被uboot识别的镜像。这个工具随uboot源码一起提供。在你构建完成uboot之后,可以在tools目录下找到这个工具(mkimage)

4.构建内核镜像


$ export PATH=/opt/myandroid/bootable/bootloader/uboot-imx/tools:$PATH
$ cd /opt/myandroid/kernel_imx

$ export ARCH=arm
$ export CROSS_COMPILE=/opt/myandroid/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/
arm-linux-androideabi-
# Generate ".config" according to default config file under arch/arm/configs.
# To build the kernel image for i.MX 6Dual/Quad, 6QuadPlus, 6DualLite, 6Solo, 6SoloLite,
6SoloX, and 7Dual
$ make imx_v7_android_defconfig
$ make KCFLAGS=-mno-android
# To build the kernel uImage for i.MX 6Dual/Quad, 6QuadPlus, 6DualLite, and 6Solo
$ make uImage LOADADDR=0x10008000 KCFLAGS=-mno-android


5.构建 boot.img

#如有需要可以在这里修改下devices/fsl/sabresd_6dq/BoardConfig.mk文件内容,其中包括命令行,dtb,等一系列配置
#另外当我们那使用 BUILD_TARGET_DEVICE=sd创建安卓系统时,构建系统会在文件系统中使用mmc2作为存储介质配置文件系统,而mmc2对应的是sdhc3接口,我们可以#修改imx6qdl.dtsi文件,令mmc2=&sdhc2,mmc1=$sdhc3
#把imx6qdl-tqe9.dtsi中如下两行注掉
 &cpu0 {
          #arm-supply = <&sw1a_reg>;//注掉
          #soc-supply = <&sw1c_reg>;//注掉

  };
#把所有形如#vin-supply = <&swbst_reg>;的行注掉。
#修改imx6qdl-tqe9.dtsi如下
        gpio-keys {
                compatible = "gpio-keys";
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_gpio_keys>;


                power {
                        label = "Power Button";
                        gpios = <&gpio4 5 GPIO_ACTIVE_LOW>;
                        gpio-key,wakeup;
                        linux,code = <KEY_POWER>;
                };


                volume-up {
                        label = "Volume Up";
                        gpios = <&gpio4 8 GPIO_ACTIVE_LOW>;
                        gpio-key;
                        linux,code = <KEY_VOLUMEUP>;
                };


                volume-down {
                        label = "Volume Down";
                        gpios = <&gpio4 9 GPIO_ACTIVE_LOW>;
                        gpio-key;
                        linux,code = <KEY_VOLUMEDOWN>;
                };
        };
...
pinctrl_gpio_keys: gpio_keysgrp {
                        fsl,pins = <
                                MX6QDL_PAD_GPIO_19__GPIO4_IO05 0x1b0b0
                                MX6QDL_PAD_KEY_COL1__GPIO4_IO08 0x1b0b0
                                MX6QDL_PAD_KEY_ROW1__GPIO4_IO09 0x1b0b0
                                #if 0
                                MX6QDL_PAD_EIM_D29__GPIO3_IO29 0x1b0b0
                                MX6QDL_PAD_GPIO_4__GPIO1_IO04  0x1b0b0
                                MX6QDL_PAD_GPIO_5__GPIO1_IO05  0x1b0b0
                                #endif

                        >;
                };
...
&ecspi1 {
        fsl,spi-num-chipselects = <1>;
        cs-gpios = <&gpio4 9 0>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_ecspi1>;
        status = "disabled";


        flash: m25p80@0 {
                #address-cells = <1>;
                #size-cells = <1>;
                compatible = "st,m25p32";
                spi-max-frequency = <20000000>;
                reg = <0>;
        };
};
...
&uart5 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_uart5_1>;
        fsl,uart-has-rtscts;
        status = "disabled";
};
#uboot启动参数添加ro.boot.watchdogd=disabled
# Boot image for the i.MX 6Dual/6Quad SABRE-SD board
$ cd /opt/myandroid
$ source build/envsetup.sh
$ lunch sabresd_6dq-user
$ make bootimage

6.使用dd命令烧写镜像到sd卡

下载镜像前需要先按要求进行分区,而官方已经准备好了给我们SD卡分区的脚本,但需保证sd卡容量大于2G。
$ sudo chmod +x ./device/fsl/common/tools/fsl-sdcard-partition.sh
$ sudo ./device/fsl/common/tools/fsl-sdcard-partition.sh -f  imx6q /dev/sdc

Download the U-Boot image:
# sudo dd if=u-boot.imx of=/dev/sdx bs=1K seek=1; sync
Download the boot image:
# sudo dd if=boot.img of=/dev/sdx1; sync
Download the Android system root image:
# sudo simg2img system.img system_raw.img
# sudo dd if=system_raw.img of=/dev/sdx5; sync
Download the Android recovery image:
# sudo dd if=recovery.img of=/dev/sdx2; sync
 

7.uboot环境变量

U-Boot > setenv fastboot_dev mmc0
U-Boot > setenv bootcmd boota mmc0 
U-Boot > setenv bootargs console=ttymxc0,115200 init=/init video=mxcfb0:dev=lcd,CLAA-WVGA,if=RGB24 video=mxcfb1:off video=mxcfb2:off video=mxcfb3:off vmalloc=128M androidboot.console=ttymxc0 consoleblank=0  androidboot.hardware=freescale  ro.boot.watchdogd=disabled cma=448M 
U-Boot > saveenv                         
U-Boot > setenv ethaddr 00:04:9f:00:ea:d3   
U-Boot > setenv fec_addr 00:04:9f:00:ea:d3 




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值