Go to NXP's website, download IMX6_M6.0.1_2.1.0_ANDROID_SOURCE_BSP (filename: android_M6.0.1_2.1.0_source.tar.gz) and put into your ~/downloads directory.
Code Block |
---|
theme | Confluence |
---|
language | cpp |
---|
|
$ cd ~/downloads
$ tar xvfz android_M6.0.1_2.1.0_source.tar.gz |
Download Google Android M6.0.1
Code Block |
---|
theme | Confluence |
---|
language | cpp |
---|
|
$ mkdir -p ~/android/smarcfimx6/m_601_210_build
$ cd ~/android/smarcfimx6/m_601_210_build
$ mkdir ~/bin
$ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
$ export PATH=~/bin:$PATH
$ repo init -u https://android.googlesource.com/platform/manifest -b android-6.0.1_r22
$ repo sync -j4 |
Clone Embedian's U-Boot and Linux kernel sources
Code Block |
---|
theme | Confluence |
---|
language | cpp |
---|
|
$ mkdir -p ~/android/smarcfimx6/m_601_210_build/bootable/bootloader
$ cd ~/android/smarcfimx6/m_601_210_build/bootable/bootloader
$ git clone git@git.embedian.com:developer/smarc-t335x-uboot.git uboot-imx
$ cd uboot-imx
$ git checkout smarc-m6.0.1_2.1.0-ga
$ cd ~/android/smarcfimx6/m_601_210_build
$ git clone git@git.embedian.com:developer/smarc-fsl-linux-kernel.git kernel_imx
$ cd kernel_imx
$ git checkout smarc-m6.0.1_2.1.0-ga |
Apply all the i.MX Android patches with Freescale i.MX6 support
Code Block |
---|
theme | Confluence |
---|
language | cpp |
---|
|
$ cd ~/android/smarcfimx6/m_601_210_build
$ source ~/downloads/android_M6.0.1_2.1.0_source/code/M6.0.1_2.1.0/and_patch.sh
**** Invoke ". and_patch.sh" from your shell to add following functions to your environment:
****-- c_gotop: Changes directory to the top of the tree
****-- c_patch: Recover working tree to base version and then applying FSL android patch
$ c_patch ~/downloads/android_M6.0.1_2.1.0_source/code/M6.0.1_2.1.0 imx_M6.0.1_2.1.0
If everything is OK, "c_patch" generates the following output to indicate the successful patch:
*************************************************************
Success: Now you can build android code for FSL i.MX platform
************************************************************* |
Code Block |
---|
theme | Confluence |
---|
language | cpp |
---|
|
$ cd ~/android/smarcfimx6
$ git clone http://git.embedian.com/developer/smarc-fimx6-android.git embedian
$ cd embedian
$ git checkout smarc-m6.0.1_2.1.0-ga
$ cd ../
$ embedian/install |
Build Android Images
Change to Android top level directory.
Code Block |
---|
theme | Confluence |
---|
language | cpp |
---|
|
$ cd ~/android/smarcfimx6/m_601_210_build
$ source build/envsetup.sh
$ export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
$ export PATH=$JAVA_HOME/bin/:$PATH
$ lunch smarc_mx6-eng
or
$ lunch smarc_mx6-user |
Note |
---|
smarc_mx6-user creates a production version of the Android Marshmallow. smarc_mx6-eng creates an engineering version of the Android Marshmallow. Development mode enable and development tools are available on target. |
Switching from eMMC build to SD card build and vice versa
When you switch your target MMC device you need to remove the fstab file. This will guarantee that the make system will copy the right one into target.
Code Block |
---|
theme | Confluence |
---|
language | cpp |
---|
|
$ rm out/target/product/smarc_mx6/recovery/root/fstab* out/target/product/smarc_mx6/root/fstab* |
Build Android for SD card
Code Block |
---|
theme | Confluence |
---|
language | cpp |
---|
|
$ make -j4 BUILD_TARGET_DEVICE=sd 2>&1 | tee build1-1.log |
Note |
---|
When running Android from an SD card, the eMMC will be detected and presented as an SD card storage. |
Build Android for on-SMARC eMMC
Code Block |
---|
theme | Confluence |
---|
language | cpp |
---|
|
$ make -j4 BUILD_TARGET_DEVICE=emmc 2>&1 | tee build1-1.log |
Images created by the Android build for Embedian SMARC-FiMX6 system
All images will be created under out/target/product/smarc_mx6 directory.
Image | Description |
---|
boot-<name1>-<name2>.img | Boot image that contains zImage, device tree blob and ramdisk |
recovery-<name1>-<name2>.img | Recovery image that contains zImage, device tree blob and ramdisk |
system.img | Android system image file. |
u-boot-<defconfig>.img | Bootloader |
Note |
---|
- <name1>: smarcfimx6dl is for solo and dual lite core and smarcfimx6dq is for dual and quad core i.MX6 processor.
- <name2>: If display output is HDMI or parallel RGB, this field is not necessary. If display output is LVDS LCD, this field stands for the LVDS LCD resolutions (wvga, wxga, xga, 1080p, etc...).
- <defconfig>: This is the u-boot defconfig file. If you use quad core and 1GB DDR3L memory, SER3 as your console output port, the u-boot file that you should use is u-boot-smarcfimx6_quad_1g_ser3_android_defconfig.imx. If you use dual lite core and use SER3 as console output, the u-boot file that you should use is u-boot-smarcfimx6_dl_1g_ser3_android_defconfig.imx.
|
Setup Bootloader
U-Boot boots from on-module SPI NOR flash, and the rest of the Android images will be loaded from SD card or on-module eMMC.
To flash u-boot into on-module SPI NOR flash. First, you need to prepare for a new SD card and insert into your Linux host PC. The u-boot-<defconfig>.imx is pre-installed in SPI NOR flash at factory default. SMARC-FiMX6 is designed to always boot up from SPI NOR flash and to load other Android images based on the setting of BOOT_SEL. If users need to fuse their own u-boot or perform u-boot upgrade. This section will instruct you how to do that.
For these instruction, we are assuming: DISK=/dev/mmcblk0, "lsblk" is very useful for determining the device id.
Info |
---|
|
$ export DISK=/dev/mmcblk0 |
Erase SD card:
Info |
---|
|
$ sudo dd if =/dev/zero of=${DISK} bs=1M count= 16 |
Create Partition Layout:
With util-linux v2.26, sfdisk was rewritten and is now based on libfdisk.
Info |
---|
|
$ sudo sfdisk --version
sfdisk from util-linux 2.17.1
|
Create Partitions:
Info |
---|
|
$ sudo sfdisk ${DISK} <<-__EOF__
1M , 48M , 0x83 ,*
,,,-
__EOF__
|
Info |
---|
|
$ sudo sfdisk --in-order --Linux --unit M ${DISK} <<-__EOF__
1 , 48 , 0x83 ,*
,,,-
__EOF__
|
Format Partitions:
Info |
---|
|
for : DISK=/dev/mmcblk0
$ sudo mkfs.vfat -F 16 ${DISK}p1 -n boot
for : DISK=/dev/sdX
$ sudo mkfs.vfat -F 16 ${DISK} 1 -n boot
|
Mount Partitions:
On some systems, these partitions may be auto-mounted...
Info |
---|
|
$ sudo mkdir -p /media/boot/
for : DISK=/dev/mmcblk0
$ sudo mount ${DISK}p1 /media/boot/
for : DISK=/dev/sdX
$ sudo mount ${DISK} 1 /media/boot/
|
Copy u-boot-<defconfig>.imx to the boot partition.
Info |
---|
icon | false |
---|
title | ~/android/smarcfimx6/m_601_210_build/out/target/product/smarc_mx6 |
---|
|
$ sudo cp -v u-boot-<defconfig>.imx /media/boot/u-boot.imx
|
Install Bootloader
If SPI NOR Flash is not empty (Factory Default)
Fuse u-boot.imx to the SPI NOR flash.
Insert the SD card that you just made into EVK-STD-CARRIER SD card slot. Stop at U-Boot command prompt (Press any key when booting up). Copy and Paste the following script under u-boot command prompt.
Info |
---|
icon | false |
---|
title | u-boot command prompt |
---|
|
U-Boot# mmc rescan; mmc dev; load mmc 0:1 0x10800000 u-boot.imx; sf probe; sleep 2; sf erase 0 0xc0000; sf write 0x10800000 0x400 80000 |
If SPI NOR Flash is empty
In some cases, when SPI NOR flash is erased or the u-boot is under development, we need a way to boot from SD card first. Users need to shunt cross the TEST# pin to ground. In this way, SMARC-FiMX6 will always boot up from SD card.
Insert the same SD card into your host Linux PC.
Copy u-boot.imx to the SD card.
Info |
---|
icon | false |
---|
title | ~/android/smarcfimx6/m_601_210_build/out/target/product/smarc_mx6 |
---|
|
$ sudo dd if=u-boot-<defconfig>.imx of=${DISK} bs=512 seek=2
|
Insert the SD card into EVK-STD-CARRIER. Stop at U-Boot command prompt (Press any key when booting up). Copy and Paste the following script under u-boot command prompt.
Info |
---|
icon | false |
---|
title | u-boot command prompt |
---|
|
U-Boot# mmc rescan; mmc dev; load mmc 0:1 0x10800000 u-boot.imx; sf probe; sleep 2; sf erase 0 0xc0000; sf write 0x10800000 0x400 80000 |
Setup SD card
Prepare for the othe SD card that is differmt from the one for bootloader. Insert into your Linux host PC
Code Block |
---|
theme | Confluence |
---|
language | cpp |
---|
|
$ cd ~/android/smarcfimx6/m_601_210_build/out/target/product/smarc_mx6/
$ cp ~/android/smarcfimx6/m_601_210_build/emb-mksdcard.sh .
$ sudo ./emb-mksdcard.sh -f <name1>-<name2> /dev/sdX;sync |
Note |
---|
- <name1>: smarcfimx6dl is for solo and dual lite core and smarcfimx6dq is for dual and quad core i.MX6 processor.
- <name2>: If display output is HDMI or parallel RGB, this field is not necessary. If display output is LVDS LCD, this field stands for the LVDS LCD resolutions (wvga, wxga, xga, 1080p, etc...).
|
Setup eMMC
First, make sure the images that you built is for eMMC (use BUILD_TARGET_DEVICE=emmc when built Android).
Setup eMMC for Android is a bit complex, but trivial. There are a couple of ways to achieve it.
NXP/Freescale provides with a way to boot up, partition, format, and program images into eMMC. User can go to NXP's website to download mfgtool and follow their guide to achieve it. We will leave it to users if you would like to use this method to set up your eMMC. Make sure that the FORCE_RECOV# pin has to be shunt to Ground when using this tool.
Use a Ubuntu 14.04 Bootable SD card
The second way that we also recommend is to make a bootable Ubuntu 14.04 SD card for SMARC-FiMX6. User go to our Linux Development Site to learn how to make a bootable Ubuntu 14.04 SD card. An prr-built images can be downloaded from our ftp site. Users can download those images and follow the "Setup SD card" section from our Linux development site. Once it done, you can copy the emb-mksdcard.sh scipt and all Android images into your home directory. Follow exactly what you did for SD card, but now, eMMC device will be emulated as /dev/mmcblk3.
Code Block |
---|
theme | Confluence |
---|
language | cpp |
---|
|
$ sudo ./emb-mksdcard.sh -f <name1>-<name2> /dev/mmcblk3;sync |
Note |
---|
- <name1>: smarcfimx6dl is for solo and dual lite core and smarcfimx6dq is for dual and quad core i.MX6 processor.
- <name2>: If display output is HDMI or parallel RGB, this field is not necessary. If display output is LVDS LCD, this field stands for the LVDS LCD resolutions (wvga, wxga, xga, 1080p, etc...).
|
Power off and set BOOT_SEL to OFF ON ON and you will be able to boot up your Android from on-module eMMC.
Use USB Fastboot
The third way is to use Android USB fast boot. This way will work only when the on-module eMMC is partitioned and formatted. To partition and format the on-module eMMC. You can use the SD card mentioned above.
Code Block |
---|
theme | Confluence |
---|
language | cpp |
---|
|
$ sudo ./emb-mksdcard.sh -np /dev/mmcblk3 |
Once you have your on-module eMMC partitioned and formated.
On your Linux host PC, you need to install Android tools.
Code Block |
---|
|
$ sudo apt-get install android-tools-adb android-tools-fastboot |
Connect the device with host PC at fastboot mode:
- Connect a USB OTG cable from the target board OTG port to a your host machine USB HOST port.
- Power up the board and hit return/space to stop the boot at U-Boot.
- type fastboot in the U-Boot command line.
On the Host PC:
Code Block |
---|
theme | Confluence |
---|
language | cpp |
---|
|
$ sudo fastboot flash boot out/target/product/smarc_mx6/boot-<name1>-<name2>.img
$ sudo fastboot flash recovery out/target/product/smarc_mx6/recovery-<name1>-<name2>.img
$ sudo fastboot flash system out/target/product/smarc_mx6/system.img
$ sudo fastboot reboot |
Android Recovery Mode
Enter board in Android Recovery mode
Shunt LID# pin to ground will enter Android Recovery mode.
Update Android Firmware
Generate OTA Packages
For generating "OTA" packages, use the following commands:
Code Block |
---|
theme | Confluence |
---|
language | cpp |
---|
|
$ cd ~/android/smarcfimx6/m_601_210_build/
# if Android for SD card
$ make -j4 BUILD_TARGET_DEVICE=sd otapackage 2>&1 | tee build1-1.log
# if Android for eMMC
$ make -j4 BUILD_TARGET_DEVICE=emmc otapackage 2>&1 | tee build1-1.log |
Install OTA Packages to device
- Enter to Android Recovery mode
- Select menu item "apply update from ADB"
- To the host system, perform the following command:
Code Block |
---|
theme | Confluence |
---|
language | cpp |
---|
|
$ out/host/linux-x86/bin/adb sideload out/target/product/smarc_mx6/smarc_mx6-ota-<data>-<image-id>.zip |
Reboot the device.
Note |
---|
Real example name for OTA package: out/target/product/smarc_mx6/smarc_mx6-ota-20170114-smarcfimx6dq-wvga.zip |
Manual Operations
Build boot.img
When you perform changes to the kernel, you may build boot.img solely instead of building the whole Android.
Code Block |
---|
theme | Confluence |
---|
language | cpp |
---|
|
$ cd ~/android/smarcfimx6/m_601_210_build/
$ source build/envsetup.sh
$ lunch smarc_mx6-user (or smarc_mx6-eng)
$ make bootimage |
Setup the toolchain path to point to arm-eabi- tools in prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/bin
Code Block |
---|
theme | Confluence |
---|
language | cpp |
---|
|
$ export ARCH=arm
$ export CROSS_COMPILE=~/android/smarcfimx6/m_601_210_build/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/bin/arm-eabi- |
Manual build Bootloader
Change directory to U-Boot
Code Block |
---|
theme | Confluence |
---|
language | cpp |
---|
|
$ cd ~/android/smarcfimx6/m_601_210_build/bootable/bootloader/uboot-imx |
Execute following commands:
Code Block |
---|
theme | Confluence |
---|
language | cpp |
---|
|
$ make distclean
$ make smarcfimx6_quad_1g_ser3_android_defconfig
$ make -j4 |
Note |
---|
Note1: If the board is SMARC-FiMX6-Q-2G or SMARC-FiMX6-D-2G, use $ make ARCH=arm CROSS_COMPILE=${CC} smarcfimx6_quad_2g_ser3_android_defconfig If the board is SMARC-FiMX6-Q-1G or SMARC-FiMX6-D-1G, use $ make ARCH=arm CROSS_COMPILE=${CC} smarcfimx6_quad_1g_ser3_android_defconfig If the board is SMARC-FiMX6-U-1G, use $ make ARCH=arm CROSS_COMPILE=${CC} smarcfimx6_dl_1g_ser3_android_defconfig If the board is SMARC-FiMX6-S, use $ make ARCH=arm CROSS_COMPILE=${CC} smarcfimx6_solo_ser3_android_defconfig Note 2: "ser3" stands for console debug port. In this example, we uses SER3 as debug port. If user uses SER0 as your debug port, make change to "ser0" instead. Same as SER1 and SER2. Note 3: The SMARC-FiMX6 module always boot up from the onboard SPI NOR flash. The factory default will be u-boot.imx pre-installed. In some cases when the SPI NOR flash is empty or needs to be upgraded. Users can shunt crossed the TEST# to ground. In this way, the SMARC-FiMX6 module will boot up to carrier SD card, if TEST# pin is shunt crossed. The u-boot.imx image are the same, the difference is how you flash u-boot.imx. This will be explained in the "Setup Bootloader" and "Setup SD card" section. |
It will generate u-boot.imx file.
Manual build Android Linux Kernel and modules
Code Block |
---|
theme | Confluence |
---|
language | cpp |
---|
|
$ cd ~/android/smarcfimx6/m_601_210_build/kernel_imx
$ make distclean
$ make smarcfimx6_android_defconfig
$ make -j4 uImage LOADADDR=0x10008000
$ make -j4 modules |
This will generate the uImage (kernel image) in the kernel/arch/arm/boot folder
version 1.0a,1/15/2017
Last updated 2017-01-25