Saturday, 13 October 2012

How to build Android CyanogenMod 7.2.0 for Samsung GT-S5570 tass phone from source code in Debian


This article shows how to build CyanogenMod 7.2.0 (Android fork) from source in Debian Sid (October 2012) for a Samsung GT-S5570 (tass) mobile phone.

7.2.0 is the stable CyanogenMod version for tass device.
http://wiki.cyanogenmod.com/wiki/Samsung_Galaxy_Mini

First we create a directory to place everything there:
$ mkdir ~/mydroid
$ cd ~/mydroid


Download Android SDK


The Android SDK will provide us developer tools and libraries necessary to build our Android based system.

http://developer.android.com/sdk/index.html

We choose linux platform and download a tar gz file.

Then to install the Android SDK we uncompress it and export the paths of tools and platforms directories.
$ tar xvzf android-sdk_r20.0.3-linux.tgz
$ export PATH=~/mydroid//android-sdk-linux/tools:~/mydroid/android-sdk-linux/platforms:$PATH


DOWNLOAD ADB TOOL

We have downloaded basic SDK. But it lacks some required tools like adb, etc.

To upgrade Android SDK in console:
$ android update sdk --no-ui

or using a graphical interface
$ android update sdk

It fetches some xml files and starts downloading Android SDK Platform-tools and some documentation.

We export the path to recently added SDK platform-tools:
$ export PATH="~/mydroid/android-sdk-linux/platform-tools:$PATH

Now adb tool is in our PATH.


Install required Debian packages


These packages are needed for both x32 and x64 architectures:
$ sudo aptitude install git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.8-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev default-jdk pngcrush schedtool

For x64 architectures only:
$ sudo aptitude install g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline-dev gcc-4.7-multilib g++-4.7-multilib


Download repo tool and CyanogenMod source code


Repo tool allows us to deal easily with Android source code.

$ mkdir -p ~/mydroid/bin
$ cd ~/mydroid

Download repo:
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > bin/repo
$ chmod a+x bin/repo

Make repo tool visible:
$ export PATH=~/mydroid/bin:$PATH


CyanogenMod source code

$ mkdir -p ~/mydroid/system
$ cd ~/mydroid/system/

We download Android CyanogeMod source code:
$ repo init -u git://github.com/CyanogenMod/android.git -b gingerbread
$ repo sync -j4 # four is the number of processors in my machine. See /proc/cpuinfo to know the number for your machine.

NOTE: Source code size is bigger than 10GB.


Grant usb permission to access the device


We want to access the phone device as a standard user when it gets connected to the computer.

Each model is identified by vendor and product identifiers.
For Samsung GT-S5570 tass device:
idVendor=04e8, idProduct=689e

You can see them in /var/log/syslog when you connect the device.


To grant permissions we will as root create or edit this file: /etc/udev/rules.d/51-android.rules.

As root execute: (change YOUR_USER_NAME by your user name).
# echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="689e", MODE="0600", OWNER="YOUR_USER_NAME"' >> /etc/udev/rules.d/51-android.rules

# chmod a+r /etc/udev/rules.d/51-android.rules

# udevadm control --reload-rules


Once we get right permissions we can access into the device:
$ adb devices
* daemon not running. starting it now on port 5037 *
 * daemon started successfully *
List of devices attached 
S5570560ee3ab   device

Adb daemon will start and show your device.


Extract proprietary code


Next step consists on extracting some proprietary blobs from an actual running phone.

Your device has to be already connected to the computer.

In current CyanogenMod source code tass device directory is not downloaded by default.

So we get samsung tass device source code:
$ cd ~/mydroid/system
$ build/tools/roomservice.py samsung_tass
device/samsung/tass directory appears.

$ cd device/samsung/tass
$ ./extract-files.sh
It complains about this in my system:
remote object '/system/lib/libOmxEvrcDec.so' does not exist
remote object '/system/lib/libOmxQcelpDec.so' does not exist

To get them I clone another repository:
$ cd ~/mydroid
$ git clone --depth 1 https://github.com/teamhacksung/proprietary_vendor_samsung.git

And copy those files to right places:
$ cp proprietary_vendor_samsung/tass/proprietary/lib/libOmxEvrcDec.so ~/mydroid/system/vendor/samsung/tass/proprietary/lib/ -v
$ cp proprietary_vendor_samsung/tass/proprietary/lib/libOmxQcelpDec.so ~/mydroid/system/vendor/samsung/tass/proprietary/lib/ -v


Download rom manager


$ cd ~/mydroid/system/vendor/cyanogen
$ ./get-rommanager


Build images


In the end it is time to build the images and create zipped ROMs.

$ cd ~/mydroid/system
$ repo sync # Download latest changes in source code.

Build the system:
$ . build/envsetup.sh
$ brunch tass # if we would have not already downloaded tass source code it would try to download it in this step.

In the end ROMs are created:
Package complete: ~/mydroid/system/out/target/product/tass/cm-7-20121005-UNOFFICIAL-tass.zip
ae351bb752becfd72a5af7efea7698cd  cm-7-20121005-UNOFFICIAL-tass.zip cyanogen_tass-ota-eng.whatever.zip

You can upload cm-7-20121005-UNOFFICIAL-tass.zip in your SD card, reboot your device into recovery mode and flash it!


REFERENCE


Samsung Galaxy S II: Compile CyanogenMod (Linux)


YOU MAY ALSO BE INTERESTED IN:


How to BUILD the LINUX KERNEL for the ANDROID EMULATOR (Eclair version)

Building Android in Debian Sid

0 comentarios: