This post documents a recent build of Android 4.4.2 KitKat on Ubuntu 12.04.5 LTS x86_64 Desktop using the Element14-provided source code for RIoTboard. The build images were transferred to an SD card using Linux commands rather than using the MFGTool.  Ubuntu 14.04.5 LTS x86_64 Desktop users should see the Addendum at the bottom of the post for additional information.

 

HARDWARE AND BUILD OS

 

Gateway NE56R12u Laptop running Ubuntu 12.04.5 LTS x86_64 Desktop

     2.1 GHz Intel B950 dual-core Pentium processor

     8 GB physical RAM

     135 GB /home partition for build

     60 Mbs Internet connection

 

RESOURCES

 

RIoTboard User Manual Version 2.1 (RioTboard-User-Manual-V2.1.pdf)

Freescale Semiconductor Android User's Guide, Document Number : AUG, Rev. kk4.4.2_1.0.0-ga, 07/2014 (Android-Users-Guide.pdf)

https://source.android.com/source/initializing.html

Building Android from Source

Recompiling Android for use with Parallel RGB TFT LCD and Capacitive Touch Panel

Android, setting up a Linux build environment, libgl1-mesa-glx:i386 package have unmet dependencies - Stack Overflow

 

UPDATE UBUNTU

 

sudo apt-get update
sudo apt-get upgrade

(reboot)

sudo apt-get dist-upgrade

(reboot)

 

INSTALL NECESSARY PACKAGES

 

Note that non-development Mesa packages (namely, libgl1-mesa-glx:i386 and libglapi-mesa:i386) are NOT used in the following command. This is due to the fact that attempting to install these packages triggered the removal of more than three dozen 64-bit Mesa packages, and this in turn caused the boot sequence to hang due to graphics issues. Pay attention to what packages are proposed for removal when you install necessary packages, and if you see large numbers of 64-bit graphics libraries being sacrificed for the sake of dependencies, then you are probably doing something wrong.

 

 sudo apt-get install ia32-libs-multiarch git gnupg flex bison gperf build-essential zip curl libc6-dev x11proto-core-dev lib32ncurses5-dev libx11-dev:i386 lib32readline6-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 ia32-libs u-boot-tools minicom libncurses5-dev lib32z1-dev uuid-dev liblzo2-dev

 

UNPACK ANDROID SOURCE CODE

 

Copy the android-imx6-kk4.4.2-1.0.0-svn2705-20140818.tar.bz2 source code file to the home directory and decompress it:

 

cd ~
tar -xvf android-imx6-kk4.4.2-1.0.0-svn2705-20140818.tar.bz2

 

INSTALL JAVA 6 JDK

 

I had a copy of the Oracle Java 6 Update 43 JDK tucked away in my archive, so I used it as the Java JDK. OpenJDK can also be used, but changes to build scripts will be necessary as noted in the “Building Android from Source” post above. The “Recompiling Android” post above has a link to the more recent Oracle Java 6 Update 45 JDK if you prefer.

 

sudo mkdir /usr/lib/jvm
sudo chmod a+x jdk-6u43-linux-x64.bin
sudo ./jdk-6u43-linux-x64.bin
sudo mv jdk1.6.0_43 /usr/lib/jvm

 

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_43/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_43/bin/javac 1
sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.6.0_43/bin/javaws 1

 

sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javaws
export PATH=$PATH:/usr/lib/jvm/jdk1.6.0_43/bin

 

SELECT SD CARD OR EMMC BUILD

 

Open android-imx6-kk4.4.2-1.0.0/device/fsl/RIoTboard_6solo/BoardConfig.mk in your favorite editor and change

 

BUILD_TARGET_LOCATION ?= emmc

 

to

 

BUILD_TARGET_LOCATION ?= sdmmc

 

since we want to create an SD card image. Save the file.

 

BUILD ANDROID

 

cd ~/android-imx6-kk4.4.2-1.0.0
source build/envsetup.sh
lunch (Select RIoTboard_6solo-user)
make clean
time make -j4

 

The -j4 parameter in the make command is important as this reduced build times on my dual core laptop from around 7 hours to a little over 3 ½ hours. At the very least, you want as many jobs as you have CPU cores (-j2 in my case), but in my tests, increasing beyond that yields only marginal improvement.

 

CREATE A BOOTABLE SD CARD

 

The resulting image files to create an SD card for booting RIoTboard are located in ~/android-imx6-kk4.4.2-1.0.0/out/target/product/RIoTboard_6solo/:

 

boot.img

recovery.img

system.img

u-boot.bin

 

Per the Freescale Semiconductor Android User's Guide, a Linux script to generate the necessary partitions on a blank SD card to boot Android is located in ~/android-imx6-kk4.4.2-1.0.0/device/fsl/common/tools/fsl-sdcard-partition.sh.

 

Determine the device designation for the SD card in your system. You can use the lsblk command to do this by executing the command first without the SD card inserted, and then again with the SD card inserted.:

 

stmorgan@GATEWAY:~$ lsblk

NAME MAJ:MIN RM SIZE   RO TYPE MOUNTPOINT

sda    8:0   0  465.8G 0  disk 

sda1   8:1   0  100M   0  part 

sda2   8:2   0  288G   0  part 

sda3   8:3   0  1K     0  part 

sda5   8:5   0  169.8G 0  part /

sda6   8:6   0  7.9G   0  part [SWAP]

sr0   11:0   1  1024M  0  rom  


stmorgan@GATEWAY:~$ lsblk

NAME MAJ:MIN RM SIZE   RO TYPE MOUNTPOINT

sda    8:0   0  465.8G 0  disk 

sda1   8:1   0  100M   0  part 

sda2   8:2   0  288G   0  part 

sda3   8:3   0  1K     0  part 

sda5   8:5   0  169.8G 0  part /

sda6   8:6   0  7.9G   0  part [SWAP]

sdd    8:48  1  29.8G  0  disk

sdd1   8:49  1  29.8G  0  part /media/9016-4EF8

sr0   11:0   1  1024M  0  rom  

 

So I would use /dev/sdd for the SD card on my system. Note that this is not an empty SD card, as indicated by the presence of the mounted sdd1 partition.

 

In the following discussion, /dev/sdX will be used for the SD card, BUT YOU MUST REMEMBER TO CHANGE THE DEVICE DESIGNATION TO MATCH YOUR CARD IN ALL COMMANDS THAT FOLLOW.

 

Use your favorite method to remove all partitions from your SD card. If the partitioning tool used to remove partitions asks whether to use an MS-DOS or GPT scheme, use MS-DOS.

 

Execute the following commands after an SD card with no partitions has been inserted into the system:

 

cd ~/android-imx6-kk4.4.2-1.0.0/device/fsl/common/tools
sudo ./fsl-sdcard-partition.sh /dev/sdX

 

Eject the SD card from the system and reinsert it. This is a necessary step on my Gateway laptop, otherwise the following commands will not generate a usable image, although they give the outward appearance of doing what they are supposed to do.

 

cd ~/android-imx6-kk4.4.2-1.0.0/out/target/product/RIoTboard_6solo
sudo dd if=u-boot.bin of=/dev/sdX bs=1K skip=1 seek=1; sync
sudo dd if=boot.img of=/dev/sdX1; sync
sudo dd if=system.img of=/dev/sdX5; sync
sudo dd if=recovery.img of=/dev/sdX2; sync

 

The SD card can now be used to boot Android on the RIoTboard.

 

It's worth mentioning that there is a difference between the partition organization yielded by the above procedure versus that used in the Element14 pre-built SD card image. The Element14 image uses a partitioning scheme identical to that described in the Freescale Semiconductor Android User's Manual (presumably a byproduct of using MFGTool in a Windows environment), so the partitions are physically ordered as follows:

 

PARTITION TYPE/INDEX     NAME

N/A                      U-Boot Loader

Primary 1                Boot

Primary 2                Recovery

Logical 5 (Extended 3)   SYSTEM

Logical 6 (Extended 3)   CACHE

Logical 7 (Extended 3)   Device

Logical 8 (Extended 3)   Misc

Primary 4                DATA

 

The procedure used above reverses the Extended 3 and Primary 4 partitions, so the resulting physical order is as follows:

 

PARTITION TYPE/INDEX     NAME

N/A                      U-Boot Loader

Logical 1                Boot

Logical 2                Recovery

Logical 3                (small stub)

Logical 4                DATA

Logical 5                SYSTEM

Logical 6                CACHE

Logical 7                Device

Logical 8                Misc

 

For those too young to remember, the above references to Primary and Extended partitions go all the way back to Microsoft MS-DOS where you could have a maximum of either four Primary partitions on a (usually hard) disk drive or three Primary partitions and one Extended partition which could be populated with one or more Logical partitions. The procedure above just generates a sequence of Type 0x083 GNU/Linux partitions.

 

ENABLE 7-INCH LCD DISPLAY

 

The LCD8000-70T 7-inch LCD can be used with the resulting build by using the U-boot boot arguments specified in the LCD8000-70T Quick Start Guide.  NOTE:  You must have a connection to the J18 Serial Debug Port during boot in order to execute the following commands.

 

Reboot the RIoTboard, press a key when the “Hit any key to stop autoboot:” message appears and use the following commands:

 

MX6Solo RIoTboard U-Boot >setenv bootargs console=ttymxc1,115200 init=/init nosmp video=mxcfb0:dev=lcd,7inch_LCD,if=RGB565 video=mxcfb1:off fbmem=10M vmalloc=400M androidboot.console=ttymxc1 androidboot.hardware=freescale calibration
MX6Solo RIoTboard U-Boot >saveenv

 

Reboot the RIoTboard, and you should see the LCD in action. While the LCD works, the touchscreen does not.

 

CONCLUSION

 

Hopefully, this procedure will be of use to someone who is unable to use the MFGTool due to a lack of access to a Windows machine.  Thanks to those who have taken the time to post their procedures and approaches to issues when trying to build Android for RIoTboard.

 

ADDENDUM

 

The procedure for Ubuntu 14.04.5 LTS x86_64 Desktop is identical except for the Install Necessary Packages section.  Replace this section with the following:

 

INSTALL NECESSARY PACKAGES

 

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 u-boot-tools uuid-dev liblzo2-dev python-markdown