Message-ID: <1062618687.5235.1711672882313.JavaMail.root@dns3> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_5234_887703428.1711672882313" ------=_Part_5234_887703428.1711672882313 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html SMARC-FiMX6-ANDROID-M6.0.1-2.0.1

SMARC-FiMX6-ANDROID-M6.0.1-2.0.1

=20 =20
=20 =20 = =20 =20 =20 =20 =20 =20 =20 =20 =20 =20 =20 =20
=20 =20
=20
=20
=20

=20

On this page:

=20 =20

=20

Building Freescale/Embedian=E2=80=99s Android M6.0.1_2.0.1 BSP Distribut= ion

Eric Lee

version 1.0a, 1/15/2017

Introduction


This document describes how to&nbs= p;build and deploy Android Marshmallow on the SMARC-FiMX6. It is based on N= XP's IMX6_M6.0.1_2.1.0-ga ANDROID release.


Generating SSH Keys


In order to download u-boot and kerne= l from Embedian. We recommend you use SSH keys to establish a s= ecure connection between your computer and Embedian Gitlab server. The step= s below will walk you through generating an SSH key and then adding the pub= lic key to our Gitlab account. 

Step 1. Check for SSH keys


First, we need to check for existing ssh keys on your computer. Open up&= nbsp;Git Bash and run: 

=20
$ cd ~/.ssh
$ ls
# Lists the files in your .ssh directory
=20

 Check the directory list= ing to see if you have a file named either id_rsa.pub&nbs= p;or id_dsa.pub. If you don't have either of those files = go to step 2. Otherwise, you already have an existing= keypair, and you can skip to step 3. 

Step 2. Generate a new SSH key


 To generate a new SSH ke= y, enter the code below. We want the default settings so when asked to ente= r a file in which to save the key, just press enter.

=20
$ ssh-keygen -t rsa -C "your_email@example.com"
# Creates a new ssh key, using the provided email as a label
# Generating public/private rsa key pair.
# Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press en=
ter]
$ ssh-add id_rsa
=20

 Now you need to enter a = passphrase.

=20
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
=20

 Which should give you so= mething like this:

=20
Your identification has been saved in /c/Users/you/.ssh/id_rsa.
Your public key has been saved in /c/Users/you/.ssh/id_rsa.pub.
The key fingerprint is:
01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com=20

Step 3. Add your SSH key t= o Embedian Gitlab Server


 Copy the key to your cli= pboard.

=20
$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAABDAQABAAABAQDQUEnh8uGpfxaZVU6+uE4bsDrs/tEE5/BPW7j=
MAxak
6qgOh6nUrQGBWS+VxMM2un3KzwvLRJSj8G4TnTK2CSmlBvR+X8ZeXNTyAdaDxULs/StVhH+QRtF=
EGy4o
iMIzvIlTyORY89jzhIsgZzwr01nqoSeWWASd+59JWtFjVy0nwVNVtbek7NfuIGGAPaijO5Wnshr=
2uChB
Pk8ScGjQ3z4VqNXP6CWhCXTqIk7EQl7yX2GKd6FgEFrzae+5Jf63Xm8g6abbE3ytCrMT/jYy5OO=
j2XSg
6jlxSFnKcONAcfMTWkTXeG/OgeGeG5kZdtqryRtOlGmOeuQe1dd3I+Zz3JyT your_email@exa=
mple.c
om
=20

Go to Embedian Git Server. At Profile Setting --> SSH Keys --> Add SSH Key 

Paste your public key and press "Add Key" and your are done.

Overview of this document


The objective of this document is to guide SMARC-FiMX6 Android developer= s to obtain Android Marshmallow sources, setting up host environment, compi= lation and deployment.

This document contains instructions for:

  • Hardware and software requirements.
  • Setup the hardware.
  • Setup the toolchain.
  • Download & build the sources.
  • Install the binaries on the SMARC-FiMX6 SOM.

Hardware Requirement


EVK-STD-CARRIER and SMARC-FiMX6. 

Host (PC) setup requ= irements

The host development environment for Android is based on Ubuntu and Debi= an, please install Ubuntu version 14.04 64bit LTS http://www.ubuntu.com/download/desktop or Debian 8.4 64bit&n= bsp;https://www.debian.org/releases

=20
=20 Icon=20
=20

Do not use other Ubuntu or Debian releases, than recommended above.

= =20
=20
=20

Install requir= ed packages on host PC

=20
$ sudo apt-get -y install git-core gnupg flex bison gperf build-=
essential zip curl zlib1g-dev gcc-multilib g++-multilib=20
$ sudo apt-get -y install libc6-dev-i386 lib32ncurses5-dev x11proto-core-de=
v libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils=20
$ sudo apt-get -y install xsltproc unzip mtd-utils u-boot-tools lzop liblzo=
2-2 liblzo2-dev zlib1g-dev liblz-dev uuid uuid-dev android-tools-fsutils=20

Install the OpenJDK=

=20
$ sudo apt-get update=20
$ sudo apt-get install openjdk-7-jdk
=20


Update the default Java version by running:

=20
$ sudo update-alternatives --config java=20
$ sudo update-alternatives --config javac
=20
=20
=20 Icon=20
=20

The build machine should have at least 50GB of free space to complete th= e build process.

=20
=20
=20

Obtain Source Code


<= span class=3D"mw-headline" style=3D"color: rgb(0,51,102);">Get NXP's Androi= d Release Package

Go to NXP's website, download IMX6_M6.0.1_2.1.0_ANDROID_SOURCE_BSP (file= name: android_M6.0.1_2.1.0_source.tar.gz) and put into your ~/downloads dir= ectory.

=20
$ cd ~/downloads
$ tar xvfz android_M6.0.1_2.1.0_source.tar.gz
=20

Download Google An= droid M6.0.1

=20
$ mkdir -p ~/android/smarcfimx6/m_601_210_build=20
$ cd ~/android/smarcfimx6/m_601_210_build=20
$ mkdir ~/bin=20
$ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo >=
 ~/bin/repo=20
$ chmod a+x ~/bin/repo=20
$ export PATH=3D~/bin:$PATH=20
$ repo init -u https://android.googlesource.com/platform/manifest -b androi=
d-6.0.1_r22=20
$ repo sync -j4
=20

Clo= ne Embedian's U-Boot and Linux kernel sources

=20
$ mkdir -p ~/android/smarcfimx6/m_601_210_build/bootable/bootloa=
der=20
$ 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 kerne=
l_imx
$ cd kernel_imx
$ git checkout smarc-m6.0.1_2.1.0-ga 
=20

Apply all the i.MX Android patches with Freescale i.MX6 support

=20
$ 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_patc=
h.sh
**** Invoke ". and_patch.sh" from your shell to add following fun=
ctions to your environment:
****-- c_gotop:     Changes directory to the top of the tree=20
****-- 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
*************************************************************
=20

Apply Em= bedian's i.MX6 platforms' patches

=20
$ cd ~/android/smarcfimx6
$ git clone http://git.embedian.com/developer/smarc-fimx6-android.git embed=
ian
$ cd embedian
$ git checkout smarc-m6.0.1_2.1.0-ga=20
$ cd ../
$ embedian/install
=20

Build Android Images


Change to Android top level directory.
=20
$ cd ~/android/smarcfimx6/m_601_210_build
$ source build/envsetup.sh
$ export JAVA_HOME=3D/usr/lib/jvm/java-1.7.0-openjdk-amd64
$ export PATH=3D$JAVA_HOME/bin/:$PATH
$ lunch smarc_mx6-eng
or
$ lunch smarc_mx6-user
=20
=20
=20 Icon=20
=20

smarc<= /span>_mx6-user creates a production version of the Android Marshmal= low. smarc_mx6-eng creates an engineering version of the Android Marshmallo= w. Development mode enable and development tools are available on target.=20

=20
=20

=20
$ rm out/target/product/smarc_mx6/recovery/root/fstab* out/targe=
t/product/smarc_mx6/root/fstab*
=20

Build Android for SD car= d

=20
$ make -j4 BUILD_TARGET_DEVICE=3Dsd 2>&1 | tee build1-1.l=
og
=20
=20
=20 Icon=20
=20

When running Android from an SD card, the eMMC will be detected and pres= ented as an SD card storage.

=20
=20
=20

Build Android for = on-SMARC eMMC

=20
$ make -j4 BUILD_TARGET_DEVICE=3Demmc 2>&1 | tee build1-1=
.log
=20

Images created by the Android build for Embedian SMARC-FiMX6 s= ystem

All images will be created under out/target/product/smarc_mx6 directory.

Image Description
boot-<name1>-<name2&g= t;.img Boot image that contains zImage, device tree blo= b 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
=20
=20 Icon=20
=20
  1. <name1>: smarc= fimx6dl is for solo and dual lite core and smarcfimx6dq is for dual and quad core i.MX6 processor.
  2. <name2>: If display output is HDMI or parallel RGB, this= field is not necessary. If display output is LVDS LCD, this field stands f= or the LVDS LCD resolutions (wvga, wxga, xga, 1080p, etc...). = ;
  3. <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_a= ndroid_defconfig.imx. If you use dual lite core and use SER3 as consol= e output, the u-boot file that you should use is u-boot-smarcfimx6_dl_1= g_ser3_android_defconfig.imx.
=20
=20
=20

Setup Bootloader<= /span>


U-Boot boots from on-module SPI NOR flash, and the rest of the Android i= mages 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 f= actory default. SMARC-FiMX6 is designed to always boot up from SPI NOR flas= h and to load other Android images based on the setting of BOOT_SE= L. If users need to fuse their own u-boot or perform u-boot upgrade. T= his section will instruct you how to do that.

For these instruction, we are assuming: DISK=3D/dev/mmcblk0, "lsblk= " is very useful for determining the device id.

=20
=20
=20

$ export DISK=3D/dev/mmcblk0

=20
=20
=20

Erase SD card:

=20
=20
=20

$ sudo = dd if=3D/dev/zero of=3D${DISK} bs=3D1M count=3D16

=20
=20
=20

Create Partition Layout:

With util-linux v2.26, sfdisk was rewritten and is now based on = libfdisk.

=20
=20

sfdisk

=20
=20
$ sudo sfd= isk --version
sfdisk from util-linux 2.17.1
=20
=20
=20

Create Partitions:

=20
=20

sfdisk >=3D2.26.x

=20 Icon=20
=20
$ sudo sfd= isk ${DISK} <<-__EOF__
1M<= code class=3D"java plain">,48M,0x83,*
,,,-
__EOF__
=20
=20
=20
=20

sfdisk <=3D2.25

=20 Icon=20
=20
$ sudo sfd= isk --in-order --Linux --unit M ${DISK} <<-__EOF__
1,48,0x83,*
,,,-
__EOF__
=20
=20
=20

Format Partitions:

=20
=20
=20
for: DISK=3D/dev/mmcblk0
$ sudo mkf= s.vfat -F 16 ${DISK}p1 -n boot
 
for: DISK=3D/dev/sdX
$ sudo mkf= s.vfat -F 16 ${DISK}1 -n boot
=20
=20
=20

Mount Partitions:

On some systems, these partitions may be auto-mounted...

=20
=20
=20
$ sudo mkd= ir -p /media/boot/
 
for: DISK=3D/dev/mmcblk0
$ sudo mou= nt ${DISK}p1 /media/boot/
 
for: DISK=3D/dev/sdX
$ sudo mou= nt ${DISK}1 /media/boot/
=20
=20
=20

Copy u-boot-<defconfig>.imx to the = boot partition.

=20
=20

~/android/smarcfimx6/m_601_210_build/out/target/product/= smarc_mx6

=20
=20

$ sudo cp = -v u-boot-<defconfig>.imx /media/boot/u-boot.imx
=20
=20
=20

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 int= o EVK-STD-CARRIER SD card slot. Stop at U-Boot command prompt (Press any ke= y when booting up). Copy and Paste the following script under u-boot comman= d prompt.

=20
=20

u-boot command prompt

=20
=20

U-Boot# mmc rescan; mmc dev; load m=
mc 0:1 0x10800000 u-boot.imx; sf probe; sleep 2; sf erase 0 0xc0000; sf write 0x10800000 0x400 80000=20
=20
=20

If SPI N= OR Flash is empty

In some cases, when SPI NOR flash is eras= ed or the u-boot is under development, we need a way to boot from SD card f= irst. 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 Li= nux PC. 

Copy u-boot.imx to the SD card.

=20
=20

~/android/smarcfimx6/m_601_210_build/out/target/product/= smarc_mx6

=20
=20

$ sudo dd if=3Du-boot-<defconfig>.imx of=3D${DISK} bs=3D512 seek=3D2<= /span>
=20
=20
=20

Insert the SD card into EVK-STD-CARRIER. = Stop at U-Boot command prompt (Press any key when booting up). Copy and Pas= te the following script under u-boot command prompt.

=20
=20

u-boot command prompt

=20
=20

U-Boot# mmc rescan; mmc dev; load m=
mc 0:1 0x10800000 u-boot.imx; sf probe; sleep 2; sf erase 0 0xc0000; sf write 0x10800000 0x400 80000=20
=20
=20

Setup SD card


 Prepare for the othe SD card that is differmt from the one for bootloader.= Insert into your Linux host PC

=20
$ cd ~/android/smarcfimx6/m_601_210_build/out/target/product/sma=
rc_mx6/
$ cp ~/android/smarcfimx6/m_601_210_build/emb-mksdcard.sh .
$ sudo ./emb-mksdcard.sh -f <name1>-<name2> /dev/sdX;sync
= =20
=20
=20 Icon=20
=20
  1. <name1>: smarc= fimx6dl is for solo and dual lite core and smarcfimx6dq is for dual and quad core i.MX6 processor.
  2. <name2>: If display output is HDMI or parallel RGB, this= field is not necessary. If display output is LVDS LCD, this field stands f= or the LVDS LCD resolutions (wvga, wxga, xga, 1080p, etc...). = ;
=20
=20
=20

Setup eMMC


First, make sure the images that y= ou built is for eMMC (use BUILD_TARGET_DEVICE=3Demmc w= hen built Android).

Setup eMMC for Android is a bit complex, but trivial. There are a couple= of ways to achieve it. 

Use MFG Tools v2


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 mf= gtool and follow their guide to achieve it. We will leave it to users if yo= u 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 t= ool.

<= span style=3D"color: rgb(0,51,102);">Use a Ubuntu 14.04 Bootable SD card


The second way that we also recomm= end 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 pre-built images can be downloade= d from our ftp site. Users can download thos= e images and follow the "Setup SD card" section from our Linux de= velopment site. Once it done, you can copy the emb-mksdcard.sh scipt and all Android im= ages into your home directory. Follow exactly what you did for SD card, but= now, eMMC device will be emulated as /dev/mmcblk3. 

 

=20
$ sudo ./emb-mksdcard.sh -f <name1>-<name2> /dev/mmc=
blk3;sync
=20
=20
=20 Icon=20
=20
  1. <name1>: smarc= fimx6dl is for solo and dual lite core and smarcfimx6dq is for dual and quad core i.MX6 processor.
  2. <name2>: If display output is HDMI or parallel RGB, this= field is not necessary. If display output is LVDS LCD, this field stands f= or the LVDS LCD resolutions (wvga, wxga, xga, 1080p, etc...).
=20
=20
=20

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 t= he on-module eMMC. You can use the SD card mentioned above.

 

=20
$ sudo ./emb-mksdcard.sh -np /dev/mmcblk3
=20

Once you have your on-module eMMC partitioned and formated.

On your Linux host PC, you need to install Android tools.

 

=20
$ sudo apt-get install android-tools-adb android-tools-fastboot=20

Connect the device with ho= st PC at fastboot mode:

  1. Connect a USB OTG cable from the target board OTG port to a your host m= achine USB HOST port.
  2. Power up the board and hit return/space to stop the boot at U-Boot.
  3. type fastboot in the U-Boot command line.

On the Host PC:

=20
$ sudo fastboot flash boot out/target/product/smarc_mx6/boot-<=
;name1>-<name2>.img
$ sudo fastboot flash recovery out/target/product/smarc_mx6/recovery-<na=
me1>-<name2>.img
$ sudo fastboot flash system out/target/product/smarc_mx6/system.img
$ sudo fastboot reboot
=20

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:=

=20
$ cd ~/android/smarcfimx6/m_601_210_build/
# if Android for SD card
$ make -j4 BUILD_TARGET_DEVICE=3Dsd otapackage 2>&1 | tee build1-1.l=
og
# if Android for eMMC
$ make -j4 BUILD_TARGET_DEVICE=3Demmc otapackage 2>&1 | tee build1-1=
.log
=20

Inst= all OTA Packages to device 

  1. Enter to Android Recovery mode
  2. Select menu item "apply update from ADB" 
  3. To the host system, perform the following command:
=20
$ out/host/linux-x86/bin/adb sideload out/target/product/smarc_m=
x6/smarc_mx6-ota-<data>-<image-id>.zip
=20

Reboot the device.

=20
=20 Icon=20
=20

Real example name for OTA package:&nb= sp;out/target/product/smarc_mx6/smarc_mx6-ota-20170114-smarcfimx= 6dq-wvga.zip

=20
=20
=20

Manual Operations


Build boot.img


 When you perform chan= ges to the kernel, you may build boot.img solely instead of building the wh= ole Android.

=20
$ cd ~/android/smarcfimx6/m_601_210_build/
$ source build/envsetup.sh
$ lunch smarc_mx6-user (or smarc_mx6-eng)
$ make bootimage
=20

To= olchain setup for manual build kernel and U-Boot


 Setup the toolchain path to point to arm-eabi- tools in prebuilts/gcc/linu= x-x86/arm/arm-eabi-4.8/bin

=20
$ export ARCH=3Darm
$ export CROSS_COMPILE=3D~/android/smarcfimx6/m_601_210_build/prebuilts/gcc=
/linux-x86/arm/arm-eabi-4.8/bin/arm-eabi-
=20

Manual build Bootloader<= /span>


 Change directory to U-Boot

=20
$ cd ~/android/smarcfimx6/m_601_210_build/bootable/bootloader/ub=
oot-imx
=20

Ex= ecute following commands:

=20
$ make distclean
$ make smarcfimx6_quad_1g_ser3_android_defconfig
$ make -j4
=20
=20
=20 Icon=20
=20

Note1:=

If the board is SMARC-FiMX6-Q-2G or SMARC-FiMX6-D-2G, use
$ make ARCH=3Darm CROSS_COMPILE=3D${CC} smarcf= imx6_quad_2g_ser3_android_defconfig

 If the board is SMARC= -FiMX6-Q-1G or SMARC-FiMX6-D-1G, use
$ make ARCH=3Darm CROSS_COMPILE=3D${CC} smarcfimx6_quad_1g_ser3_androi= d_defconfig

 If the board is SMARC= -FiMX6-U-1G, use
$ make ARCH=3Da= rm CROSS_COMPILE=3D${CC} smarcfimx6_dl_1g_ser3_android_defconfig

 If the board is SMARC= -FiMX6-S, use
$ make ARCH=3Darm = CROSS_COMPILE=3D${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 ch= ange to "ser0" instead. Same as SER1 and SER2.

Note 3:

The SMARC-FiMX6 module always boot up from the onboar= d 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 th= e TEST# to ground. In this way, the SMARC-FiMX6=  module will boot up to carrier SD card, if TEST#&n= bsp;pin is shunt crossed. The u-boot.imx image are the s= ame, the difference is how you flash u-boot.imx. This will be= explained in the "Setup Bootloader" and "Setup SD card"= ; section.

=20
=20
=20

It will generate u-boot.imx file.

Manual build Android Linux K= ernel and modules


 

=20
$ cd ~/android/smarcfimx6/m_601_210_build/kernel_imx=20
$ make distclean
$ make smarcfimx6_android_defconfig
$ make -j4 uImage LOADADDR=3D0x10008000
$ make -j4 modules
=20

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


&n= bsp;
------=_Part_5234_887703428.1711672882313--