系统: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"
$ 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版本
$ 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 uboot-imx
$ git checkout n7.1.1_1.0.0-ga
$ source /opt/android_N7.1.1_1.0.0_source/code/N7.1.1_1.0.0/and_patch.sh #建立环境
Success: Now you can build the Android code for FSL i.MX platform
*****************************************************************
$ lunch sabresd_6dq-user #指定板型
•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
• 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.
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
注意:
4.构建内核镜像
$ 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
#arm-supply = <&sw1a_reg>;//注掉
#soc-supply = <&sw1c_reg>;//注掉
};
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>;
};
};
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
>;
};
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>;
};
};
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_uart5_1>;
fsl,uart-has-rtscts;
status = "disabled";
};
$ source build/envsetup.sh
$ lunch sabresd_6dq-user
$ make bootimage
6.使用dd命令烧写镜像到sd卡
$ sudo chmod +x ./device/fsl/common/tools/fsl-sdcard-partition.sh
$ sudo ./device/fsl/common/tools/fsl-sdcard-partition.sh -f imx6q /dev/sdc
# 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