Aria Ti am335x Android kk4.4.4

From Ariaboard Wiki
Jump to navigation Jump to search

Android KitKat 4.4 for Ariaboard am335x

apt install

sudo apt-get install bison g++-multilib git gperf libxml2-utils make python-networkx zlib1g-dev:i386 zip curl flex

if > u1604

apt install repo

sun jdk 6

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java6-installer


cd ~
tar -xvf make-3.82.tar.gz
cd make-3.82

use a proxy if needed

git proxy:

git config --global http.proxy 'socks5://'
git config --global https.proxy 'socks5://'

http proxy:

export http_proxy=
export https_proxy=

Kernel Cross Compiler

IMPORTANT, we usually will use armhf(gnueabihf), but for android we use arm(guneabi)


cd /opt
tar -xvf gcc-linaro-arm-linux-gnueabi-2012.04-20120426_linux.tar.bz2

at ~/.bashrc insert:

export PATH=/opt/gcc-linaro-arm-linux-gnueabi-2012.04-20120426_linux/bin:$PATH

Get Aosp 4.4.4_r1

Note we use ~/aosp

Install repo command if not u1604

mkdir ~/bin
curl > ~/bin/repo
chmod a+x ~/bin/repo

setup sync android code.

mkdir ~/aosp
cd aosp 
repo init -u -b android-4.4.4_r1 
repo sync -c

This takes several hours because there is > 60 GiB to download. When complete you will have the AOSP code in ~/aosp

Get Device files for am335x

 cd ~/aosp/device
 mkdir ti
 cd ti
 git clone beagleboneblack
 cd beagleboneblack

Checkout the right version. If installing to an SD card:

 git checkout kk4.4-sdcard

If installing to eMMC via fastboot:

git checkout kk4.4-fastboot

Apply the patch....

cd ~/aosp/system/core
patch -p1 < ../../device/ti/beagleboneblack/0001-Fix-CallStack-API.patch

Then select the product:

cd ~/aosp
. build/

Select "beagleboneblack-eng" (option 1x)

Build AOSP for am335x

~/make-3.82/make -j`getconf _NPROCESSORS_ONLN`

This takes an hour or two. When complete you will find the compiled Android system in ~/aosp/out/target/product/beagleboneblack/

Build U-boot

 cd  ~/aosp
 git clone 
 cd aria-uboot     
 git checkout android

eEnv.txt for SD CARD

bootargs=console=ttyO0,115200n8 androidboot.console=ttyO0 rootwait ro
bootcmd=mmc rescan ; fatload mmc 0 82000000 uImage ; fatload mmc 0 83000000 uRamdisk ; bootm 82000000 83000000

eEnv.txt for eMMC

bootargs=console=ttyO0,115200n8 androidboot.console=ttyO0 rootwait ro
bootcmd=mmc rescan ; fatload mmc 1 82000000 uImage ; fatload mmc 1 83000000 uRamdisk ; bootm 82000000 83000000

Build Kernel

use cross compiler: gcc-linaro-arm-linux-gnueabi-2012.04-20120426_linux.tar.bz2

cd ~/aosp
git clone YOUR_GIT_ADDR kernel
cd kernel
git checkout aria_slot_480_800 

Build SGX Drivers

Once again I am getting these from Rowboat. This is messy because they are not very well integrated with the AOSP code. One issue is that the makefile has some paths hard coded which is why it has to be put into hardware/ti/sgx, and also why the kernel has to be in directory kernel/.

cd ~/aosp/hardware/ti
git clone sgx
cd sgx
git checkout ti_sgx_sdk-ddk_1.10-jb-4.3

With Rowboat, the binaries are copied into out/target/product/beagleboneblack/system after the AOSP build is complete and then post-processed into the install tar ball. I want to have them built as part of the AOSP build, so I edit one of the makefiles to put the binaries into my device directory. Then they get sucked into the final images by the rules in my So, edit Rules.make: line 23 and change




This next bit has to be run in a completely new shell. I'm sorry, but for some reason it won't build in a shell that has been set up for an AOSP build (i.e. has ". build/").Note: W=1 is needed to avoid turning warnings into errors... $ cd ~/aosp/hardware/ti/sgx

make TARGET_PRODUCT=beagleboneblack OMAPES=4.x ANDROID_ROOT_DIR=$HOME/aosp W=1
make TARGET_PRODUCT=beagleboneblack OMAPES=4.x ANDROID_ROOT_DIR=$HOME/aosp W=1 install 

That will result in populating device/ti/beagleboneblack/sgx

Clean SGX Drivers

If any compiling error occurs, or you want to remove SGX drivers,

rm -rf ~/aosp/hardware/ti 
rm -rf ~/aosp/device/ti/beagleboneblack/sgx/*

Final Build

Now you need to regenerate the Android image files to include the sgx binaries. This should only take a few minutes. $ cd ~/aosp

. build/
lunch beagleboneblack-eng 
~/make-3.82/make installclean 
~/make-3.82/make -j`getconf _NPROCESSORS_ONLN`

If something goes wrong, go back through the steps and try to identify the problem.

Install option (1): install to SD card

You need a micro SD card of at least 4 GiB capacity. Insert your SD card into your SD card reader. It will appear as either /dev/sd? Or as /dev/mmcblk? Use fdisk or similar to create partitions like this: Partition type bootable? Size (MiB) ID and file system

1          primary      *               64   c  W95 FAT32 (LBA)  
2          primary                      32  83  Linux 
3          primary                      32  83  Linux
4          extended                   ----  (remainder of device)
5          logical                     270  83  Linux 
6          logical                    3080  83  Linux 
7          logical                     270  83  Linux 

I am going to leave the details up to you: that way you can't blame me if it goes wrong, but as mentioned at the start, please do be aware that accidentally formatting the wrong device, for example your hard drive, is a distinct possibility. It has happened to me. So, please, double check everything.Then format the first partition, the boot partition, giving the correct device node:

sudo mkfs -t vfat -n "boot" /dev/mmcblk0

Create the ramdisk:

cd ~/aosp
mkimage -A arm -O linux -T ramdisk -d out/target/product/beagleboneblack/ramdisk.img uRamdisk

Mount the first partition and copy these files to it 1. u-boot/MLO 2. u-boot/u-boot.img 3. uRamdisk 4. device/ti/beagleboneblack/uEnv.txt 5. kernel/arch/arm/boot/uImageThe remaining image files are already in ext4 format so they can be copied directly to partitions 5, 6 and 7. For example if the SD card is /dev/mmcblk0 then

cd ~/aosp/out/target/product/beagleboneblack
sudo dd if=system.img of=/dev/mmcblk0p5 bs=4M
sudo dd if=userdata.img of=/dev/mmcblk0p6 bs=4M
sudo dd if=cache.img of=/dev/mmcblk0p7 bs=4M

Now put the SD card in your BeagleBone. Hold down the boot button while powering on to get it to load U-Boot from the SD card. All being well, you should see the "Android" boot animation after about 30 seconds and the launcher screen after 90 to 120 seconds. The second time the boot should be faster, I find it to be about 30 seconds.

Flash eMMC via SD card

Now you have a SD card made. We will need to back it up to an image. At PC Linux:

sudo dd if=/dev/sdX of=andoird-ariaboard-am335x.image bs=4M
pixz andoird-ariaboard-am335x.image # xz andoird-ariaboard-am335x.image

Note: output image will be andoird-ariaboard-am335x.image.xz

Copy the andoird-ariaboard-am335x.image.xz to sd card /root

Now boot linux on Ariaboad am335x board with an SD card. Restore eMMC with command:

xzcat andoird-ariaboard-am335x.image.xz > /dev/mmcblkX 


unxz -c andoird-ariaboard-am335x.image.xz | dd of=/dev/mmcblkX

sample script