Tuesday, November 10, 2009
Sunday, November 1, 2009
[How-to] install Debian and openssh server in T-Mobile G1
Assume you have installed CynogenMod and get busybox in it, you can install Debian system in G1 or other Android phone that has been rooted and have busybox in that custom ROM.
The instruction of setting up debian in G1 is in saurik's site here http://www.saurik.com/id/10
But some of the information are outdated, as the rooting is very simple now and the busybox comes with all custom cooked ROMs.
I like this method as the Debian system is installed in a standalone img file which can be copied to other Android phones.
(1) Download the Debain G1 image here
http://modmygphone.com/files/debian-G1.zip
or
http://rapidshare.com/files/161776007/debian-armel-750.img.bz2
unzip bz2 file with
bunzip2 debian-armel-750.img.bz2
(2) unzip it and copy the img file to sdcard. The image is 750M in size, so make sure you have enough space in sdcard.
(3) su shell access into G1
(4) setup mount and chroot
(5) change root password and install OpenSSH and start it
(6) If the default package source does not work, you can change this file /etc/apt/sources.list to
(7) if you want to install gcc compiler
(8) exit the debian system
(9) Before you proceed to copy the Debian system to the /system/sd, please consider to check the partition size of /system/sd first. If you want to manually increase the ext2 partition size, please follow this guide below. Please backup before re-partition as the process will wipe your sdcard data.
http://forum.xda-developers.com/showthread.php?t=534714
This how you can backup the /system/sd and sdcard
and this is how you restore data after repartition the sdcard (remember this is when the phone is booted up and not in recovery mode
(10) Reboot G1
(11) Copy the Debian system to /system/sd if you use CynogenMod ROM and have ext2 partition in the sdcard
(12) create the mount script as /system/sd/userinit.sh
append this script if you want to start ssh server automatically
(12) Reboot G1
(13) Then you can ssh to your G1 by using ssh root@xxx.xxx.xxx.xxx after enable wifi in G1, where xxx.xxx.xxx.xxx is the IP address of G1.
This is how you chroot manually when you use adb shell access
The instruction of setting up debian in G1 is in saurik's site here http://www.saurik.com/id/10
But some of the information are outdated, as the rooting is very simple now and the busybox comes with all custom cooked ROMs.
I like this method as the Debian system is installed in a standalone img file which can be copied to other Android phones.
(1) Download the Debain G1 image here
http://modmygphone.com/files/debian-G1.zip
or
http://rapidshare.com/files/161776007/debian-armel-750.img.bz2
unzip bz2 file with
bunzip2 debian-armel-750.img.bz2
(2) unzip it and copy the img file to sdcard. The image is 750M in size, so make sure you have enough space in sdcard.
adb push debian-armel-750.img /sdcard/kit/(3) su shell access into G1
adb shell
su
(4) setup mount and chroot
export kit=/sdcard/kit
export mnt=/data/local/mnt
export TERM=linux
export HOME=/root
export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
busybox clear
busybox mkdir -p $mnt
busybox mount -o loop,noatime $kit/debian-armel-750.img $mnt
busybox mount -t devpts devpts $mnt/dev/pts
busybox mount -t proc proc $mnt/proc
busybox mount -t sysfs sysfs $mnt/sys
busybox mkdir -p $mnt/mnt
busybox mkdir -p $mnt/mnt/sdcard $mnt/mnt/system
busybox mkdir -p $mnt/mnt/data $mnt/mnt/dev
busybox mount --bind /sdcard $mnt/mnt/sdcard
busybox mount --bind /system $mnt/mnt/system
busybox mount --bind /data $mnt/mnt/data
busybox mount --bind /dev $mnt/mnt/dev
busybox mount -t tmpfs tmpfs $mnt/tmp -o noatime,mode=1777
busybox chroot $mnt /bin/bash
# now G1 should be in Debian System
rm -f /etc/mtab
ln -s /proc/mounts /etc/mtab
(5) change root password and install OpenSSH and start it
passwd root
apt-get install debian-keyring debian-archive-keyring
apt-get update
apt-get upgrade
apt-get install openssh-server openssh-client
/etc/init.d/ssh start
(6) If the default package source does not work, you can change this file /etc/apt/sources.list to
deb http://ftp.us.debian.org/debian lenny main
(7) if you want to install gcc compiler
apt-get install build-essential
(8) exit the debian system
exit(9) Before you proceed to copy the Debian system to the /system/sd, please consider to check the partition size of /system/sd first. If you want to manually increase the ext2 partition size, please follow this guide below. Please backup before re-partition as the process will wipe your sdcard data.
http://forum.xda-developers.com/showthread.php?t=534714
This how you can backup the /system/sd and sdcard
adb pull /system/sd/app app
adb pull /system/sd/app-private app-private
adb pull /system/sd/dalvik-cache dalvik-cache
adb pull /sdcard sdcard
and this is how you restore data after repartition the sdcard (remember this is when the phone is booted up and not in recovery mode
adb push app /system/sd/app
adb push app-private /system/sd/app-private
adb push dalvik-cache /system/sd/dalvik-cache
adb push sdcard /sdcard
(10) Reboot G1
reboot(11) Copy the Debian system to /system/sd if you use CynogenMod ROM and have ext2 partition in the sdcard
cd /data/local/mnt
tar cf - . | (cd /system/sd/; tar xvf -)
(12) create the mount script as /system/sd/userinit.sh
export mnt=/system/sd
export TERM=linux
export HOME=/root
busybox mount -t devpts devpts $mnt/dev/pts
busybox mount -t proc proc $mnt/proc
busybox mount -t sysfs sysfs $mnt/sys
busybox mount --bind /sdcard $mnt/mnt/sdcard
busybox mount --bind /system $mnt/mnt/system
busybox mount --bind /data $mnt/mnt/data
busybox mount --bind /dev $mnt/mnt/dev
append this script if you want to start ssh server automatically
busybox chroot /system/sd /etc/init.d/ssh start(12) Reboot G1
reboot(13) Then you can ssh to your G1 by using ssh root@xxx.xxx.xxx.xxx after enable wifi in G1, where xxx.xxx.xxx.xxx is the IP address of G1.
This is how you chroot manually when you use adb shell access
chroot /system/sd /bin/bashThursday, October 29, 2009
Android NDK Makefile
(1) install NDK 1.6 in say
~/Android/android-ndk-1.6_r1
download http://developer.android.com/sdk/ndk/1.6_r1/index.html
(2) install SDK 1.6 in say
~/Android/android-sdk-linux_x86-1.6_r1
download http://developer.android.com/sdk/1.6_r1/index.html
(3) you can compile standalone C program like this hello.c using the Makefile below
(4) Create Makefile
(5) connect device and test using
(6) compile C++ program example1.cpp (no STL)
~/Android/android-ndk-1.6_r1
download http://developer.android.com/sdk/ndk/1.6_r1/index.html
(2) install SDK 1.6 in say
~/Android/android-sdk-linux_x86-1.6_r1
download http://developer.android.com/sdk/1.6_r1/index.html
(3) you can compile standalone C program like this hello.c using the Makefile below
#include <stdio.h>
int main() {
printf("hello, NDK makefile world\n");
return 0;
}
(4) Create Makefile
- Makefile Select all
APP=hello
NDK_DIR := /cygdrive/c/Android/android-ndk-1.6_r1
#NDK_DIR := ~/Android/android-ndk-1.6_r1
NDK_HOST := windows
#NDK_HOST := linux-x86
#NDK_HOST := darwin-x86
SDKTOOL := /cygdrive/c/Android/android-sdk-windows-1.6_r1/tools
#SDKTOOL := ~/Android/android-sdk-linux_x86-1.6_r1/tools
#SDKTOOL := ~/Android/android-sdk-mac_x86-1.6_r1/tools
TOOLCHAIN_PREFIX := $(NDK_DIR)/build/prebuilt/$(NDK_HOST)/arm-eabi-4.2.1/bin/arm-eabi-
CC := $(TOOLCHAIN_PREFIX)gcc
CPP := $(TOOLCHAIN_PREFIX)g++
LD := $(CC)
COMMON_FLAGS := -mandroid -ffunction-sections -fdata-sections -Os -g --sysroot=$(NDK_DIR)/build/platforms/android-4/arch-arm \
-fPIC \
-fvisibility=hidden \
-D__NEW__
CFLAGS := $(COMMON_FLAGS)
CFLAGS += -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -DANDROID -DSK_RELEASE -DNDEBUG
CFLAGS += -UDEBUG -march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fpic -ffunction-sections -funwind-tables -fstack-protector -fmessage-length=0 -Bdynamic
CPPFLAGS := $(COMMON_FLAGS) \
-fno-rtti -fno-exceptions \
-fvisibility-inlines-hidden
LDFLAGS += --sysroot=$(NDK_DIR)/build/platforms/android-4/arch-arm
LDFLAGS += -Bdynamic -Wl,-dynamic-linker,/system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc
LDFLAGS += -L$(NDK_DIR)/build/prebuilt/$(NDK_HOST)/arm-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1/android
LDFLAGS += -L$(NDK_DIR)/build/prebuilt/$(NDK_HOST)/arm-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1
LDFLAGS += -L$(NDK_DIR)/build/prebuilt/$(NDK_HOST)/arm-eabi-4.2.1/lib/gcc
LDFLAGS += -L$(NDK_DIR)/build/prebuilt/$(NDK_HOST)/arm-eabi-4.2.1/arm-eabi/lib
LDFLAGS += -nostdlib -lc -llog -lgcc \
--no-undefined -z $(NDK_DIR)/build/platforms/android-4/arch-arm/usr/lib/crtbegin_dynamic.o $(NDK_DIR)/build/platforms/android-4/arch-arm/usr/lib/crtend_android.o
OBJS += $(APP).o
all: $(APP)
$(APP): $(OBJS)
$(LD) $(LDFLAGS) -o $@ $^
%.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
%.o: %.cpp
$(CPP) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
install: $(APP)
$(SDKTOOL)/adb push $(APP) /data/local/bin/$(APP)
$(SDKTOOL)/adb shell chmod 755 /data/local/bin/$(APP)
run:
$(SDKTOOL)/adb shell /data/local/bin/$(APP)
clean:
@rm -f $(APP).o $(APP)
(5) connect device and test using
make all
make install run
(6) compile C++ program example1.cpp (no STL)
make APP=example1 all install run
- example1.cpp Select all
#include <stdio.h>
class counter {
public:
int some_data;
char some_other_data[100];
int i;
void increment_counter() {i++;}
void decrement_counter() {i--;}
int query_counter() {return i;}
void set_counter(int new_value);
};
void counter::set_counter(int new_value)
{
i = new_value;
}
main()
{
counter apples;
counter oranges;
counter *pointer_to_counter = NULL;
counter array_of_counters[10];
int x = 5;
apples.some_data = x;
apples.set_counter(10);
apples.increment_counter();
apples.increment_counter();
oranges.set_counter(5);
oranges.decrement_counter();
printf("%d apples and %d oranges\n",
apples.query_counter(),
oranges.query_counter());
}
Saturday, October 24, 2009
Android NDK add stlport and compile C++ program
(1) Assume you have Android ndk 1.6 and your ndk directory is in ~/Android/android-ndk-1.6_r1 and you are using mac
download ndk-wrapper from
reference
http://umbel.mooo.com/git?p=ndk-wrappers.git;a=summary
(2) Edit ~/Android/ndk-wrappers/setup.sh and add these
(3) Edit ~/Android/ndk-wrappers/scripts/build-stlport.sh ad add these
(4) Edit ~/Android/ndk-wrappers/scripts/env-utils.sh and change / add these
For linux
HOST=linux-x86
For CYGWIN
HOST=windows
(5) Change ~/Android/ndk-wrappers/stlport/build/lib/android.mak
from
to
(6) Add link
(7) For Mac only, upgrade sed using Mac port
(8) build stlport
(9) Create hello.cpp to test
(10) Compile
(11) Sent to device for testing
You can use Makefile
download ndk-wrapper from
cd ~/Android
git clone git://umbel.mooo.com/ndk-wrappers.git
reference
http://umbel.mooo.com/git?p=ndk-wrappers.git;a=summary
(2) Edit ~/Android/ndk-wrappers/setup.sh and add these
export HOST=darwin-x86
export NDK_DIR=~/Android/android-ndk-1.6_r1
export NDK_WRAPPERS_BASE=~/Android/ndk-wrappers
(3) Edit ~/Android/ndk-wrappers/scripts/build-stlport.sh ad add these
export NDK_WRAPPERS_BASE=~/Android/ndk-wrappers
export PATH=~/Android/ndk-wrappers/bin:$PATH
(4) Edit ~/Android/ndk-wrappers/scripts/env-utils.sh and change / add these
SYSROOT="${NDK_DIR}/build/platforms/android-4/arch-arm"
HOST=darwin-x86
For linux
HOST=linux-x86
For CYGWIN
HOST=windows
(5) Change ~/Android/ndk-wrappers/stlport/build/lib/android.mak
from
--sysroot=$(NDK_DIR)/build/platforms/android-1.5/arch-arm \
to
--sysroot=$(NDK_DIR)/build/platforms/android-4/arch-arm \
(6) Add link
cd ~/Android/ndk-wrappers/stlport/build/Makefiles/gmake
ln -s linux arm-linux
(7) For Mac only, upgrade sed using Mac port
sudo port install gsed
sudo ln -s /opt/local/bin/gsed /opt/local/bin/sed
(8) build stlport
cd ~/Android/ndk-wrappers
export NDK_DIR=~/Android/android-ndk-1.6_r1
./setup.sh
(9) Create hello.cpp to test
#include <iostream>
using namespace std;
int main() {
cout << "hello, world\n";
return 0;
}
(10) Compile
~/Android/ndk-wrappers/bin/arm-linux-g++ -o hello hello.cpp -L~/Android/ndk-wrappers/stlport/build/lib/obj/arm-linux-gcc/so
(11) Sent to device for testing
adb push hello /data/local/bin/hello
adb shell chmod 755 /data/local/bin/hello
adb shell /data/local/bin/hello
You can use Makefile
- Makefile Select all
APP := hello
SDKTOOL := ~/Android/android-sdk-mac_x86-1.6_r1/tools
WRAPPER := ~/Android/ndk-wrappers
STLLIB := -L~/Android/ndk-wrappers/stlport/build/lib/obj/arm-linux-gcc/so
BIN := $(WRAPPER)/bin
CPP := $(BIN)/arm-linux-g++
CC := $(BIN)/arm-linux-gcc
all: $(APP)
OBJS += $(APP).o
$(APP): $(OBJS)
$(CPP) $(LDFLAGS) -o $@ $(STLLIB) $^
%.o: %.c
$(CC) -c $(INCLUDE) $(CFLAGS) $< -o $@
%.o: %.cpp
$(CPP) -c $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $< -o $@
install: $(APP)
$(SDKTOOL)/adb push $(APP) /data/local/bin/$(APP)
$(SDKTOOL)/adb shell chmod 755 /data/local/bin/$(APP)
shell:
$(SDKTOOL)/adb shell
run:
$(SDKTOOL)/adb shell /data/local/bin/$(APP)
clean:
@rm -f $(APP).o $(APP)
Tuesday, October 6, 2009
Sunday, September 13, 2009
default write
Disable iTunes Device backup
defaults write com.apple.iTunes DeviceBackupsDisabled -bool true
defaults write com.apple.iTunes DeviceBackupsDisabled -bool true
Sunday, July 19, 2009
Fix SSH timeout for jailbreak iPhone
Login iPhone and edit /etc/ssh/sshd_config and change the line
from
to
According to man sshd_config, this line,
Sets a timeout interval in seconds after which if no data has been received from the client, sshd(8) will send a message through the encrypted channel to request a response from the client. The default is 0, indicating that these messages will not be sent to the client. This option applies to protocol version 2 only.
Don’t forget to restart sshd on the iPhone after you save the file.
from
#ClientAliveInterval 0to
ClientAliveInterval 60According to man sshd_config, this line,
Sets a timeout interval in seconds after which if no data has been received from the client, sshd(8) will send a message through the encrypted channel to request a response from the client. The default is 0, indicating that these messages will not be sent to the client. This option applies to protocol version 2 only.
Don’t forget to restart sshd on the iPhone after you save the file.
Subscribe to:
Posts (Atom)