Monday, October 29, 2012

Script to on/off touchpad on Ubuntu 12.04

I wrote this is for workaround for those touchpad button & fn key is not working.

1 )  Create file ~/ with content below.


off=`sudo synclient |grep TouchpadOff |cut -c30-35`

if [ $off -eq 0 ] ;then
echo 'turnoff touchpad';
sudo synclient TouchpadOff=1
echo 'turnon touchpad';
sudo synclient TouchpadOff=0

2 ) sudo chmod +x ~/

3 ) Adding shortcut by launch Settings > Keyboard, go to tab 'Shorcuts'
 Click '+' icon for adding new shortcut.
Name: Touchpad On/Off
Shortcut: sudo ~/
Click 'Apply', then click on Disable to select shortcut key, my case is Super+f9 since Fn will not work here.

4 ) Grant permission
adding line below to sudoer and replace <user> to your username.
<user> ALL = (ALL) NOPASSWD: /home/<user>/


Thursday, October 25, 2012

Install Busybox for Jellyebean

1. Download files:

2. Create dir

$ mkdir -p META-INF/com/google/android/
$ mkdir -p system/bin/busybox

You should get something like this...

│   └── com
│       └── google
│           └── android
│               ├── update-binary
│               └── updater-script
└── system
    └── bin
        └── busybox

3. Move the file, you need 'update-binary', updater-script from other
$ mv busybox-armv6l busybox/system/bin/busybox

4. Update the updater-script with content below :
ui_print("Busybox 1.19.0 for Android 2.0-4.1 arm");
ui_print("Mounting system...");
run_program("/sbin/busybox", "mount", "/system");
ui_print("Deleting old files...");
ui_print("Copying files...");
package_extract_dir("system", "/system");
ui_print("Fixing permissions...");
set_perm(0, 0, 06755, "/system/bin/busybox");
symlink("/system/bin/busybox", "/system/xbin/busybox");
ui_print("Unmounting system...");
run_program("/sbin/busybox", "umount", "/system");
ui_print("Installation complete!");

5. Zip & Signed
$ keytool -genkey -v -alias mw_apk_signed_key -keyalg RSA -keysize 2048 -validity 10000 -keystore .keystore

$ jarsigner -verbose -keystore .keystore mw_apk_signed_key
Enter Passphrase for keystore: 
   adding: META-INF/MW_APK_S.SF
   adding: META-INF/MW_APK_S.RSA
   adding: system/bin/
  signing: system/bin/busybox

6. Install
$ adb push /sdcard/
$ adb reboot recovery

Install the from recovery....

Monday, October 22, 2012

Subclipse with 32bit Eclipse on 64bit host

# wget
# dpkg -x libsvn-java_1.7.5-1ubuntu2_i386.deb  .
# mkdir -p /usr/lib32/jni
# cp -P ./usr/lib/i386-linux-gnu/jni/* /usr/lib32/jni/
# nano /opt/eclipse-cpp-indigo-SR2/eclipse.ini
add following line, '-Djava.library.path=/usr/lib32/jni'.

Build CM10 from source for Galaxy S2 (i9100)

1. Basic env setup is needed before head to CM site, please follow the instructions HERE to setup the build env.

2. Downloading source from github.

$ mkdir /opt/android/cm
$ cd /opt/android/cm
$ repo init -u git:// -b jellybean
$ repo sync -j4

3. Copy proprietary files from your device, assume you have android-sdk installed, if you don't please proceed to for details.

create ~/android/system/.repo/local_manifest.xml using this content:

<?xml version="1.0" encoding="UTF-8"?>
  <project name="teamhacksung/buildscripts" path="buildscripts" remote="github" revision="jellybean">
    <copyfile dest="" src="" />

$ repo sync -j4
$ . build/

$ lunch

You're building on Linux

Lunch menu... pick a combo:
     1. full-eng
     2. full_x86-eng
     3. vbox_x86-eng
     4. mini_armv7a_neon-userdebug
     5. mini_armv7a-userdebug
     6. full_panda-userdebug
     7. cm_a700-userdebug
     8. cm_captivatemtd-userdebug
     9. cm_crespo-userdebug
     10. cm_crespo4g-userdebug
     11. cm_d2att-userdebug
     12. cm_d2spr-userdebug
     13. cm_d2tmo-userdebug
     14. cm_d2usc-userdebug
     15. cm_d2vzw-userdebug
     16. cm_endeavoru-userdebug
     17. cm_epicmtd-userdebug
     18. cm_everest-userdebug
     19. cm_evita-userdebug
     20. cm_fascinatemtd-userdebug
     21. cm_galaxysmtd-userdebug
     22. cm_galaxysbmtd-userdebug
     23. cm_grouper-userdebug
     24. cm_hercules-userdebug
     25. cm_i777-userdebug
     26. cm_i9100-userdebug
     27. cm_i9100g-userdebug
     28. cm_i9300-userdebug
     29. cm_jewel-userdebug
     30. cm_mint-userdebug
     31. cm_maguro-userdebug
     32. cm_mesmerizemtd-userdebug
     33. cm_n7000-userdebug
     34. cm_n8000-userdebug
     35. cm_n8013-userdebug
     36. cm_quincyatt-userdebug
     37. cm_quincytmo-userdebug
     38. cm_p1-userdebug
     39. cm_p1c-userdebug
     40. cm_p1l-userdebug
     41. cm_p1n-userdebug
     42. cm_p3100-userdebug
     43. cm_p3110-userdebug
     44. cm_p3113-userdebug
     45. cm_p5100-userdebug
     46. cm_p5110-userdebug
     47. cm_p5113-userdebug
     48. cm_p930-userdebug
     49. cm_p970-userdebug
     50. cm_skyrocket-userdebug
     51. cm_stingray-userdebug
     52. cm_su640-userdebug
     53. cm_tf101-userdebug
     54. cm_tf201-userdebug
     55. cm_tf300t-userdebug
     56. cm_toro-userdebug
     57. cm_toroplus-userdebug
     58. cm_t769-userdebug
     59. cm_vibrantmtd-userdebug
     60. cm_ville-userdebug
     61. cm_wingray-userdebug

Which would you like? [full-eng] 26

I pick (26cd vemd), i9100...., wait until the repo synced.

$ cd device/samsung/i9100/
$ ./

3. Build.
$ cd ../../..
$ . / i9100
$ cd out/target/product/i9100/
$ adb push /sdcard/
$ adb reboot recovery

Flash the update with CWM-Recovery.


Friday, October 19, 2012

Android profiling with ARM Streamline

Configs :

1. Getting kernel source for Nexus S.
$mkdir ~/android
$cd android
$ git clone

2. Checkout the source.

$ git branch -r
  origin/HEAD -> origin/master

$git checkout android-samsung-2.6.35-gingerbread origin/android-samsung-2.6.35-gingerbread

3. Export prebuild toolchanin & build vars...
$export PATH=<SDK_PATH>/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin:$PATH

$export ARCH=arm
$export SUBARCH=arm
$export CROSS_COMPILE=arm-eabi-

4. Compile kernel and gator module.

$ make herring_defconfig

arch/arm/configs/herring_defconfig:323:warning: override: reassigning to symbol LOCALVERSION_AUTO
arch/arm/configs/herring_defconfig:333:warning: override: reassigning to symbol NET_ACTIVITY_STATS
# configuration written to .config
#herring_defconfig is config for NEXUS S, use 'make help' to find out your device config

$nano .config
Ensure the parameters below is set.

$ make -j4 CROSS_COMPILT=arm-eabi- uImage
  CHK     include/linux/version.h
  CHK     include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
  CALL    scripts/
  CHK     include/generated/compile.h
  Kernel: arch/arm/boot/Image is ready
  SHIPPED arch/arm/boot/compressed/lib1funcs.S
  AS      arch/arm/boot/compressed/lib1funcs.o
  LD      arch/arm/boot/compressed/vmlinux
  OBJCOPY arch/arm/boot/zImage
  Kernel: arch/arm/boot/zImage is ready
  UIMAGE  arch/arm/boot/uImage
Image Name:   Linux-
Created:      Thu Sep 27 13:36:20 2012
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    3017840 Bytes = 2947.11 kB = 2.88 MB
Load Address: 30008000
Entry Point:  30008000
  Image arch/arm/boot/uImage is ready

5. Build Gator module

Install DS-5 module for Eclipse, detail please refer to HERE.


Download DS-5 from

6. After install.....go Eclipse Help-> ARM Extras, explore pop out.....
navigate to 'driver-src', extract 'gator-driver.tar.gz'.. to kernel dir.

$ cd gator-driver/
$ make -C path/to/kernel  M=`pwd`  modules
$ cd ..
$ adb pull /sdcard/init.rc /path/to/sdk/tools/

7. go Eclipse Help-> ARM Extras, explore pop out.....
navigate to 'daemon-src'.

$ mkdir /path/to/arm/gator/android
$ cp /path/to/arm/gator/daemon-src/gator-daemon/gator-daemon.tar.gz /path/to/arm/gator/android/
$ tar -zxvf gator-daemon.tar.gz
$ mv gator-daemon jni

$ ndk-build
Compile++ thumb  : gatord <= CapturedXML.cpp
Compile++ thumb  : gatord <= Child.cpp
Compile++ thumb  : gatord <= Collector.cpp
Compile++ thumb  : gatord <= ConfigurationXML.cpp
Compile++ thumb  : gatord <= Fifo.cpp
Compile++ thumb  : gatord <= LocalCapture.cpp
Compile++ thumb  : gatord <= Logging.cpp
Compile++ thumb  : gatord <= main.cpp
Compile++ thumb  : gatord <= OlySocket.cpp
Compile++ thumb  : gatord <= OlyUtility.cpp
Compile++ thumb  : gatord <= Sender.cpp
Compile++ thumb  : gatord <= SessionData.cpp
Compile++ thumb  : gatord <= SessionXML.cpp
Compile++ thumb  : gatord <= StreamlineSetup.cpp
Compile thumb  : gatord <= mxml-attr.c
Compile thumb  : gatord <= mxml-entity.c
Compile thumb  : gatord <= mxml-file.c
Compile thumb  : gatord <= mxml-get.c
Compile thumb  : gatord <= mxml-index.c
Compile thumb  : gatord <= mxml-node.c
Compile thumb  : gatord <= mxml-private.c
Compile thumb  : gatord <= mxml-search.c
Compile thumb  : gatord <= mxml-set.c
Compile thumb  : gatord <= mxml-string.c
StaticLibrary  : libstdc++.a
Executable     : gatord
Install        : gatord => libs/armeabi/gatord

8.  Copy gatord to device.
# adb push gatord /sdcard/
# adb push gator.ko /sdcard/
# adb shell

# su
# mount -o remount,rw -t yaffs2 /dev/block/mtdblock4 /system
# mv /sdcard/gatord /system/xbin/
# mv /sdcard/gator.ko /system/xbin/

# mount -o ro,remount -t yaffs2 /dev/block/mtdblock4 /system
# sync
# reboot

9. After device boot up.

# adb shell 
# su
# gatord &

10.  Profiling Android phone with Streamline
Streamline supports connection to your target using Ethernet. Using the Android Debug Bridge (ADB) utility, it is possible to forward a TCP port from the target to your PC localhost over a USB connection. ADB can also be configured to work over Ethernet or Wi-Fi. For more information about the Android SDK and ADB setup, see the Android website. Once ADB is set up, forward the Streamline port to your localhost using the following command:

# adb forward tcp:8080 tcp:8080

Now run DS-5 on your PC and open the Streamline Data View. If it is not visible from the Window->Show View menu, select Window->Show View->Other; find “ARM Streamline” in the dialog box and open “ARM Streamline Data”. Enter the device’s Ethernet address in the Capture Options dialog box of the ARM Streamline Data view in Eclipse or DS-5. If you use the Android Debug Bridge (ADB) over USB to forward the port, enter localhost in the Address field.

[src] :

Compile Android Kernel

1. First thing is find out kernel version used for your device, assume you already downloaded the source from AOSP.

$ cd /android/android-2.3.6_r0.9/device/samsung/crespo

$ git log kernel
commit c85d206feeedd1ee1c69d0e0fe9e529897a5288b
Author: JP Abgrall <>
Date:   Tue Aug 2 13:47:09 2011 -0700

    kernel + wifi update: gpu only
      21fb4cb gpu: pvr: Update to DDK
    Change-Id: I9d728a27256486ba0d2e39211d06ef7f2ebeab6b
    Signed-off-by: JP Abgrall <>

commit 7af59186753f2c08ed4123e0d2693d0e11f48410
Author: Simon Wilson <>
Date:   Wed Jun 8 19:15:05 2011 -0700

    update kernel
    3cc95e3 net: Reorder incoming packets in PPPoLAC and PPPoPNS.
    3128bc4 jbd2: fix fsync() tid wraparound bug
    Change-Id: If6a22a320491d52ccbe6abb97acf5e97886fe144

commit 7643328cd8f7eabbf2fed86899b1758308bb747a
Author: JP Abgrall <>
Date:   Thu May 26 19:50:48 2011 -0700

    Revert "Custom kernel with data-usage support and persistence."
    This reverts commit 6a0bcab7b1eb1ca53dd26127ed623e23eeff70a9.

commit 6a0bcab7b1eb1ca53dd26127ed623e23eeff70a9
Author: JP Abgrall <>
Date:   Thu May 26 19:50:27 2011 -0700

    Custom kernel with data-usage support and persistence.
    This is for a one-time build of Gingerbread MR3.
    Not for release.
    This kernel is based on;a=shortlog;h=refs%2Fheads%2Fandroid-samsung-2.6.35-gingerbread
       at commit 807fb588280ee28833ea7838e6fa79b9b14f66c1
     with the needed iface_stat, udp, ... changes on top:,21605,21093
    Change-Id: I558a7f14258c3d6c497995880356bc5a4106de62
    Signed-off-by: JP Abgrall <>

commit 830fe0120276f51fc9bf5872ff190bae6839eb4b
Author: Simon Wilson <>
Date:   Thu May 26 16:28:34 2011 -0700

    update kernel
    807fb58 net: wimax: wimax_status mismatch fixed.
    Change-Id: Ide8950f3f5db57e25e4b0682e181c8cb95717cd4

commit 794ceba05495001fe2bf495b23a76acb5263da17
Author: Simon Wilson <>
Date:   Wed May 25 14:47:58 2011 -0700

    update kernel

The log should contain notes of the commit SHA1 for the appropriate kernel project. Keep this value at hand so that you can use it in a later step.

2. Downloading sources

$ git clone
$ cd samsung/

Display the branch

$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
$ git checkout -b android-samsung-2.6.35-gingerbread origin/android-samsung-2.6.35-gingerbread

Checking out files: 100% (33879/33879), done.
Branch android-samsung-2.6.35-gingerbread set up to track remote branch android-samsung-2.6.35-gingerbread from origin.
Switched to a new branch 'android-samsung-2.6.35-gingerbread'

3. Assume Android-NDK is installed , if not please refer to NDK install page.

4. Setup Env

$export PATH=<android source>/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin:$PATH
$export ARCH=arm
$export SUBARCH=arm
$export CROSS_COMPILE=arm-eabi-

4. Setup default config

$ make herring_defconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/basic/docproc
  HOSTCC  scripts/basic/hash
  HOSTCC  scripts/kconfig/conf.o
scripts/kconfig/conf.c: In function ‘conf_sym’:
scripts/kconfig/conf.c:159:6: warning: variable ‘type’ set but not used [-Wunused-but-set-variable]
scripts/kconfig/conf.c: In function ‘conf_choice’:
scripts/kconfig/conf.c:231:6: warning: variable ‘type’ set but not used [-Wunused-but-set-variable]
scripts/kconfig/conf.c:307:9: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
scripts/kconfig/conf.c: In function ‘conf_askvalue’:
scripts/kconfig/conf.c:105:8: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
  HOSTCC  scripts/kconfig/kxgettext.o
  SHIPPED scripts/kconfig/
  SHIPPED scripts/kconfig/lex.zconf.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/
  HOSTLD  scripts/kconfig/conf
arch/arm/configs/herring_defconfig:323:warning: override: reassigning to symbol LOCALVERSION_AUTO
arch/arm/configs/herring_defconfig:333:warning: override: reassigning to symbol NET_ACTIVITY_STATS
# configuration written to .config

5. Compile
$ make -j4

  CC      arch/arm/boot/compressed/decompress.o
  SHIPPED arch/arm/boot/compressed/lib1funcs.S
  AS      arch/arm/boot/compressed/lib1funcs.o
  CC      crypto/ansi_cprng.mod.o
  CC      drivers/net/wireless/bcm4329/bcm4329.mod.o
  CC      drivers/scsi/scsi_wait_scan.mod.o
  LD [M]  crypto/ansi_cprng.ko
  LD [M]  drivers/net/wireless/bcm4329/bcm4329.ko
  LD [M]  drivers/scsi/scsi_wait_scan.ko
  AS      arch/arm/boot/compressed/piggy.gzip.o
  LD      arch/arm/boot/compressed/vmlinux
  OBJCOPY arch/arm/boot/zImage
  Kernel: arch/arm/boot/zImage is ready

 $ cp arch/arm/boot/zImage ../../../android/android-2.3.6_r0.9/device/samsung/crespo/kernel

6. Flash to device....
$ cd <android src>
$ make -j4
$ fastboot flash -w

Compile Android Error

find: `frameworks/base/frameworks/base/docs/html': No such file or directory
find: `out/target/common/docs/gen': No such file or directory
find: `frameworks/base/frameworks/base/docs/html': No such file or directory
find: `out/target/common/docs/gen': No such file or directory
find: `frameworks/base/frameworks/base/docs/html': No such file or directory
find: `out/target/common/docs/gen': No such file or directory
find: `frameworks/base/frameworks/base/docs/html': No such file or directory
find: `out/target/common/docs/gen': No such file or directory
find: `frameworks/base/frameworks/base/docs/html': No such file or directory
find: `out/target/common/docs/gen': No such file or directory
Install: out/host/linux-x86/framework/apicheck.jar
Install: out/host/linux-x86/framework/clearsilver.jar
Install: out/host/linux-x86/framework/droiddoc.jar
Install: out/host/linux-x86/lib/
Install: out/host/linux-x86/lib/
Install: out/host/linux-x86/lib/
Install: out/host/linux-x86/lib/
Copying: out/target/common/obj/JAVA_LIBRARIES/core_intermediates/emma_out/lib/classes-jarjar.jar
Install: out/host/linux-x86/framework/dx.jar
Install: out/host/linux-x86/bin/dx
host C++: libutils <= frameworks/base/libs/utils/RefBase.cpp
<command-line>:0:0: warning: "_FORTIFY_SOURCE" redefined [enabled by default]
<built-in>:0:0: note: this is the location of the previous definition
frameworks/base/libs/utils/RefBase.cpp: In member function ‘void android::RefBase::weakref_type::trackMe(bool, bool)’:
frameworks/base/libs/utils/RefBase.cpp:483:67: error: passing ‘const android::RefBase::weakref_impl’ as ‘this’ argument of ‘void android::RefBase::weakref_impl::trackMe(bool, bool)’ discards qualifiers [-fpermissive]
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] Error 1

 # gedit frameworks/base/libs/utils/
Add '-fpermissive' after  "LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) ".

# make -j4

Until another error came up.

# gedit  /build/core/combo/



repo forall -c 'git tag -d android-2.3.3_r1 && git fetch' 

# make -j4 

$ fastboot flashall -w
Bootloader Version...: I9020XXKA3
Baseband Version.....: I9020XXKF1
Serial Number........: 36300317D10EC
checking product...
OKAY [  0.001s]
checking version-bootloader...
OKAY [  0.001s]
checking version-baseband...
OKAY [  0.001s]
sending 'boot' (2936 KB)...
OKAY [  0.445s]
writing 'boot'...
OKAY [  0.379s]
sending 'recovery' (3176 KB)...
OKAY [  0.483s]
writing 'recovery'...
OKAY [  0.407s]
sending 'system' (107922 KB)...
OKAY [ 16.756s]
writing 'system'...
OKAY [ 15.917s]
erasing 'userdata'...
OKAY [  0.204s]
formatting 'userdata' partition...
Erase successful, but not automatically formatting.
Can't determine partition type.
OKAY [  0.001s]
erasing 'cache'...
OKAY [  2.009s]
formatting 'cache' partition...
Erase successful, but not automatically formatting.
Can't determine partition type.
OKAY [  0.001s]

Install JDK6 on Ubuntu 12.04

1. Download binary file from


2. Switch to root.
$ sudo -s

3. Move the file to JVM dir.
# cd /usr/lib/jvm/
# mv ~/Downloads/jdk-6u37-linux-x64.bin ./
# sh jdk-6u37-linux-x64.bin

4. Dir jdk1.6.0_37 is extracted, now install using update-alternatives
update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_37/bin/java 1000
update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_37/bin/javac 1000
update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.6.0_37/bin/javaws 1000

5. #update-alternatives --config java
Choose the option that you just installed.

6. Verify.
# java -version
java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01, mixed mode)

Wednesday, October 17, 2012

svnjavahl not found ubuntu 12.04

In version 12.04, lib path for native lib is changed to /usr/lib/x86_64-linux-gnu/jni,

I'set "-Djava.library.path=/usr/lib/x86_64-linux-gnu/jni" (on 64 bit installation) in eclipse.ini