Build adb for Loongson(MIPS)

Henceforth it will be more easy to debug Android device on Loongson. I will tell you how to build adb for Loongson (MIPS).

Step 1: Clone source code from git repos

git clone

Step 2: Write a standalone Makefile

vim core/adb/Makefile
# Makefile for adb
SRCS+= adb.c
SRCS+= adb_client.c
SRCS+= commandline.c
SRCS+= console.c
SRCS+= file_sync_client.c
SRCS+= fdevent.c
SRCS+= get_my_path_linux.c
SRCS+= services.c
SRCS+= sockets.c
SRCS+= transport.c
SRCS+= transport_local.c
SRCS+= transport_usb.c
SRCS+= usb_linux.c
SRCS+= usb_vendors.c
SRCS+= utils.c
VPATH+= ../libcutils
SRCS+= abort_socket.c
SRCS+= socket_inaddr_any_server.c
SRCS+= socket_local_client.c
SRCS+= socket_local_server.c
SRCS+= socket_loopback_client.c
SRCS+= socket_loopback_server.c
SRCS+= socket_network_client.c
VPATH+= ../libzipfile
SRCS+= centraldir.c
SRCS+= zipfile.c
CPPFLAGS+= -I../include
CPPFLAGS+= -I../../../external/zlib
CFLAGS+= -O2 -Wno-unused-parameter
LIBS= -lrt -lpthread -lz
TOOLCHAIN= mipsel-unknown-linux-gnu-
OBJS= $(SRCS:.c=.o)
all: adb
adb: $(OBJS)
	$(LD) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)
	rm -rf $(OBJS)

Step 3: Build

cd core/adb


How to force HTC Desire CDMA in CDMA 1x mode?

1. Backup old rom via ClockMod recovery.
2. Flash to Offical stock rom. (I’m using ‘2.11.573.5_USCC’ without radio)
3. Input ‘##778#’ at dial pad to run ‘EPST’ in this ROM.
4. Select ‘Edit mode’.
5. Input password, default is ‘000000’.
6. Go to ‘Modem Settings’.
7. Set ‘Preferred Mode’ = ‘CDMA only’.
8. Set ‘HDR Hybrid Preferred’ = ‘Disable’.
9. Press the ‘Menu’ button at bottom of phone.
10. Tap on ‘Commit Modifications’.
11. Press ‘OK’ to reboot phone.
12. Restore ‘CM’ rom.


How to configure OpenVPN on Android CyanogenMod

I just tested this on my old Google G1(Dream) with CyanogenMod 6.0.2(RC), and I think it could apply on other CyanogenMod rom with OpenVPN GUI.

Not like OpenVPN on Windows or Linux which needs a config folder holding separate keys and certificates, on CyanogenMod, the OpenVPN GUI needs a PKCS12 compressed file to perform importing actions.

Lets say you have got the three files: client.key, client.cert and ca.cert, then you could compress them into a single PKCS12 file by running the following command(Linux):

openssl pkcs12 -export -in [PathToClientCert] -inkey [PathToClientKey] -certfile [PathToCACert] -name [FriendlyName] -out certs.p12

Be sure to replace all the [PathTo**] with appropriate path to your files. On Windows, you could using “openssl.exe”.

Once you got the PKCS12 file, copy it to your Android SDCARD root, and go to “Settings › Security and location”, and then select “Import from SDCARD”.

After importing, you could go to “Wireless > VPN Settings”, and create a new OpenVPN connection and do your stuff.

BTW. You should configure OpenVPN on Android carefully according to the configuration file from Linux or Windows, something important like key-size and encryption method may result very differently, check them by tap “Menu > Advanced settings” in OpenVPN GUI.


Ubuntu 10.04 系统上构建 Android 应用开发环境

安装 JDK
从源里安装 OpenJDK

sudo apt-get install openjdk-6-jdk

下载、安装 Android SDK

cd ~
tar xzf android-sdk_r08-linux_86.tgz
mv android-sdk_r08-linux_86 asdk
test -e bin || mkdir bin
cd bin
find ../asdk/tools -maxdepth 1 -type f -executable -exec ln -s {} \;
find ../asdk/platform-tools -maxdepth 1 -type f -executable -exec ln -s {} \;

安装、升级 Android 平台



创建 AVD

android create avd -n Android -t 1 -c 100M

安装 Ant

sudo apt-get install ant1.8

至此,再安装一个自己喜欢的代码编辑器(如 vim )就完成开发环境的建立。

创建、编译和调试 Hello World!

# 创建项目
android create project --package --activity HelloAndroid --target 1 --path HelloAndroid
# 编译调试版本
cd HelloAndroid
ant debug
# 进行模拟器
emulator -avd Android
# 安装 Hello World 程序到模拟器
adb -s emulator-5554 install bin/HelloAndroid-debug.apk


Terminal for CM 6 ROM

CM 6 集成的终端程序在普通用户权限下无法访问存储卡和网络,这个对权限做了一些修改。



mount -o remout,rw /system
cp /sdcard/Term.apk /system/app/Term.apk
chmod 644 /system/app/Term.apk
mount -o remount,ro /system


另类安装 Apk 方法

由于不喜安装一些 ApkManager,又需要安装 /sdcard 里的 apk。我采用了下面的方法。

例如安装 /sdcard/mobileqq.apk,打开手机终端,执行如下命令

httpd -f -p 8000 -h /sdcard

在浏览器里下载 http://localhost:8000/mobileqq.apk,完成后点击安装即可。