Thursday 17 December 2015

Android Lollipop build and install on Wandboard Dual

I took a small break from baremetal development to learn some Android. I had bought a Wandboard Dual for the purpose of learning Android. This board comes with the Freescale i.MX6 Cortex A9 Dual core CPU with 1GB of DDR3 RAM.


My Build setup:

Ubuntu 15.10 Wily
Sun java version "1.8.0_51" and javac 1.8.0_51

Do a prerequisite install of the different packages as mentioned in google android site.

As I recall there was a problem when the kernel was getting archived which seems to be because of lzop package not being present. It seems to be the latest way to archive. Please install the package from the repository.


Coming to the install grab the Android Lollipop source archive from the Wandboard site and unzip it.



Modify wandboard.h(bootable/bootloader/uboot-imx/include/configs/wandboard.h) to have the appropriate display resolution. I have a Dell Monitor with 1920x1024@60 as ideal specification.
So my code snippet is:


  "if hdmidet; then " \
            "setenv bootargs ${bootargs} " \

                "video=mxcfb${nextcon}:dev=hdmi,1920x1080M@60," \
                    "if=RGB24; " \
            "setenv fbmen fbmem=28M; " \

Either compile first and then modify and compile again or modify the above in the initial steps before start of compilation and then compile.

Now do a
  1. source ./build/envsetup.sh
  2. lunch and hit tab to see the options. Do -> lunch wandboard-eng
  3. make -j10 (here 10 is because I have a quad core machine. So the rule being 2.5 * number of cores we get 2.5 * 4 = 10)
In between the build might stop because of changes in Java code where they have introduced constants which are not present in the original AOSP. The build suggests running make update_api. So do a make update_api and then again start by doing make -j10.

There might be errors when compilation of u-boot and it might stop. Restart the compilation again. This time there will be no stoppage.

My build took at least 3 hours to complete! Usage of CCACHE is highly recommended.

Partition of SD Card:

I created the following partition on my SD card using gparted as the fsl-sdcard-partitions.sh (present in ./device/fsl/common/tools) does not work because of "unsupported option -M" in the recent version of sfdisk.

My partition structure is as follows:



Disk /dev/sdb: 29.7 GiB, 31914983424 bytes, 62333952 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x74ea21b6

Device     Boot    Start      End  Sectors  Size Id Type
/dev/sdb1         206848   309247   102400   50M  b W95 FAT32
/dev/sdb2         309248  1357823  1048576  512M 83 Linux
/dev/sdb3        1357824 33310719 31952896 15.2G  5 Extended
/dev/sdb4       33310720 62332927 29022208 13.9G 83 Linux
/dev/sdb5        1359872 11845631 10485760    5G 83 Linux
/dev/sdb6       11847680 16041983  4194304    2G 83 Linux
/dev/sdb7       16044032 18141183  2097152    1G 83 Linux
/dev/sdb8       18143232 22337535  4194304    2G 83 Linux
/dev/sdb9       22339584 33310719 10971136  5.2G 83 Linux

Here
  1. sdb1 is BOOT which is a vfat partition.
  2. sdb2 is RECOVERY. All partitions including this will be ext4.
  3. sdb3 will be an extended partition as we can hold maximum of 4 primary partitions.
  4. sdb4 is DATA
  5. sdb5 is SYSTEM
  6. sdb6 is CACHE
  7. sdb7 is DEVICE
  8. sdb8 is MISC
  9. sdb9 will be mounted if encryptable to sdb5 data.

Leave at least 100MB space at the start of the SD Card for the UBoot SPL loader.

After the build is done we have to flash the SD card.

In the below command we seek 1KB. This is done because Image Vector table offset is 0x400 or 1KB from the start. (Ref: Processor Reference Manual Pg 434).

sudo dd if=bootable/bootloader/uboot-imx/SPL of=/dev/sdb bs=1K seek=1; sync

sudo dd if=./out/target/product/wandboard/system.img of=/dev/sdb5; sync

sudo mount /dev/sdb1 /mnt/wandboard
cd /mnt/wandboard
mkdir boot


For initial ramdisk image creation please do the following:
mkimage -A arm -O linux -T ramdisk -C none -a 0x10800800 -n "Android Root Filesystem" -d out/target/product/wandboard/ramdisk.img /mnt/wandboard/boot/uramdisk.img
 
Copy the following files to the boot directory:

kernel_imx/arch/arm/boot/dts/imx6dl-wandboard.dtb,device/fsl/wandboard/logo/out.bmp.gz,bootable/bootloader/uboot-imx/u-boot.img,device/fsl/wandboard/uenv/uEnv.txt,kernel_imx/arch/arm/boot/uImage and kernel_imx/arch/arm/boot/zImage.

Modify uEnv.txt to have the following text:


bootargs_base=console=ttymxc0,115200 init=/init androidboot.console=ttymxc0 androidboot.hardware=freescale vmalloc=400M androidboot.selinux=disabled
video_mode=display0=dev=hdmi,mode=1920x1080M@60,if=RGB24,bpp=32 fbmem=28M
expansion=fwbadapt
baseboard=wand


Insert the SD Card in the wandboard. Make sure you have connected the display and then boot.

You should get a "android" in the boot screen. After this you will get "Updating apps" dialog and then you will get the standard Android launcher screen.

That is all. I will update this HOWTO if I have missed anything.


5 comments:

  1. hi ,

    I tried compiling the android source 5.0 for wandboard dual and it got compiled. but when I connected to my TV display , it gets stuck in "wandboard" logo .

    Any suggestions ?

    ReplyDelete
  2. @saravanan,

    What errors do you get in the console? I have seen the boot loop happening when you have a corrupted partition or if Android is not able to mount it.

    ReplyDelete
  3. Hi ,

    I did not check after that. Will check and let you know. Now I'm trying to port linux.

    ReplyDelete
  4. Hi,
    you wrote "I created the following partition on my SD card using gparted as the fsl-sdcard-partitions.sh (present in ./device/fsl/common/tools) does not work because of "unsupported option -M" in the recent version of sfdisk."
    Where './device/fsl/common/tools' is placed? Where is it concidered to find?

    ReplyDelete
    Replies
    1. @Derenad: I did not get you. What do you mean by considered to find?

      Delete