Tuesday, November 26, 2013

Nexus 4 Rooting from source code


Intro

There are so many documents dealing with rooting Android devices. But most of webpages describe it using binaries already pre-built by Hacker groups. It is not enough for rookies who want to build their own binaries from source code, kernel to user level. This manual is written for them.

Before Rooting we need to prepare to restore original release binaries. We can get full binary images and vendor specific driver binaries for custom build from here: https://developers.google.com/android/


Android web pages(http://source.android.com/index.html) already contain all information. I just added comments dedicated to Nexus 4 and re-arrange their order.

Sunday, November 24, 2013

Install java6 jdk from oracle binary instead of using "apt-get install sun-java6-jdk"


For Android platform development, we need java6.
But the guide is outdated. "sun-java6-jdk" is deprecated! ;-(

We have to find another way.


First of all, we need oracle java6 jdk binary.

The url is Oracle download page. You need your account on oracle.com for downloading it.
http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html#jdk-6u45-oth-JPR




tmax@tmax3:~/work/android$ chmod +x jdk-6u45-linux-x64.bin
tmax@tmax3:~/work/android$ ./jdk-6u45-linux-x64.bin
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
replace jdk1.6.0_45/db/bin/ij? [y]es, [n]o, [A]ll, [N]one, [r]ename: A
  inflating: jdk1.6.0_45/db/bin/ij
  inflating: jdk1.6.0_45/db/bin/NetworkServerControl
  inflating: jdk1.6.0_45/db/bin/setNetworkClientCP.bat
  inflating: jdk1.6.0_45/db/bin/setEmbeddedCP.bat
  inflating: jdk1.6.0_45/db/bin/stopNetworkServer.bat
...

I set up my  environment by following (https://help.ubuntu.com/community/Java#Oracle_.28Sun.29_Java_6
 ). But I failed. Compiling failed with the error message below.
host Java: jsilver (out/host/common/obj/JAVA_LIBRARIES/jsilver_intermediates/classes)
Note: external/jsilver/src/org/clearsilver/FactoryLoader.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
jar: internal error:
java.io.FileNotFoundException: -C (No such file or directory)
   at gnu.java.nio.channels.FileChannelImpl.open(libgcj.so.12)
   at gnu.java.nio.channels.FileChannelImpl.<init>(libgcj.so.12)
   at gnu.java.nio.channels.FileChannelImpl.create(libgcj.so.12)
   at java.io.FileInputStream.<init>(libgcj.so.12)
   at gnu.classpath.tools.jar.Creator.writeFile(libgcj-tools.so.12)
   at gnu.classpath.tools.jar.Creator.writeCommandLineEntries(libgcj-tools.so.12)
   at gnu.classpath.tools.jar.Creator.writeCommandLineEntries(libgcj-tools.so.12)
   at gnu.classpath.tools.jar.Updater.run(libgcj-tools.so.12)
   at gnu.classpath.tools.jar.Main.run(libgcj-tools.so.12)
   at gnu.classpath.tools.jar.Main.main(libgcj-tools.so.12)
make: *** [out/host/common/obj/JAVA_LIBRARIES/jsilver_intermediates/javalib.jar] Error 1
make: *** Deleting file `out/host/common/obj/JAVA_LIBRARIES/jsilver_intermediates/javalib.jar'

The guide use "update-alternatives" utility for manual setup ("manual" means not-using-apt-get). It looks fancy. But something is wrong: conflict with pre-installed gcj java(GNU Compiler for Java). I could not fix it up. No idea about "update-alternatives".

So I just followed ( http://www.arndaleboard.org/wiki/index.php/O_WiKi#Installing_the_JDK). I set PATH=$JAVA_HOME/bin:$PATH in .bashrc. The site gave good resource.


Wednesday, November 13, 2013

Disk data backup using dd

Yesterday I saw the message pop-up "Hard driver failure blah blah ~". "Smart Data" utility said that replace my hard drive immediately.

Main reason is "reallocated sector count warning". increasing Bad sector.

There are so many posting about this issue





Most of posting recommend that I should replace my hard disk immediately. Only few postings say the warning can be handled by recent system, so I can use my disk longer before more crucial waning occurs. But they also recommend data backup.

So I decided to replace my HDD. Because I'm not busy, I thought that I did it relaxedly.


My colleague recommended to use "dd"(disk dump") This tool clones a HDD as a block device, so I don't need to re-install OS.

I accepted his advice. I insert a new HDD and old one with same bland & same size but different versions.  And I type the following command

dd if=/dev/sdb of=/dev/sda

I regretted my decision. Because dd is not gui tool, there is no fancy display, so I could not check current status.

I asked the colleague How long it will take. He don't know it!!! He just knew about that, did not have used it.
I'm upset. What I could do was just watching "dd"'s CPU occupation info using "top". It was steadily 30%. I tried to search for information of the performance of "dd" command on the webs. but I found nothing.

It took 28800 seconds, almost 8 hours for cloning 1 TB !!!!!

I didn't do any thing yesterday!!!

One of my friend recommends to use "bs=1m" option for "dd". And another colleague recommends a specialized hardware cloning HDD called "clone1". It's chip and fast and can be used as a external HDD adapter.