March 14, 2012   Posted by: Dr. Ace Jeangle

How to compile Android ICS with touchscreen support

This post was created with valuable help of Zhi Yong Woo and Benjamin Tissoires

OK, lets make our own Android ICS tablet based on PandaBoard and our 10″ LCD bundle. We will use Linaro 12.01 build.

Prerequisites

We will need Ubuntu 11.04 x64 as a host machine. I tried different others hosts including 10.04LTS and 11.10, but only 11.04 x64 gave me working result. You can install your machine in VirtualBox – that’s exactly what I did. Just turn on Intel virtualization (VT-x) option in BIOS an enable it in VirtualBox. Also, you will need around 40 Gbytes of free disk space.

Install required packages
sudo apt-get install git-core gnupg flex bison gperf build-essential \
        zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \
        x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \
        libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \
        libxml2-utils xsltproc libncurses5-dev libreadline6-dev \
        gcc-arm-linux-gnueabi uboot-mkimage
Install Java JDK

Oracle forced to remove Java JDK from standard Ubuntu repository recently. Therefore, we will use small trick to install JDK.

wget https://raw.github.com/flexiondotorg/oab-java6/master/oab-java6.sh -O oab-java6.sh
chmod +x oab-java6.sh
sudo ./oab-java6.sh
sudo apt-get install sun-java6-jdk
Install Linaro image tools
sudo add-apt-repository ppa:linaro-maintainers/tools 
sudo apt-get update 
sudo apt-get install linaro-image-tools
Install Repo tool
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
export PATH=$HOME/bin:$PATH
chmod a+x ~/bin/repo
Download Android source code (Linaro 12.01)
export MANIFEST_REPO=git://android.git.linaro.org/platform/manifest.git 
export MANIFEST_BRANCH=linaro_android_4.0.3 
export MANIFEST_FILENAME=landing-panda.xml
mkdir ~/work
mkdir ~/work/android 
cd ~/work/android 
repo init -u ${MANIFEST_REPO} -b ${MANIFEST_BRANCH} -m ${MANIFEST_FILENAME} 
repo sync

This will download > 2 Gb of sources and will take around one hour (highly depends on your Internet speed).

Download toolchain
cd ~/work 
wget --no-check-certificate http://releases.linaro.org/12.01/components/android/toolchain/4.6/android-toolchain-eabi-linaro-4.6-2012.01-2-2012-01-13_19-04-18-linux-x86.tar.bz2
tar -jxvf android-toolchain-eabi-linaro-4.6-2012.01-2-2012-01-13_19-04-18-linux-x86.tar.bz2
Build source code
cd ~/work/android 
export TARGET_PRODUCT=pandaboard 
export TARGET_SIMULATOR=false 
export TARGET_TOOLS_PREFIX=~/work/android-toolchain-eabi/bin/arm-linux-androideabi-
make TARGET_PRODUCT=${TARGET_PRODUCT} TARGET_TOOLS_PREFIX=${TARGET_TOOLS_PREFIX} HOST_CC=gcc-4.5 HOST_CXX=g++-4.5 HOST_CPP=cpp-4.5 boottarball systemtarball userdatatarball

If you have multi-core processor, then you should try to use “make -jX …” to speed-up compilation. I used “make -j8 …” on my i7 processor. Compilation time highly depends on your computer and can vary from 20 minutes to several hours. So, have another cup of coffee and keep fingers crossed 🙂

Build source code
cd ~/work/android 
export TARGET_PRODUCT=pandaboard 
export TARGET_SIMULATOR=false 
export TARGET_TOOLS_PREFIX=~/work/android-toolchain-eabi/bin/arm-linux-androideabi-
make TARGET_PRODUCT=${TARGET_PRODUCT} TARGET_TOOLS_PREFIX=${TARGET_TOOLS_PREFIX} HOST_CC=gcc-4.5 HOST_CXX=g++-4.5 HOST_CPP=cpp-4.5 boottarball systemtarball userdatatarball

If you have multi-core processor, then you should try to use “make -jX …” to speed-up compilation. I used “make -j8 …” on my i7 processor. Compilation time highly depends on your computer and can vary from 20 minutes to several hours.

Find out the name of your SD card device

Insert SD card and enter the following command:

df -h

You will see the list of storage devices, you should find out which one is your SD card. Mine has name “sdb”, and I will use it in the next command.

Install Android image to SD card
cd ~/work/android/out/target/product/pandaboard 
sudo linaro-android-media-create --mmc /dev/sdb --dev panda --system system.tar.bz2 --boot boot.tar.bz2 --userdata userdata.tar.bz2 
sync

We use here “sdb” as a name of SD card. Now remove SD card and insert it again – you will see several partitions opened in separate windows.

Apply Android binary patch

Insert SD card and enter the following command:

cd ~/work
wget http://releases.linaro.org/12.01/android/images/landing-panda/install-binaries.sh 
chmod a+x install-binaries.sh
./install-binaries.sh /dev/sdb2
sync

Here we again use “sdb” as a name of SD card (2 is added to point to system partition).

Set correct LCD resolution

Go to “/media/boot” folder (this is boot partition of your SD card), open file “boot.txt” and add the following arguments to “setenv bootargs …” string:

omapfb.mode=dvi:[email protected] consoleblank=0

Now save file. And enter the following command to generate boot script:

sudo mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n 'boot script' -d boot.txt boot.scr 
sync

Now we have working Android with correct LCD output, but our touchscreen doesn’t work. Well, that’s right time to recompile kernel to add touchscreen support. Lets’ proceed!

Configure kernel
cd ~work/android/kernel 
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- panda_defconfig 
make ARCH=arm menuconfig 

Now select this driver in configuration menu:

Device Drivers --> HID Devices --> Special HID drivers --> HID Multitouch panels 

Save configuration and exit.

Build kernel and copy to boot partition on SD card
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage
cp ~work/android/kernel/arch/arm/boot/uImage /media/boot
sync

Now we have working touchscreen, but it works really weird – only left top corner is working as projected to whole screen. This is because Android gets HDMI default resolution (1920×1080) and assigns it to touchscreen. Our touchscreen is connected through USB and is considered as “external” device, so Android thinks it is related to HDMI input. Therefore we have to configure touchscreen to be considered as “internal” device (just set parameter . Then Android will assign DVI resolution to it.

Configure touchscreen resolution
  1. Connect Pandaboard to PC with mini-USB cable and run ADB utility (it is available in Android SDK)
  2. Get file from this link Vendor_2087_Product_0a01.idc and put it to your current folder
  3. Enter the following commands to remount Android file system in R/W mode and to copy configuration file:
    adb remount
    adb push Vendor_2087_Product_0a01.idc /system/usr/idc/Vendor_2087_Product_0a01.idc
    adb sync
  4. Restart Pandaboard
  5. You should have fully working touchscreen now.

Here are links to built images, kernel and boot.scr file:
boot.tar.bz2
system.tar.bz2
userdata.tar.bz2
boot.scr
Kernel
Full SD card image (use DD or Win32DiskImage to write to card)

89 comments posted in: How-To