My native hello world segfaults everytime - Android Software/Hacking General [Developers Only]

Hello all,
Just got my first android phone. I need to port a tiny C application I have to my phone. It worked when I compiled a static binary but now I'm trying to compile a dynamic one, but before that, I'm trying to run a native hello world on it but not having much luck. When I run it on the emulator, it prints "Hello world" and then segfaults after that. When I run it on the phone, it doesn't even get that far. It says link_image[1995] CANNOT LINK EXECUTABLE.
These are my test files
<I had to remove it. It triggered the spam detection even though I didn't try to post any outside links :/>

test.c
Code:
#include <stdio.h>
int main (int argc, char *argv[])
{
printf ("Hello world!\n");
return 0;
}

Makefile
Code:
APP := test
ROOT:=$(HOME)/Projects/Android
NDK_PLATFORM_VER := 8
INSTALL_DIR := /data/tmp
ANDROID_NDK_ROOT:=$(ROOT)/android-ndk-r5b
ANDROID_NDK_HOST:=linux-x86
ANDROID_SDK_ROOT:=$(ROOT)/android-sdk-linux_x86
PREBUILD:=$(ANDROID_NDK_ROOT)/toolchains/arm-eabi-4.4.0/prebuilt/$(ANDROID_NDK_HOST)
BIN := $(PREBUILD)/bin
CPP := $(BIN)/arm-eabi-g++
CC := $(BIN)/arm-eabi-gcc
CFLAGS := -I$(ANDROID_NDK_ROOT)/platforms/android-$(NDK_PLATFORM_VER)/arch-arm/usr/include -fno-short-enums
LDFLAGS := -Wl,--entry=main,-rpath-link=$(ANDROID_NDK_ROOT)/platforms/android-$(NDK_PLATFORM_VER)/arch-arm/usr/lib,-dynamic-linker=/system/bin/linker -L$(ANDROID_NDK_ROOT)/platforms/android-$(NDK_PLATFORM_VER)/arch-arm/usr/lib
LDFLAGS += -nostdlib -lc -disable-multilib
all: $(APP)
OBJS += $(APP).o
$(APP): $(OBJS)
$(CPP) $(LDFLAGS) -o [email protected] $^
%.o: %.c
$(CC) -c $(INCLUDE) $(CFLAGS) $< -o [email protected]
install: $(APP)
$(ANDROID_SDK_ROOT)/platform-tools/adb push $(APP) $(INSTALL_DIR)/$(APP)
$(ANDROID_SDK_ROOT)/platform-tools/adb shell chmod 777 $(INSTALL_DIR)/$(APP)
shell:
$(ANDROID_SDK_ROOT)/platform-tools/adb shell
run:
$(ANDROID_SDK_ROOT)/platform-tools/adb shell $(INSTALL_DIR)/$(APP)
r: $(APP)
$(ANDROID_SDK_ROOT)/platform-tools/adb push $(APP) $(INSTALL_DIR)/$(APP)
$(ANDROID_SDK_ROOT)/platform-tools/adb shell chmod 777 $(INSTALL_DIR)/$(APP)
$(ANDROID_SDK_ROOT)/platform-tools/adb shell $(INSTALL_DIR)/$(APP)
clean:
@echo "Cleaning up..."
rm -f $(APP).o $(APP)

Output on the emulator and the phone
Output:
Code:
[[email protected] app]$ make run
/home/hacker/Projects/Android/android-sdk-linux_x86/platform-tools/adb shell /data/tmp/test
Hello world!
[1] Segmentation fault /data/tmp/test
[[email protected] app]$
Output (on the phone):
Code:
# /data/local/test
link_image[1995]: failed to link /data/local/test
CANNOT LINK EXECUTABLE
#

I just got permission to post in the developer forum so I've posted this thread again since it belongs there. If a moderator sees this thread, please delete it.
New thread at http://forum.xda-developers.com/showthread.php?p=12803422

Related

NDK-less native apps

Seems to me the Android NDK has been abstracted to the point of obscurity.
I understand the need for a regimented application framework; but talk about over engineering...
> cd $(NDK_HOME)
> build/host-setup.sh
> make app=hello-jni
# ... some magic ...
> cd apps/hello-jni/project
> android.bat update project -p .
> ant debug
# ... more magic ...
> adb install bin/hello-jni-debug.apk
#hey wait wheres my c executable...
> vi apps/hello-jni/project/jni/Android.mk
# change BUILD_SHARED_LIBRARY to BUILD_EXECUTABLE
>make app=hello-jni
# there we go
what a pain, not to mention porting existing posix code with multiple dependencies...
Here is my Makefile developed in cygwin on windows by running:
> make APP=hello-jni V=1
and copying all the pertinent flags into a generic Makefile...
Hope this helps anyone having the same frustrations.
Code:
.KEEP_STATE:
#
# Android NDK tool chain setup
# run cd ~/android/ndk; make APP-xxx -V1 to obtain toolchain values
#
NDK=/home/Administrator/android/ndk
GCC=$(NDK)/build/prebuilt/windows/arm-eabi-4.2.1/bin/arm-eabi-gcc
AR=$(NDK)/build/prebuilt/windows/arm-eabi-4.2.1/bin/arm-eabi-ar
STRIP=$(NDK)/build/prebuilt/windows/arm-eabi-4.2.1/bin/arm-eabi-strip
NDK_INCLUDE=-I$(NDK)/build/platforms/android-3/arch-arm/usr/include
NDK_CFLAGS=\
-march=armv5te -mtune=xscale -msoft-float -fpic -mthumb-interwork \
-ffunction-sections -funwind-tables -fstack-protector -fno-short-enums \
-D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ \
-mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 \
-DANDROID \
#
# THIS WORKS
#
NDK_LDFLAGS=\
-nostdlib -Bdynamic -Wl,-dynamic-linker,/system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc \
$(NDK)/build/platforms/android-3/arch-arm/usr/lib/libc.so \
$(NDK)/build/platforms/android-3/arch-arm/usr/lib/libstdc++.so \
$(NDK)/build/platforms/android-3/arch-arm/usr/lib/libm.so \
$(NDK)/build/platforms/android-3/arch-arm/usr/lib/crtbegin_dynamic.o \
-Wl,--no-undefined -Wl,-rpath-link=$(NDK)/build/platforms/android-3/arch-arm/usr/lib \
$(NDK)/build/prebuilt/windows/arm-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1/interwork/libgcc.a \
$(NDK)/build/platforms/android-3/arch-arm/usr/lib/crtend_android.o
#
# Local setup
#
INCLUDE=$(NDK_INCLUDE) -I../sockets -I.
CFLAGS=$(NDK_CFLAGS)
LDFLAGS=$(NDK_LDFLAGS)
LDPATH=$(NDK_LDPATH) -L../sockets -L.
LIBS=$(NDK_LIBS) -ludp -lsockets
OBJS=$(NDK_OBJS) \
udp.o \
readTest.o \
hostnameToIp.o
# Implicit target definition for generating objects. (don't touch!)
.c.o:
$(GCC) $(INCLUDE) $(CFLAGS) -Wall -D__cygwin__ -O2 -DNDEBUG -g -c -MMD -MP -MF [email protected] $< -o [email protected]
# Target section
all: libudp.a readTest writeTest udpRecord multiRead multiWrite
# Dependency section
libudp.a: udp.o hostnameToIp.o multi.o
$(AR) crs [email protected] udp.o multi.o hostnameToIp.o
#ranlib [email protected]
udpRecord: udpRecord.o libudp.a
$(GCC) udpRecord.o $(LDFLAGS) $(LDPATH) $(LIBS) -o udpRecord
$(STRIP) --strip-debug [email protected]
readTest: readTest.o libudp.a
$(GCC) readTest.o $(LDFLAGS) $(LDPATH) $(LIBS) -o readTest
$(STRIP) --strip-debug [email protected]
writeTest: writeTest.o libudp.a
$(GCC) writeTest.o $(LDFLAGS) $(LDPATH) $(LIBS) -o writeTest
$(STRIP) --strip-debug [email protected]
multiRead: multiRead.o libudp.a
$(GCC) multiRead.o $(LDFLAGS) $(LDPATH) $(LIBS) -o multiRead
$(STRIP) --strip-debug [email protected]
multiWrite: multiWrite.o libudp.a
$(GCC) multiWrite.o $(LDFLAGS) $(LDPATH) $(LIBS) -o multiWrite
$(STRIP) --strip-debug [email protected]
clean:
-rm *.o *.a *.o.d.tmp
now its a simple
> make
> adb push program /data
> adb shell chmod 777 /data/program
> adb shell /data/program
this should be useful for command line tools and inittab daemons

Optware for Android, another try

If you're interested in running more complete Unix/Linux environment on your Android device, you might have heard about Optware for Android, here is thread for example.
Well, that project had few issues, like: shipping binaries of unknown origin and running them on user's device as root; coded and advertised as applying to one particular device; making too much changes on the device in one turn (like alter rootfs image).
That's why I decided to create another Optware install script to address those points. It is explicitly envisioned to support Android as an OS/Platform, i.e. all devices, not one particular model. Well, that may be not exactly easy, but that's at least good aim to pursue. It also doesn't come with any random binaries, but instead downloads them from a trusted source during the installation process (sources being Optware itself for bootstrap packages and CodeSourcery toolchain package for libc on which Optware depends).
Due to the last point, the installation script runs on a Linux host, so ADB connection to the device is required. Device also should have working "su" command (i.e. be rooted).
The source code is on github: https://github.com/pfalcon/optware-android
Just a bit of DISCLAIMER: you should run this script only if you understand what Optware is, and how to use it. Some experience with Unix/Linux command line and shell scripts is required, in particular you should skim thru the install script before running it.
Otherwise, it works quite well on my Nook Tablet, and I'd be happy to receive suggestions, success/bug reports, patches, etc.
Great work.
I took the liberty of using your script as a base to install OpenSSH. Should work on any device. I can't post links so I attached an archive with the script and the necessary files.
CyanogenMod on my Touchpad has some sort of sysinit '/etc/init.d', so I initialize Optware and Optware init scripts from there. I don't know how other mods handle this, probably different. SSH authentication is key-based, since passwords are not set. Have a look at the script to figure out how to deal with that.
Glad it was useful for you. Issue how to automatically start up daemons on Android indeed exists. The native Android way is /init.rc config file (of adhoc format). The problem is that this file is located on rootfs, which is ramdisk, i.e. any changes are lost and not available during boot. And initial content of that ramdisk comes from initramfs/initrd, but it has many ways to be implemented - compiled into kernel or on separate partition, checksumed against any changes, etc. So, in general case it's not possible to update, and even if it is, a mistake can lead to bricked device.
So, I for now skipped that issue altogether in my installer, but hope to get to it eventually (have some ideas).
So, if you have CyanogenMod, then using /etc/init.d is for sure a good solution.
One suggestion/question... is it possible to alter the script to run directly off of the device's command line? That would eliminate the Linux (and optionally would eliminate the ADB requirement).
I'm sure there's a static wget binary for ARM already compiled somewhere, and the rest can be done through busybox.
That would really make it universal. I'm a Windows user, and haven't had the time to parse out your script and figure out what the end result is supposed to look like on the device
merwin said:
One suggestion/question... is it possible to alter the script to run directly off of the device's command line?
Click to expand...
Click to collapse
There's now FAQ at http://sf.net/p/optware-android which discusses why this isn't possible on pristine Android system (lack of basic POSIX utilities and wget). It also has a suggestion for Windows users ;-).
That would eliminate the Linux (and optionally would eliminate the ADB requirement).
I'm sure there's a static wget binary for ARM already compiled somewhere, and the rest can be done through busybox.
Click to expand...
Click to collapse
The question is not if it's available, but whether you can trust such binary. The responsible user's answer is "No". Nook Color's optware installer does exactly that - ships binaries of unknown origin, and dissatisfaction with such approach is what prompted be to develop alternative installer.
The only way you can trust it if [easily buildable] source is provided, then it's up to the user to either compile it themselves or on their own risk to use provided binary. I don't have such source at my hands, and not interested to make it zillion's time just for this adhoc purpose - instead, there should be well-established community project to provide such build framework for all other projects to reuse. I hope, we'll tackle that under auspices of f-droid.org project.
That would really make it universal. I'm a Windows user, and haven't had the time to parse out your script and figure out what the end result is supposed to look like on the device
Click to expand...
Click to collapse
Other possible approach is to just skip "shell script" (and need for busybox) thing at all, and write installer in Java, to be run as normal Android app. That's certainly neat idea which will make users' life easier, and I have that on my (very long) TODO list ;-).
awesome! great work!
i have one small issue though: /etc/hosts doesnt seem to have any effect. a lot of stuff won't work because localhost cant be resolved. any suggestions?
2 onemandivision: Confirmed this issue, looking into it.
Ok, it turns out that GLibc's nsswitch default is weird in favoring DNS over /etc/hosts, and with Google DNS it didn't even look in the latter. Fixed by installing explicit nsswitch.conf:
# ping localhost
PING localhost (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: seq=0 ttl=64 time=0.274 ms
Let's dub this 1.0 then (tagged).
pfalcon said:
There's now FAQ at http://sf.net/p/optware-android which discusses why this isn't possible on pristine Android system (lack of basic POSIX utilities and wget). It also has a suggestion for Windows users .
The question is not if it's available, but whether you can trust such binary. The responsible user's answer is "No". Nook Color's optware installer does exactly that - ships binaries of unknown origin, and dissatisfaction with such approach is what prompted be to develop alternative installer.
The only way you can trust it if [easily buildable] source is provided, then it's up to the user to either compile it themselves or on their own risk to use provided binary. I don't have such source at my hands, and not interested to make it zillion's time just for this adhoc purpose - instead, there should be well-established community project to provide such build framework for all other projects to reuse. I hope, we'll tackle that under auspices of f-droid.org project.
Other possible approach is to just skip "shell script" (and need for busybox) thing at all, and write installer in Java, to be run as normal Android app. That's certainly neat idea which will make users' life easier, and I have that on my (very long) TODO list .
Click to expand...
Click to collapse
Most phones that are rooted have a fairly recent version of busybox on it, which includes wget. Also, standard practice on kernels these days (non stock ones) is to have all scripts that exist in /etc/init.d execute. That would solve any service startup issue.
I don't see any problems with requiring root and busybox
Solves all of the issues.
Hello
I tried the script and i was able to install ipkg on my Samsung Galaxy II
the only problem is... if i try to install any package... i get a segmentation fault error
Code:
[email protected]:/ # [B]cd /data/opt[/B]
[email protected]:/data/opt # [B]./start.sh[/B]
[B]BusyBox v1.10.3 (2012-02-14 09:43:47 UTC) built-in shell (ash)
Enter 'help' for a list of built-in commands.[/B]
$(precmd)[email protected]$HOSTNAME:${PWD:-?} #
$(precmd)[email protected]$HOSTNAME:${PWD:-?} # [B]ipkg install rsync[/B]
[B]Installing rsync (3.0.9-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/stable/rsync_3.0.9-1_arm.ipk
Segmentation fault[/B]
$(precmd)[email protected]$HOSTNAME:${PWD:-?} #
any advice? :'(
If you already have shell access to your device and don't want to connect via ADB, I modified the script to have the ability to run directly on your device (your device will need at least a functional wget executable already, which I had from SSHDroid):
Code:
# OPTWARE_DIR is where to install optware, it should be on a partition with
# normal Unix filesystem (permissions, etc.)
OPTWARE_DIR=/data/opt
# Particular field to install from, stable by default
FEED=http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/stable
# DO NOT edit anything below this line unless you know what you are doing
start_script=start.sh
cs08q1_url=https://sourcery.mentor.com/sgpp/lite/arm/portal/package2549/public/arm-none-linux-gnueabi/arm-2008q1-126-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
cs08q1_fname=$(basename $cs08q1_url)
libc_path=arm-2008q1/arm-none-linux-gnueabi/libc
libc_libs="lib/ld-2.5.so ld-linux.so.3 \
lib/libc-2.5.so libc.so.6 \
lib/libm-2.5.so libm.so.6 \
lib/librt-2.5.so librt.so.1 \
lib/libpthread-2.5.so libpthread.so.0 \
lib/libresolv-2.5.so libresolv.so.2 \
lib/libdl-2.5.so libdl.so.2 \
lib/libnss_dns-2.5.so libnss_dns.so.2 \
lib/libutil-2.5.so libutil.so.1 \
lib/libgcc_s.so.1 libgcc_s.so \
lib/libnsl-2.5.so libnsl.so.1 \
lib/libcrypt-2.5.so libcrypt.so.1 \
lib/libBrokenLocale-2.5.so libBrokenLocale.so.1 \
lib/libanl-2.5.so libanl.so.1 \
lib/libcidn-2.5.so libcidn.so.1 \
lib/libnss_compat-2.5.so libnss_compat.so.2 \
lib/libnss_files-2.5.so libnss_files.so.2 \
lib/libnss_hesiod-2.5.so libnss_hesiod.so.2 \
lib/libnss_nis-2.5.so libnss_nis.so.2 \
lib/libnss_nisplus-2.5.so libnss_nisplus.so.2 \
lib/libthread_db-1.0.so libthread_db.so.1 \
"
#
# On-target (device) commands
#
t_cp () {
# copy file on a device
cat $1 >$2
}
t_cd_ln () {
local dir=$1
shift
cd $dir; ln $*
}
t_ln () {
ln $*
}
t_chmod () {
chmod $*
}
t_mkdir_p () {
# This doesn't complain if dir exists, but can't create intermediate dirs
ls $1 >/dev/null 2>&1 || mkdir $1
}
t_rm_f () {
# Doesn't complain if file not there
ls $1 >/dev/null 2>&1 && rm $1
}
t_rm_rf () {
# Doesn't complain if dir not there
ls $1 >/dev/null 2>&1 && rm -r $1
}
t_remount_rw () {
mount -o rw,remount $1 $1
}
t_remount_ro () {
mount -o ro,remount $1 $1
}
extract_libc () {
if [ ! -d $(echo $libc_path | sed -e 's%/.*%%') ]; then
echo Extracting $cs08q1_fname
tar xjf $cs08q1_fname $list
fi
}
install_system_lib () {
local f=$(basename $1)
echo "Installing system lib: $f"
t_cp $libc_path/$1 /lib/$f
t_chmod 0755 /lib/$f
t_ln -s $f /lib/$2
}
install_system_bin () {
local f=$(basename $1)
echo "Installing system bin: $1"
t_cp $libc_path/$1 /bin/$f
t_chmod 0755 /bin/$f
}
install_libc () {
while [ -n "$1" ]; do
local lib=$1
shift
local symlink=$1
shift
install_system_lib $lib $symlink
done
}
install_bin () {
echo "Installing /opt/bin/$1"
t_cp opt/bin/$1 /opt/bin/$1
t_chmod 755 /opt/bin/$1
}
install_ipkg () {
t_mkdir_p /opt/bin
t_mkdir_p /opt/lib
install_bin ipkg
t_cp opt/lib/libipkg.so.0.0.0 /opt/lib/libipkg.so.0.0.0
t_ln -s libipkg.so.0.0.0 /opt/lib/libipkg.so.0
t_ln -s libipkg.so.0.0.0 /opt/lib/libipkg.so
}
fetch_package_index () {
if [ ! -f Packages ]; then
echo "Downloading Optware package index"
wget -q $FEED/Packages
else
echo "Using cached Optware package index"
fi
}
get_package_fname () {
awk "/^Filename: ${1}_/ {print \$2}" Packages
}
fetch_package () {
if [ -z "$1" ]; then
echo "Unexpected error: package '$1' not found in index"
exit 1
fi
if [ ! -f "$1" ]; then
echo "Downloading Optware package $1"
wget -q $FEED/$1
else
echo "Using cached package $1"
fi
}
fetch_toolchain () {
if [ ! -f $cs08q1_fname ]; then
echo "You need CodeSourcery ARM-Linux toolchain release 2008q1: $cs08q1_fname"
echo "if you have this file on your system already, press Ctrl-C now and copy"
echo "it into the current directory. Otherwise, press Enter to download it (65MB)."
read
wget $cs08q1_url
fi
}
optware_uninstall () {
t_remount_rw /
t_remount_rw /system
rm -r $OPTWARE_DIR
rm /lib
rm /bin
rm /opt
rm /tmp
t_remount_ro /
rm /etc/resolv.conf
rm /etc/mtab
rm /etc/passwd
rm /etc/group
t_remount_ro /system
echo "Optware sucessfully uninstalled"
}
#
# Main code
#
if [ "$1" == "" ]; then
echo "This script installs NSLU Optware on an Android device connected using ADB"
echo "Usage: $0 install|uninstall"
exit 1
fi
if [ "$1" == "uninstall" ]; then
optware_uninstall
exit
fi
fetch_toolchain
fetch_package_index
ipkg_fname=$(get_package_fname ipkg-opt)
wget_fname=$(get_package_fname wget)
busybox_fname=$(get_package_fname busybox-base)
fetch_package $ipkg_fname
fetch_package $wget_fname
fetch_package $busybox_fname
t_remount_rw /
t_remount_rw /system
# Start from scratch
echo "== Initializing optware environment =="
t_mkdir_p $OPTWARE_DIR
t_ln -s $OPTWARE_DIR /opt
t_mkdir_p $OPTWARE_DIR/rootbin
t_ln -s $OPTWARE_DIR/rootbin /bin
t_mkdir_p $OPTWARE_DIR/rootlib
t_ln -s $OPTWARE_DIR/rootlib /lib
t_mkdir_p $OPTWARE_DIR/tmp
t_ln -s $OPTWARE_DIR/tmp /tmp
t_mkdir_p $OPTWARE_DIR/home
t_mkdir_p $OPTWARE_DIR/home/root
t_mkdir_p $OPTWARE_DIR/home/user
echo "== Installing libc =="
extract_libc
install_libc $libc_libs
install_system_bin usr/bin/ldd
echo "== Installing bootstrap ipkg =="
rm -rf opt
tar -xOzf $ipkg_fname ./data.tar.gz | tar -xzf -
install_ipkg
echo "== Installing bootstrap wget =="
rm -rf opt
tar -xOzf $wget_fname ./data.tar.gz | tar -xzf -
install_bin wget
echo "== Installing bootstrap busybox =="
rm -rf opt
tar -xOzf $busybox_fname ./data.tar.gz | tar -xzf -
install_bin busybox
echo "== Initializing bootstrap /bin =="
# We need sane shell as /bin/sh
t_ln -s /opt/bin/busybox /bin/sh
# We need minimal set of sane shell commands to run update-alternatives
# script to properly (re)install busybox itself
t_ln -s /opt/bin/busybox /bin/echo
t_ln -s /opt/bin/busybox /bin/rm
t_ln -s /opt/bin/busybox /bin/rmdir
t_ln -s /opt/bin/busybox /bin/sed
t_ln -s /opt/bin/busybox /bin/mkdir
t_ln -s /opt/bin/busybox /bin/head
t_ln -s /opt/bin/busybox /bin/sort
t_ln -s /opt/bin/busybox /bin/dirname
t_ln -s /opt/bin/busybox /bin/ln
t_ln -s /opt/bin/busybox /bin/mv
t_ln -s /opt/bin/busybox /bin/cat
t_ln -s /opt/bin/busybox /bin/chown
t_ln -s /opt/bin/busybox /bin/chmod
# gzip and tar should be part of Android, but there were reports
# that some implementations may be broken
t_ln -s /opt/bin/busybox /bin/tar
t_ln -s /opt/bin/busybox /bin/gzip
echo "== Configuring package feed =="
t_mkdir_p /opt/etc
t_mkdir_p /opt/etc/ipkg
echo src cross $FEED >/opt/etc/ipkg/feeds.conf
echo "== Configuring domain name resolution =="
echo nameserver 8.8.8.8 >/opt/etc/resolv.conf
# On a normal Android system, /etc is symlink to /system/etc, but just in case...
t_mkdir_p /etc
# but for normal system, we need to remount /system
t_rm_f /etc/resolv.conf
t_ln -s /opt/etc/resolv.conf /etc/resolv.conf
echo "== Configuring GLIBC Namespace Switch =="
t_cp nsswitch.conf /etc/nsswitch.conf
t_chmod 0644 /etc/nsswitch.conf
echo "== Configuring /etc/mtab =="
t_ln -s /proc/mounts /etc/mtab
echo "== Configuring users =="
echo root:x:0:0:root:/opt/home/root:/bin/sh >/opt/etc/passwd
echo shell:x:2000:2000:shell:/opt/home/user:/bin/sh >>/opt/etc/passwd
t_ln -s /opt/etc/passwd /etc/passwd
echo "== Configuring groups =="
echo root:x:0:root >/opt/etc/group
echo shell:x:2000:shell >>/opt/etc/group
t_ln -s /opt/etc/group /etc/group
echo "== Creating optware init script =="
echo '#!/system/bin/sh' >/opt/optware-init.sh
echo 'ls /opt >/dev/null 2>&1 && exit' >>/opt/optware-init.sh
echo echo Reinitializing optware rootfs links >>/opt/optware-init.sh
echo mount -o rw,remount rootfs / >>/opt/optware-init.sh
echo ln -s $OPTWARE_DIR /opt >>/opt/optware-init.sh
echo ln -s $OPTWARE_DIR/rootlib /lib >>/opt/optware-init.sh
echo ln -s $OPTWARE_DIR/rootbin /bin >>/opt/optware-init.sh
echo ln -s $OPTWARE_DIR/tmp /tmp >>/opt/optware-init.sh
echo mount -o ro,remount rootfs / >>/opt/optware-init.sh
t_chmod 0755 /opt/optware-init.sh
echo "== Creating optware startup script =="
echo '#!/system/bin/sh' >/opt/$start_script
echo 'ls /opt >/dev/null 2>&1 ||' su -c $OPTWARE_DIR/optware-init.sh >>/opt/$start_script
echo '# You may want to add /opt/local/bin to PATH below' >>/opt/$start_script
echo export PATH=/opt/sbin:/opt/bin:/bin:/system/bin >>/opt/$start_script
echo 'if busybox test $(busybox id -u) = 0; then HOME=/opt/home/root; else HOME=/opt/home/user; fi' >>/opt/$start_script
echo export HOME>>/opt/$start_script
echo export TMPDIR=/tmp >>/opt/$start_script
echo umask 022 >>/opt/$start_script
echo /bin/sh >>/opt/$start_script
t_chmod 0755 /opt/$start_script
# Create "s" symlink to ease typing on touchscreen devices
t_ln -s $start_script /opt/s
t_remount_ro /
echo "== Reinstalling bootstrap packages =="
echo "Make sure that your device is woken up and connected to the Internet"
echo "Press Enter to continue"
read
#
# Now that we have all dependencies to run ipkg bootstraped on device,
# we need to use ipkg to reinstall itself and all those dependencies,
# to make sure they're installed and configured properly.
#
PATH=/opt/bin:/bin /opt/bin/ipkg update
PATH=/opt/bin:/bin /opt/bin/ipkg install ipkg-opt
PATH=/opt/bin:/bin /opt/bin/ipkg install wget
PATH=/opt/bin:/bin /opt/bin/ipkg install busybox
echo "== Cleaning local directory =="
rm -rf opt arm-2008q1
t_remount_ro /system
echo "Optware for Android installation complete."
echo "To start optware session, execute $OPTWARE_DIR/$start_script (aka $OPTWARE_DIR/s) on the device"
echo "Also, make sure you have mounted whichever partition contains Optware as rw when you execute an update"
pfalcon, let me know if you want me to add any license headers to this.

[Q] Latest Linux version of Flashtool does not see libusb

As I still don't made sufficient posts to put it directly to dev forum, it's here. Admins, please move it to correct sections as you desire.
I installed the latest version of Flashtool for Linux. I followed the instructions at flashtool. net/install. php and tried to run './Flashtool'. here is the output:
[[email protected] FlashTool]# ./FlashTool
Running as root.
JAVA_HOME not set. Using default value : ./x10flasher_lib/linjre64
libusb.LibUsbException: Libusb not found. Minimum libusb version is 1.0.15. It can be downloaded on libusbx. org
at libusb.UsbSystem.initSystem(UsbSystem.java:28)
at libusb.UsbSystem.<init>(UsbSystem.java:15)
at linuxlib.JUsb.init(JUsb.java:21)
at gui.Main.initLinuxUsb(Main.java:47)
at gui.Main.main(Main.java:34)
I have libusbx 1.0.16 and libusb 0.1.5 installed, so how can I debug this? if someone can forward this to Androxyde I will be very grateful.
I am running Fedora 19 x64 with both 32 and 64 bit libs installed, as per Flashtool site instructions. Current Java (Oracle) is Java(TM) SE Runtime Environment (build 1.7.0_45-b18), 64-bit version.
Thank you
***EDIT*** This post is no longer relevant, check the next post down.
luzemario said:
As I still don't made sufficient posts to put it directly to dev forum, it's here. Admins, please move it to correct sections as you desire.
I installed the latest version of Flashtool for Linux. I followed the instructions at flashtool. net/install. php and tried to run './Flashtool'. here is the output:
[[email protected] FlashTool]# ./FlashTool
Running as root.
JAVA_HOME not set. Using default value : ./x10flasher_lib/linjre64
libusb.LibUsbException: Libusb not found. Minimum libusb version is 1.0.15. It can be downloaded on libusbx. org
at libusb.UsbSystem.initSystem(UsbSystem.java:28)
at libusb.UsbSystem.<init>(UsbSystem.java:15)
at linuxlib.JUsb.init(JUsb.java:21)
at gui.Main.initLinuxUsb(Main.java:47)
at gui.Main.main(Main.java:34)
I have libusbx 1.0.16 and libusb 0.1.5 installed, so how can I debug this? if someone can forward this to Androxyde I will be very grateful.
I am running Fedora 19 x64 with both 32 and 64 bit libs installed, as per Flashtool site instructions. Current Java (Oracle) is Java(TM) SE Runtime Environment (build 1.7.0_45-b18), 64-bit version.
Thank you
Click to expand...
Click to collapse
I found on my system (arch linux) the libusbx libs were named differently from what flashtool is looking for.
FlashTool was looking for "/usr/lib/libusbx-1.0.so" and "/usr/lib/libusbx-1.0.so.0.1.0"
but what i had was "/usr/lib/libusb-1.0.so" and "/usr/lib/libusb-1.0.so.0.1.0" respectively.
I created Symbolic links so that flashtool would find what it was looking for...
"ln -s /usr/lib/libusb-1.0.so.0.1.0 /usr/lib/libusbx-1.0.so.0.1.0"
&
"ln -s /usr/lib/libusb-1.0.so /usr/lib/libusbx-1.0.so"
(Ran in root terminal without qoutes) That fixed it for me.
Perhaps those libs are also named differently on fedora too? i used "find / -name libusb*" (in root terminal without qoutes) to check for them on my system.
It's also possible to change the searched for filenames in "FlashTool" (the launching script) itself by editing it but that would need to be redone with every new version unless fixed/changed by the developers. the lines that would need changed are..
"ln -sf libusbx-1.0.so.0.1.0 ./x10flasher_lib/linux/lib32/libusbx-1.0.so"
"ln -sf libusbx-1.0.so.0.1.0 ./x10flasher_lib/linux/lib64/libusbx-1.0.so"
(I've bolded the part to be changed for flashtool-0.9.13.0, it might be different in the future)
Hope this helps :good:
I decided to change flashtool's script/launcher so it looks for libusbx in a more robust (i hope) way. i've attached the changed file. If this works for you then we can submit the changes to the devs for their consideration.
#!/bin/sh
export BASEDIR=$(dirname $0)
export system64=$(uname -m)
export OS=$(uname -s)
cd $BASEDIR
if test "$OS" = "Linux"
then
chmod 755 ./x10flasher_lib/adb.linux
chmod 755 ./x10flasher_lib/fastboot.linux
chmod 755 ./x10flasher_lib/unyaffs.linux
chmod 755 ./x10flasher_lib/bin2elf
chmod 755 ./x10flasher_lib/bin2sin
if [ "$(whoami)" != "root" ]
then
export HASRULES="false"
if test -d /etc/udev/rules.d
then
if grep -rl "0fce" /etc/udev/rules.d >/dev/null
then
export HASRULES="true"
fi
fi
if test "$HASRULES" = "true"
then
echo "Not running as root but Sony/SonyEriccson Vendor ID found on your udev rules"
echo "if Flashing didn't work well, run flashtool as root"
else
echo "Not running as root and there is no Sony/SonyEriccson Vendor ID on your udev rules"
echo "The user must be granted access to adb/flashmode/fastboot"
echo "If you are unsure what to do, run flashtool as root"
exit 1
fi
else
echo "Running as root."
fi
if test -z "${JAVA_HOME}"
then
if test "${system64}" = "x86_64"
then
export JAVA_HOME=./x10flasher_lib/linjre64
else
export JAVA_HOME=./x10flasher_lib/linjre32
fi
echo "JAVA_HOME not set. Using default value : ${JAVA_HOME}"
fi
if test -e ${JAVA_HOME}/bin/java
then
export LD_LIBRARY_PATH=./x10flasher_lib/linux/lib32
export LD_LIBRARY_PATH=./x10flasher_lib/linux/lib64:$LD_LIBRARY_PATH
#Begin changes by deagon 02/11/13
#ln -sf libusbx-1.0.so.0.1.0 ./x10flasher_lib/linux/lib32/libusbx-1.0.so
#ln -sf libusbx-1.0.so.0.1.0 ./x10flasher_lib/linux/lib64/libusbx-1.0.so
find /*/lib -name 'libusb*.0.1.0' -exec ln -sf {\} ./x10flasher_lib/linux/lib32/libusbx-1.0.so \;
find /*/lib -name 'libusb*.0.1.0' -exec ln -sf {\} ./x10flasher_lib/linux/lib64/libusbx-1.0.so \;
#End changes by deagon 02/11/13
ISJAVA6=$($JAVA_HOME/bin/java -version 2>&1|grep version|grep 1.6|wc -l)
ISJAVA7=$($JAVA_HOME/bin/java -version 2>&1|grep version|grep 1.7|wc -l)
ISJAVA64=$($JAVA_HOME/bin/java -version 2>&1|grep 64-Bit|wc -l)
if test $ISJAVA6 -gt 0 -o $ISJAVA7 -gt 0
then
if test $ISJAVA64 -gt 0
then
ln -sf swt64.jar ./x10flasher_lib/swtlin/swt.jar
else
ln -sf swt32.jar ./x10flasher_lib/swtlin/swt.jar
fi
$JAVA_HOME/bin/java -Xms128m -Xmx512m -Duser.country=US -Duser.language=en -jar x10flasher.jar
else
echo "Java version must be 1.6 or 1.7"
fi
else
echo "No Java in specified path in JAVA_HOME=${JAVA_HOME}"
echo "Set the variable to a valid Java installation"
fi
else
chmod 755 ./x10flasher_lib/adb.mac
chmod 755 ./x10flasher_lib/fastboot.mac
chmod 755 ./x10flasher_lib/unyaffs.mac
export DYLD_LIBRARY_PATH=./x10flasher_lib/mac/lib64:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=./x10flasher_lib/mac/lib32:$DYLD_LIBRARY_PATH
ln -sf libusbx-1.0.0.dylib ./x10flasher_lib/mac/lib64/libusbx-1.0.dylib
ln -sf libusbx-1.0.0.dylib ./x10flasher_lib/mac/lib32/libusbx-1.0.dylib
ISJAVA6=$(java -version 2>&1|grep version|grep 1.6|wc -l)
ISJAVA7=$(java -version 2>&1|grep version|grep 1.7|wc -l)
ISJAVA64=$(java -version 2>&1|grep 64-Bit|wc -l)
if test $ISJAVA64 -gt 0
then
ln -sf swt64.jar ./x10flasher_lib/swtmac/swt.jar
else
ln -sf swt32.jar ./x10flasher_lib/swtmac/swt.jar
fi
if test $ISJAVA6 -gt 0 -o $ISJAVA7 -gt 0
then
java -XstartOnFirstThread -Xms128m -Xmx512m -Duser.country=US -Duser.language=en -jar x10flasher.jar
else
echo "Java version must be 1.6 or 1.7"
fi
fi
let me know how you get on :good:
-- deagon
***EDIT*** I found a downside. The the new script/launcher is going to find and use either the old libusb or libusbx so it may create more problems than it solves for some users if they dont install libusbx before using flashtool.
Another problem will arise if the distro's libusbx package maintainers havent over written the old libusb libs to use libusbx as a drop in replacement like on arch and fedora 19 (i checked inside the fedora libusbx package before) because the changed script/launcher will likely link to libusb before libusbx if they are sitting next to each other.
Deagon said:
I decided to change flashtool's script/launcher so it looks for libusbx in a more robust (i hope) way. i've attached the changed file. If this works for you then we can submit the changes to the devs for their consideration.
#!/bin/sh
export BASEDIR=$(dirname $0)
export system64=$(uname -m)
export OS=$(uname -s)
cd $BASEDIR
if test "$OS" = "Linux"
then
chmod 755 ./x10flasher_lib/adb.linux
chmod 755 ./x10flasher_lib/fastboot.linux
chmod 755 ./x10flasher_lib/unyaffs.linux
chmod 755 ./x10flasher_lib/bin2elf
chmod 755 ./x10flasher_lib/bin2sin
if [ "$(whoami)" != "root" ]
then
export HASRULES="false"
if test -d /etc/udev/rules.d
then
if grep -rl "0fce" /etc/udev/rules.d >/dev/null
then
export HASRULES="true"
fi
fi
if test "$HASRULES" = "true"
then
echo "Not running as root but Sony/SonyEriccson Vendor ID found on your udev rules"
echo "if Flashing didn't work well, run flashtool as root"
else
echo "Not running as root and there is no Sony/SonyEriccson Vendor ID on your udev rules"
echo "The user must be granted access to adb/flashmode/fastboot"
echo "If you are unsure what to do, run flashtool as root"
exit 1
fi
else
echo "Running as root."
fi
if test -z "${JAVA_HOME}"
then
if test "${system64}" = "x86_64"
then
export JAVA_HOME=./x10flasher_lib/linjre64
else
export JAVA_HOME=./x10flasher_lib/linjre32
fi
echo "JAVA_HOME not set. Using default value : ${JAVA_HOME}"
fi
if test -e ${JAVA_HOME}/bin/java
then
export LD_LIBRARY_PATH=./x10flasher_lib/linux/lib32
export LD_LIBRARY_PATH=./x10flasher_lib/linux/lib64:$LD_LIBRARY_PATH
#Begin changes by deagon 02/11/13
#ln -sf libusbx-1.0.so.0.1.0 ./x10flasher_lib/linux/lib32/libusbx-1.0.so
#ln -sf libusbx-1.0.so.0.1.0 ./x10flasher_lib/linux/lib64/libusbx-1.0.so
find /*/lib -name 'libusb*.0.1.0' -exec ln -sf {\} ./x10flasher_lib/linux/lib32/libusbx-1.0.so \;
find /*/lib -name 'libusb*.0.1.0' -exec ln -sf {\} ./x10flasher_lib/linux/lib64/libusbx-1.0.so \;
#End changes by deagon 02/11/13
ISJAVA6=$($JAVA_HOME/bin/java -version 2>&1|grep version|grep 1.6|wc -l)
ISJAVA7=$($JAVA_HOME/bin/java -version 2>&1|grep version|grep 1.7|wc -l)
ISJAVA64=$($JAVA_HOME/bin/java -version 2>&1|grep 64-Bit|wc -l)
if test $ISJAVA6 -gt 0 -o $ISJAVA7 -gt 0
then
if test $ISJAVA64 -gt 0
then
ln -sf swt64.jar ./x10flasher_lib/swtlin/swt.jar
else
ln -sf swt32.jar ./x10flasher_lib/swtlin/swt.jar
fi
$JAVA_HOME/bin/java -Xms128m -Xmx512m -Duser.country=US -Duser.language=en -jar x10flasher.jar
else
echo "Java version must be 1.6 or 1.7"
fi
else
echo "No Java in specified path in JAVA_HOME=${JAVA_HOME}"
echo "Set the variable to a valid Java installation"
fi
else
chmod 755 ./x10flasher_lib/adb.mac
chmod 755 ./x10flasher_lib/fastboot.mac
chmod 755 ./x10flasher_lib/unyaffs.mac
export DYLD_LIBRARY_PATH=./x10flasher_lib/mac/lib64:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=./x10flasher_lib/mac/lib32:$DYLD_LIBRARY_PATH
ln -sf libusbx-1.0.0.dylib ./x10flasher_lib/mac/lib64/libusbx-1.0.dylib
ln -sf libusbx-1.0.0.dylib ./x10flasher_lib/mac/lib32/libusbx-1.0.dylib
ISJAVA6=$(java -version 2>&1|grep version|grep 1.6|wc -l)
ISJAVA7=$(java -version 2>&1|grep version|grep 1.7|wc -l)
ISJAVA64=$(java -version 2>&1|grep 64-Bit|wc -l)
if test $ISJAVA64 -gt 0
then
ln -sf swt64.jar ./x10flasher_lib/swtmac/swt.jar
else
ln -sf swt32.jar ./x10flasher_lib/swtmac/swt.jar
fi
if test $ISJAVA6 -gt 0 -o $ISJAVA7 -gt 0
then
java -XstartOnFirstThread -Xms128m -Xmx512m -Duser.country=US -Duser.language=en -jar x10flasher.jar
else
echo "Java version must be 1.6 or 1.7"
fi
fi
let me know how you get on :good:
-- deagon
***EDIT*** I found a downside. The the new script/launcher is going to find and use either the old libusb or libusbx so it may create more problems than it solves for some users if they dont install libusbx before using flashtool.
Another problem will arise if the distro's libusbx package maintainers havent over written the old libusb libs to use libusbx as a drop in replacement like on arch and fedora 19 (i checked inside the fedora libusbx package before) because the changed script/launcher will likely link to libusb before libusbx if they are sitting next to each other.
Click to expand...
Click to collapse
not working for me. same error.
Same error
QkiZMR said:
not working for me. same error.
Click to expand...
Click to collapse
Same error here, need help please!!
nefsation said:
Same error here, need help please!!
Click to expand...
Click to collapse
first go to this http://www.libusbx.org
and download latest source (tarball)
extract that .tar.gz and go to that dir
now run the following commands
Code:
./config
make
sudo make install
assuming your Flashtool folder is in home
run the following commands
Code:
cd
cp /usr/local/lib/libusb-1.0.so.0.1.0 FlashTool/x10flasher_lib/linux/lib64
cp /usr/local/lib/libusb-1.0.so.0.1.0 FlashTool/x10flasher_lib/linux/lib32
replace the FlashTool script in FlashTool folder by this one FlashTool
FlashTool developer decided to bundle full JRE (both 32 and 64 bit) plus all these binaries and libraries with a relatively simple Java application for some strange reason. Lame. I've spent more than an hour downloading the 113 MB 7z archive from some sh*tty file-share service, instead spending just 1/4 of that time, and do something useful for the rest!
An average Linux user should be able to install these deps by herself, all she needs is a decent README specifiying the deps...
At least with the Ubuntu 13.10 (Saucy), libusb, which is at version 1.0.1.16, should work, so one does not need no freakin libusbx... This is for Saucy x86_64;
Code:
# One also needs basic 32-bit support, for running stuff like bin2sin, check libc6:i386 or similar:
sudo apt-get install android-tools-adb android-tools-fastboot libusb-1.0-0 default-jre
sudo ln -s libusb-1.0.so.0.1.0 /lib/x86_64-linux-gnu/libusbx-1.0.so
# Remove 260MB of rubbish:
cd <wherever you unpacked FlashTool>
rm -rf x10flasher_lib/{adb,fastboot}.linux x10flasher_lib/lin*
ln -s /usr/bin/adb x10flasher_lib/adb.linux
ln -s /usr/bin/fastboot x10flasher_lib/fastboot.linux
ln -s swt64.jar x10flasher_lib/swtlin/swt.jar
# Now, start the application
java -Xms128m -Xmx512m -Duser.language=en -jar x10flasher.jar
Zgembo said:
Code:
ln -s swt64.jar x10flasher_lib/swtlin/swt.jar
Click to expand...
Click to collapse
when i execute above command..it gives this error..
Code:
ln: failed to create symbolic link ‘x10flasher_lib/swtlin/swt.jar’: File exists
Edit: aha..finally flashtool successfully started with this method..i just replaced -s with -sf which forcefully does the operation

[GUIDE] How to build CWM-based Recovery from source in Ubuntu LTS with CM-11.0

I know there are so many guides about building recovery from source, but from my perspective they are incomplete or quite old. There are some parts missing like how to set up a device tree, and others.
I wanted to write this guide to help people to build by themself a Clockworkmod or other custom recovery.
I will not reproduce the good informations from other guides, instead I will post the links to them, and I will highlight those parts that I consider are missing. And extra, I provided specific informations for MTK phones; for easy separation the text for MTK is colored in DarkRed. If your phone is not MTK powered you can skip those parts.
One important note: my guide will cover only the building of recovery from source, not the full ROM, but it can be used as start, or base for further development.
For start you need a PC with ubuntu 12.04 or 14.04 x64 installed (or use a virtual machine) - this is the recommended distribution on Android official guide. You can follow that guide to setup the building environment. In the same time, I have few things to add up, so at every step in that guide take a look here too.
Other things you need:
- A good configuration for your computer (you can't do these things with a bad computer);
- Geany software or a good IDE;
- a stock boot.img for your phone;
- a stock recovery.img for your phone;
- unpack-repack CarlivImageKitchen;
Credits:
- Clockworkmod;
- Cyanogenmod;
- bgcngm for his mtk tools;
- chrmhoffmann for the custom boot image maker;
- Android-Dls;
IMPORTANT:
I used a real making example during the guide, recreating all steps for my phone, for images. So, when you follow my guide keep in mind that "carliv" is my username and you should use yours; "lenovo" is my phone brand/manufacturer and you should use yours; "P780" is my phone model and you should use yours.
So, where you see that in examples, codes or commands, don't copy from here and paste in your terminal. First copy them in a text editor, change these data with yours and after that copy and paste in terminal - if you don't want to type much.
First open a terminal window and type this:
Code:
sudo apt-get update
If you have installed the latest Ubuntu 12.04.5 x64 with latest HWE stack, instead of the resources listed on Android guide, use these:
Code:
sudo apt-get install git gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev libreadline6-dev libgl1-mesa-dri-lts-trusty:i386 libgl1-mesa-dev-lts-trusty g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 lzop ccache gnupg python gcc g++ cpp
and:
Code:
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
Then install this:
Code:
sudo apt-get install ia32-libs
If you have installed the latest Ubuntu 14.04.1 x64, instead of the resources listed on Android guide, use these:
Code:
sudo apt-get install bison g++-multilib git gperf libxml2-utils
then
Code:
sudo apt-get install gnupg ccache lzop flex build-essential zip curl zlib1g-dev zlib1g-dev:i386 libc6-dev lib32bz2-1.0 lib32ncurses5-dev x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 lib32z1-dev libgl1-mesa-glx:i386 libgl1-mesa-dev mingw32 tofrodos python-markdown xsltproc libreadline6-dev lib32readline-gplv2-dev libncurses5-dev bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev lib32bz2-dev squashfs-tools pngcrush pngquant schedtool dpkg-dev
and:
Code:
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
For 51-android.rules:
For USB rules check here to see how they look for google devices and here to see a list with vendor Ids for different brands and here for a cyanogenmod template.
MTK
- if you use a MTK device add these lines to that file too:
Code:
#MTK
SUBSYSTEM=="usb", ATTR{idVendor}=="0e8d", MODE="0666", GROUP="plugdev", OWNER="your_username"
#MTK adb and mass storage
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", [COLOR="Red"]ATTR{idProduct}=="0c03"[/COLOR], MODE="0666", GROUP="plugdev", OWNER="your_username"
Why you need to add idProduct as well? Because idVendor "0bb4" is already used by HTC, and that will make the difference between the two.
Attached is my 51-android.rules file.
Next, download Android-sdk and unpack it in your home directory:
Code:
tar xzf $HOME/Downloads/android-sdk_[COLOR="Red"]rxx[/COLOR]-linux.tgz
where "rxx" is the release name (current is r24.0.2, but check the number when you download it, because it will be changed probably), and rename android-sdk-linux folder as android-sdk, or what name you want (keep in mind that this will be added in bashrc file in path), then in tools subfolder double click "android" script to start it (select run, not run in terminal) and install at least one android platform, to get sdk tools like adb, fastboot, etc.
For java I have my way. Because of the new instructions for openjdk in Android source, and because the new cyanogenmod 12 requires that too, I will present a new way of setting java.
Old way dual java:
MTK:
In official guide is recommended openjdk-7, but if you want to build for MTK phones and you have access to full building sources, you will notice that openjdk is not supported; in fact you will see exact this error message:
Code:
"openjdk is not supported" and "FAIL"
First uninstall in synaptic package manager the libreoffice completely, because if you don't you will not be able to uninstall openjdk (libreoffice requires java, and if you uninstall openjdk7 it will be a prompt to install openjdk6 and viceversa). This is a computer for building not office, but if you need an office solution try WPS Office for linux, or install abiword and gnumeric. After that remove completely openjdk and icedtea plugins:
Code:
sudo apt-get purge openjdk-\* icedtea-\* icedtea-6-\* icedtea-7-\*
and check if there is any trace left:
Code:
sudo dpkg --list | grep -i jdk
Next go to this page and download jdk-7u67-linux-x64.tar.gz and jdk-6u45-linux-x64.bin.
Move both in your home folder (/home/username), or use
Code:
mv $HOME/Downloads/jdk-7u67-linux-x64.tar.gz $HOME && mv $HOME/Downloads/jdk-6u45-linux-x64.bin $HOME
After that use these commands to install java:
Code:
sudo mkdir -p /opt/java
Code:
sudo tar -zxf jdk-7u67-linux-x64.tar.gz -C /opt/java
Code:
chmod u+x jdk-6u45-linux-x64.bin
Code:
./jdk-6u45-linux-x64.bin
Code:
sudo mv jdk1.6.0_45 /opt/java
Code:
sudo rm jdk-6u45-linux-x64.bin jdk-7u67-linux-x64.tar.gz
At this point java is installed in /opt/java folder, but you need to setup java alternatives.
Type these one by one:
Code:
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/jdk1.7.0_67/bin/java" 1
Code:
sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/java/jdk1.7.0_67/bin/javac" 1
Code:
sudo update-alternatives --install "/usr/bin/javadoc" "javadoc" "/opt/java/jdk1.7.0_67/bin/javadoc" 1
Code:
sudo update-alternatives --install "/usr/bin/javah" "javah" "/opt/java/jdk1.7.0_67/bin/javah" 1
Code:
sudo update-alternatives --install "/usr/bin/javap" "javap" "/opt/java/jdk1.7.0_67/bin/javap" 1
Code:
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/opt/java/jdk1.7.0_67/bin/javaws" 1
That will setup jdk 1.7 as your main java alternative, but if you need to work with jdk 1.6, type these too:
Code:
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/jdk1.6.0_45/bin/java" 2
Code:
sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/java/jdk1.6.0_45/bin/javac" 2
Code:
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/opt/java/jdk1.6.0_45/bin/javaws" 2
For building with jdk 1.6, these three are all you need.
Check again the java alternatives:
Code:
ls -la /etc/alternatives/java*
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
If they are not all with jdk 1.7, which will be your main java jdk (required by kitkat, or latest apktool), use these to select jdk 1.7:
Code:
sudo update-alternatives --config java
Code:
sudo update-alternatives --config javac
Code:
sudo update-alternatives --config javaws
Other thing you can do is to install java plugin for your browsers (not building related, but useful):
Code:
sudo ln -s /opt/java/jdk1.7.0_67/jre/lib/amd64/libnpjp2.so /usr/lib/mozilla/plugins/libnpjp2.so
Code:
sudo ln -s /opt/java/jdk1.7.0_67/jre/lib/amd64/libnpjp2.so /usr/lib/chromium-browser/plugins/libnpjp2.so
Code:
sudo ln -s /opt/java/jdk1.7.0_67/jre/lib/amd64/libnpjp2.so /usr/lib/opera/plugins/libnpjp2.so
That depends on what browser you have installed.
So, if you have to build with jdk 1.6, update those three alternatives and also in bashrc file comment "export JAVA_HOME" for jdk 1.7, and uncomment for jdk 1.6:
Code:
export JAVA_HOME=/opt/java/jdk1.6.0_45
[COLOR="Red"]#[/COLOR] export JAVA_HOME=/opt/java/jdk1.7.0_67
Everything else remain the same. Then reboot and you will be using jdk 1.6 for building. Same to revert.
Ok, you have dual java on your computer.
Ah, if you see in terminal an error like this:
Code:
(gedit:7129): Gtk-CRITICAL **: gtk_tree_selection_get_selected: assertion `GTK_IS_TREE_SELECTION (selection)' failed
when you close the gedit with bashrc file, then open again gedit with this command in terminal:
Code:
sudo gedit
in Edit menu, open Preferences > Plugins and deselect File Browser Panel plugin. Next time you open gedit in terminal you won't see that error anymore.
For removing these manual java installations, type these commands one by one:
Code:
sudo rm -rf /opt/java/jdk1.6.0_45
sudo rm -rf /opt/java/jdk1.7.0_67
sudo update-alternatives --remove "java" "/usr/bin/java"
sudo update-alternatives --remove "javac" "/usr/bin/javac"
sudo update-alternatives --remove "javadoc" "/usr/bin/javadoc"
sudo update-alternatives --remove "javah" "/usr/bin/javah"
sudo update-alternatives --remove "javap" "/usr/bin/javap"
sudo update-alternatives --remove "javaws" "/usr/bin/javaws"
sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javadoc
sudo update-alternatives --config javah
sudo update-alternatives --config javap
sudo update-alternatives --config javaws
sudo rm /usr/lib/mozilla/plugins/libnpjp2.so
sudo rm /usr/lib/chromium-browser/plugins/libnpjp2.so
sudo rm /usr/lib/opera/plugins/libnpjp2.so
and delete from bashrc file
Code:
#export JAVA_HOME=/opt/java/jdk1.6.0_45
export JAVA_HOME=/opt/java/jdk1.7.0_67
Then reinstall openjdk-7 and icedtea plugin:
Code:
sudo apt-get update
sudo apt-get install openjdk-7-jdk icedtea-netx
You can use OpenJDK 7 now, if you are not building for MTK phones.
For those of you that need to use either sun jdk 1.6 or 1.7, you have to install it manually as I show above. Then, after installation, you don't have to add it to java alternatives, since the MTK building source doesn't care about your path. Instead you have to edit "mbldenv.sh" file and to replace the java path with yours.
Although, if you want you can use jdk 1.7 or 1.6 in dual setup with openjdk-7. Just install these two alternatives:
Code:
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/jdk1.7.0_67/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/java/jdk1.7.0_67/bin/javac" 1
or
Code:
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/jdk1.6.0_45/bin/java" 2
sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/java/jdk1.6.0_45/bin/javac" 2
and ad it to bashrc file in path:
Code:
#export JAVA_HOME=/opt/java/jdk1.7.0_67
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
or
Code:
#export JAVA_HOME=/opt/java/jdk1.6.0_45
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
switching between the two with these:
Code:
sudo update-alternatives --config java
sudo update-alternatives --config javac
and editing the path in bashrc, then restart the computer. Same to revert.
Next you need to add java in your path. In Android guide for setup building environment you can see how to create the bin folder for repo file. Then how to add that folder in path. We will complete that now:
Code:
sudo gedit ~/.bashrc
And at the end add these:
Code:
export PATH=~/bin:$PATH
#export JAVA_HOME=/opt/java/jdk1.7.0_67
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export JRE_HOME=JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
export PATH=$HOME/bin:$HOME/android-sdk/platform-tools/:$HOME/android-sdk/tools:$PATH
export USE_CCACHE=1
To check if java is installed and is in path type these in terminal:
Code:
java -version
which java
echo $JAVA_HOME
You can see here also the android sdk path, which I named android-sdk/, usually is android-sdk-linux/. You need sdk for adb and fastboot to work. And, if you have only OpenJDK, remove the jdk 1.7 line.
This is a complete building environment set up.
Sync a building repo.
Since we are talking about compiling CWM based recovery, or official CWM, we will move to cyanogenmod guide.
So do what they say to sync the cm-11.0 repo. I usually do this in a folder named CM11-0, but you can use what name you want, or as they say "/android/system". Wait to finish the repo sync (depends on internet connection, computer performances, etc) - for me it takes about four hours.
A side note: most of the Custom Android ROMs have an instruction on manifest with default number of jobs for repo sync. Something like this:
Code:
<default revision="refs/heads/cm-11.0"
remote="github"
sync-c="true"
sync-j=[COLOR="Red"]"4"[/COLOR] />
But during sync process you will see sometimes "curl errors" about not permitting clone bundle. That's because google sources refuses jobs setted up to high. You have an option: after all sync process is done, run a repo sync again, but overwriting the number of jobs:
Code:
repo sync -j1
This is permitted by google git repositories and it will fix any missing sources in your cloned repo. Don't do it from start because it will take forever to download the sources. Do it like I said only after first repo sync is finished.
AMENDMENT:
OpenJDK 7 is now recommended inAndroid and mandatory in cyanogenmod 12, but will throw an error in cyanogenmod 11. A solution can be to edit /build/core/main.mk file in cyanogenmod 11 building tree, and to add new java check requirements. Instead of this:
Code:
# Check for the correct version of java
java_version := $(shell java -version 2>&1 | head -n 1 | grep '^java .*[ "]1\.[67][\. "$$]')
ifneq ($(shell java -version 2>&1 | grep -i openjdk),)
java_version :=
endif
ifeq ($(strip $(java_version)),)
$(info ************************************************************)
$(info You are attempting to build with an unsupported version)
$(info of java.)
$(info $(space))
$(info Your version is: $(shell java -version 2>&1 | head -n 1).)
$(info The correct version is: Java SE 1.6 or 1.7.)
$(info $(space))
$(info Please follow the machine setup instructions at)
$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
$(info ************************************************************)
endif
# Check for the correct version of javac
javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.[67][\. "$$]')
ifeq ($(strip $(javac_version)),)
$(info ************************************************************)
$(info You are attempting to build with the incorrect version)
$(info of javac.)
$(info $(space))
$(info Your version is: $(shell javac -version 2>&1 | head -n 1).)
$(info The correct version is: 1.6 or 1.7.)
$(info $(space))
$(info Please follow the machine setup instructions at)
$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
$(info ************************************************************)
$(error stop)
endif
to add this:
Code:
java_version_str := $(shell unset _JAVA_OPTIONS && java -version 2>&1)
javac_version_str := $(shell unset _JAVA_OPTIONS && javac -version 2>&1)
# Check for the correct version of java, should be 1.7 by
# default, and 1.6 if LEGACY_USE_JAVA6 is set.
ifeq ($(LEGACY_USE_JAVA6),)
required_version := "1.7.x"
required_javac_version := "1.7"
java_version := $(shell echo '$(java_version_str)' | grep '^java .*[ "]1\.7[\. "$$]')
javac_version := $(shell echo '$(javac_version_str)' | grep '[ "]1\.7[\. "$$]')
else # if LEGACY_USE_JAVA6
required_version := "1.6.x"
required_javac_version := "1.6"
java_version := $(shell echo '$(java_version_str)' | grep '^java .*[ "]1\.6[\. "$$]')
javac_version := $(shell echo '$(javac_version_str)' | grep '[ "]1\.6[\. "$$]')
endif # if LEGACY_USE_JAVA6
ifeq ($(strip $(java_version)),)
$(info ************************************************************)
$(info You are attempting to build with the incorrect version)
$(info of java.)
$(info $(space))
$(info Your version is: $(java_version_str).)
$(info The required version is: $(required_version))
$(info $(space))
$(info Please follow the machine setup instructions at)
$(info $(space)$(space)$(space)$(space)https://source.android.com/source/initializing.html)
$(info ************************************************************)
$(error stop)
endif
# Check for the current JDK.
#
# For Java 1.7, we require OpenJDK on linux and Oracle JDK on Mac OS.
# For Java 1.6, we require Oracle for all host OSes.
requires_openjdk := false
ifeq ($(LEGACY_USE_JAVA6),)
ifeq ($(HOST_OS), linux)
requires_openjdk := true
endif
endif
# Check for the current jdk
ifeq ($(requires_openjdk), true)
# The user asked for java7 openjdk, so check that the host
# java version is really openjdk
ifeq ($(shell echo '$(java_version_str)' | grep -i openjdk),)
$(info ************************************************************)
$(info You asked for an OpenJDK 7 build but your version is)
$(info $(java_version_str).)
$(info ************************************************************)
$(error stop)
endif # java version is not OpenJdk
else # if requires_openjdk
ifneq ($(shell echo '$(java_version_str)' | grep -i openjdk),)
$(info ************************************************************)
$(info You are attempting to build with an unsupported JDK.)
$(info $(space))
$(info You use OpenJDK but only Sun/Oracle JDK is supported.)
$(info Please follow the machine setup instructions at)
$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
$(info ************************************************************)
$(error stop)
endif # java version is not Sun Oracle JDK
endif # if requires_openjdk
# Check for the correct version of javac
ifeq ($(strip $(javac_version)),)
$(info ************************************************************)
$(info You are attempting to build with the incorrect version)
$(info of javac.)
$(info $(space))
$(info Your version is: $(javac_version_str).)
$(info The required version is: $(required_javac_version))
$(info $(space))
$(info Please follow the machine setup instructions at)
$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
$(info ************************************************************)
$(error stop)
endif
but I can't tell you it will work flawless, since I can't test the building of a full ROM (for recovery it works without problems).
Set up a device tree.
Of course if you don't have one, because nobody created it before.
Following the clockworkmod guide, you can see how to start this by using mkvendor.sh script.
So place the recovery.img from your stock ROM in that repo folder (CM11-0 for me), and let's take as example my phone Lenovo P780.
With any root explorer take a look at build.prop from "system" and notice these lines:
Code:
ro.product.manufacturer=[COLOR="Red"]LENOVO[/COLOR]
ro.product.device=[COLOR="Red"]P780[/COLOR]
I have lenovo (I will use lower-case) and P780.
And the command will be
Code:
./build/tools/device/mkvendor.sh lenovo P780 recovery.img
But, at this point I always get an error message:
Code:
"[COLOR="Red"]unpackbootimg[/COLOR] not found. Is your android build environment set up and have the host tools been built?"
In that guide they say to do
Code:
. build/envsetup.sh
make -j4 otatools
in cm11 folder, and the unpackbootimg will be compiled. What they don't say (or I never found it) is that even after otatools are created, that error still appear. And if we take a look in the script, we see it is searching for unpakbootimg executable:
Code:
UNPACKBOOTIMG=[COLOR="Red"]$(which unpackbootimg)[/COLOR]
The which command won't display anything if the module is not in path. So either you add "$HOME/CM11_folder/out/host/linux-x86/bin" in path, or run this in terminal after otatools make is finished:
Code:
cp $HOME/CM11_folder/out/host/linux-x86/bin/unpackbootimg $HOME/bin
where CM11_folder is the name of the folder with cm-11.0 building tree. After that the unpackbootimg will be in bin folder, which is in path, and everytime you need to run it, will be found. You can check that in terminal typing
Code:
which unpackbootimg
Now back to my example for device tree. Open a terminal window in CM11-0 folder, or open terminal and type
Code:
cd CM11-0
then type that command to create the device tree.
Code:
./build/tools/device/mkvendor.sh lenovo P780 recovery.img
After script is executed you will see the new device folder in device list, lenovo with subfolder P780.
For a regular phone that will be ok, and you can start working on that device tree,
but for a MTK phone that is not good.
Why? Because MTK use a header appended to kernel and ramdisk, and the script won't be able to properly unpack it.
It will be an error about ramdisk not being in gzip format for a MTK phone.
The result will be that instead of real recovery.fstab and some other data in device tree files, we will get generic default values. As an example, this is the recovery.fstab I've got for my phone after that command:
Code:
# mount point fstype device [device2]
/boot mtd boot
/cache yaffs2 cache
/data yaffs2 userdata
/misc mtd misc
/recovery mtd recovery
/sdcard vfat /dev/block/mmcblk0p1 /dev/block/mmcblk0
/system yaffs2 system
/sd-ext ext4 /dev/block/mmcblk0p2
That is not the real one (my device is emmc not mtd type) and so, for MTK phones, we need to do some extra things. First get my CarlivImageKitchen and unpack it somewhere in your home folder. The utility contains few unpack and repack scripts for boot/recovery images created using instructions from here.
Then copy the stock recovery image to those utilities folder and open a terminal window in it.
Type
Code:
./unpack_MTK_img recovery.img
What you have to do now is to repack the recovery using the regular script instead of MTK script (CarlivImageKitchen strips off the Mediatek header during unpack).
So, just type
Code:
./repack_img recovery
and choose the name recovery for the new image.
At the end take the recovery.img an move it to cm11-0 folder.
Back to cm11 folder, open a terminal window and type mkvendor command
Code:
./build/tools/device/mkvendor.sh lenovo P780 recovery.img
The result? Well take a look at this recovery.fstab:
Code:
boot /boot emmc defaults defaults
/dev/block/mmcblk0p2 /cache ext4 defaults defaults
/dev/block/mmcblk0p3 /data ext4 defaults defaults
misc /misc emmc defaults defaults
recovery /recovery emmc defaults defaults
/dev/block/mmcblk0p4 /sdcard vfat defaults defaults
/dev/block/mmcblk0p6 /system ext4 defaults defaults
This is the real one from stock recovery. It can't be used for CWM but it proves that the ramdisk was unpacked correct.
Anyway this is only the beginning, because we need to check every file from device tree and to add some files too.
This part is universal, not only for MTK phones.
At this point the device folder looks like this.
First we need to create a new file, vendorsetup.sh with this content:
Code:
add_lunch_combo cm_P780-eng
or copy one from an existent device tree, changing the device name with yours.
Actually entire file looks like this:
Code:
#
# Copyright (C) 2013 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This file is executed by build/envsetup.sh, and can use anything
# defined in envsetup.sh.
#
# In particular, you can add lunch options with the add_lunch_combo
# function: add_lunch_combo generic-eng
add_lunch_combo cm_P780-eng
This will add your device in lunch options, and will be initialized by build/envsetup.sh command. It should work even without it, but is better to create this script: the official clockworkmod guide says - " It is used to add non-standard lunch combos to the lunch menu.".
Next you have to change AndroidBoard.mk to Android.mk and instead of
Code:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
ALL_PREBUILT += $(INSTALLED_KERNEL_TARGET)
# include the non-open-source counterpart to this file
-include vendor/lenovo/P780/AndroidBoardVendor.mk
it should contain this
Code:
#
# Copyright (C) 2013 The Android Open-Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# WARNING: Everything listed here will be built on ALL platforms,
# including x86, the emulator, and the SDK. Modules must be uniquely
# named (liblights.tuna), and must build everywhere, or limit themselves
# to only building on ARM if they include assembly. Individual makefiles
# are responsible for having their own logic, for fine-grained control.
LOCAL_PATH := $(call my-dir)
ifeq ($(TARGET_DEVICE),P780)
include $(call all-makefiles-under,$(LOCAL_PATH))
endif
AndroidProducts.mk file is ok as it is and we will let BoardConfig.mk for the end.
Let's create first a folder "prebuilt" and move the kernel in it. Then a new folder "recovery" and move recovery.fstab in it.
Then cm.mk file can remain as it is for building recovery, so let's open device_YOURPHONE.mk (in my case device_P780.mk) - all editing must be made with a good editor (IDE) - I'm using Geany. You can see the kernel is called from device folder, but you moved it in prebuilt folder so change this
Code:
LOCAL_PATH := device/lenovo/P780
to this
Code:
LOCAL_PATH := device/lenovo/P780/prebuilt
Also here you can add rules for files that have to be copied in built recovery ramdisk, or aditional lines to default prop file.
Like this:
Code:
ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0 \
ro.allow.mock.location=1 \
persist.mtk.aee.aed=on \
ro.debuggable=1 \
persist.service.acm.enable=0 \
persist.sys.usb.config=mass_storage \
ro.bootloader.mode=download \
ro.mount.fs=EXT4 \
ro.persist.partition.support=no
or if you don't want those unuseful goldfish things in ramdisk, add this too:
Code:
PRODUCT_COPY_FILES_OVERRIDES += \
root/fstab.goldfish \
root/init.goldfish.rc \
recovery/root/fstab.goldfish
You have to know that in cm11 any file that starts with init will be deleted from root of ramdisk as we can see in /build/core/Makefile:
Code:
@echo -e ${CL_CYN}"Modifying ramdisk contents..."${CL_RST}
$(hide) [COLOR="Red"]rm -f $(TARGET_RECOVERY_ROOT_OUT)/init*.rc[/COLOR]
So if you want to add some init files in recovery ramdisk root (init.usb.rc or init.ssd.rc, etc.) there is another way. For cm11, you have to create a subfolder "recovery" in device tree - which you did already, and in that folder to create subfolders that match recovery ramdisk folders (ex. etc, res, sbin...), and for files that have to be in root create a root subfolder. The building process will take those, if they are in res or root subfolder and place them in corresponding folders in recovery ramdisk. for the other subfolders (etc, sbin) you have to create an Android.mk file in recovery folder defining every file as local module and to use device_xxxx.mk to add them as product packages. This method with locale module is also recommended for boot image ramdisk. For building recovery we don't need that, but I mention it for further developments.
Now it's time to add some files in recovery folder. A custom init.rc and fstab, named after your hardware: if it is qualcomm will be init.qualcomm.rc and fstab.qualcomm, if it is a MTK phone will be init.mt6589.rc and fstab.mt6589 or whatever is your MTK hardware, and so on. This fstab will be placed in /recovery/root folder and init file will remain in recovery folder. Another way is to name init.{hardware}.rc as init.recovery.{hardware}.rc and to place it in /recovery/root folder too, and to not use a custom init.rc for recovery, because that one will be called in default init.rc, but I prefer only one init.rc file in ramdisk.
For the fstab you have to unpack a stock boot.img for your phone. Using CarlivImageKitchen from before, copy your boot.img in that folder and type:
Code:
./unpack_img boot.img
or if your phone is a MTK powered one, type this
Code:
./unpack_MTK_img boot.img
Open the ramdisk folder and copy the fstab file to your device /recovery/root folder and then rename it as I said before - fstab.{hardware}. Then go to cm11 building tree folder, open /bootable/recovery/etc folder and copy init.rc file to your device /recovery folder, then change the name to init.{hardware}.rc.
Since the recovery in cm11 is using the fstab version 2, you can use same content for fstab.{hardware} and recovery.fstab, but this content is specific to your device. Try to find on github a device folder for a phone with same platform CPU and take a look, then compare with your stock fstab and try to find in your phone with a root explorer the correct paths for partitions. This one can't be standardized. As an example here is a fstab for a HTC M7:
Code:
# Copyright (C) 2014 The CyanogenMod Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#<src> <mnt_point> <type> <mnt_flags> <fs_mgr_flags>
#/dev/block/platform/msm_sdcc.1/by-name/dsps /firmware_dsps vfat ro,shortname=lower wait
/dev/block/platform/msm_sdcc.1/by-name/radio /firmware_radio vfat ro,shortname=lower wait
/dev/block/platform/msm_sdcc.1/by-name/adsp /firmware_q6 vfat ro,shortname=lower wait
#/dev/block/platform/msm_sdcc.1/by-name/wcnss /firmware_wcnss vfat ro,shortname=lower wait
/dev/block/platform/msm_sdcc.1/by-name/boot /boot emmc defaults defaults
/dev/block/platform/msm_sdcc.1/by-name/recovery /recovery emmc defaults defaults
/dev/block/platform/msm_sdcc.1/by-name/misc /misc emmc defaults defaults
/dev/block/platform/msm_sdcc.1/by-name/devlog /devlog ext4 noatime,nosuid,nodev,barrier=0 wait
/dev/block/platform/msm_sdcc.1/by-name/system /system ext4 ro,noatime,barrier=0 wait
/dev/block/platform/msm_sdcc.1/by-name/cache /cache ext4 noatime,nosuid,nodev,barrier=0 wait
/dev/block/platform/msm_sdcc.1/by-name/userdata /data ext4 noatime,nosuid,nodev,noauto_da_alloc,barrier=0 wait,encryptable=/dev/block/platform/msm_sdcc.1/by-name/extra
# SD card
/devices/platform/msm_sdcc.1/mmc_host/mmc0 auto auto defaults voldmanaged=sdcard0:36,noemulatedsd
# USB storage
/devices/platform/msm_hsusb_host/usb auto auto defaults voldmanaged=usbdisk:auto
and this is the recovery.fstab for my MTK Lenovo P780
Code:
# Android fstab file.
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
/[email protected] /system ext4 ro,noatime wait
/[email protected] /cache ext4 noatime,nosuid,nodev,noauto_da_alloc wait
/[email protected] /data ext4 noatime,nosuid,nodev,noauto_da_alloc wait,encryptable=footer
# vold-managed volumes
/devices/platform/mtk-msdc.0/mmc_host/mmc0 auto auto defaults voldmanaged=sdcard1:8,
/devices/platform/mtk-msdc.1/mmc_host/mmc1 auto auto defaults voldmanaged=sdcard0:auto
/dev/bootimg /boot emmc defaults defaults
/dev/nvram /nvram emmc defaults defaults
/dev/recovery /recovery emmc defaults defaults
/dev/uboot /uboot emmc defaults defaults
/dev/misc /misc emmc defaults defaults
in fstab.mt6589 It has two more partitions (security)
Code:
# Android fstab file.
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
/[email protected] /system ext4 ro,noatime wait
/[email protected] /cache ext4 noatime,nosuid,nodev,noauto_da_alloc wait
/[email protected] /data ext4 noatime,nosuid,nodev,noauto_da_alloc wait,encryptable=footer
[COLOR="Red"]/[email protected]_f /protect_f ext4 noatime,nosuid,nodev,noauto_da_alloc wait,check
/[email protected]_s /protect_s ext4 noatime,nosuid,nodev,noauto_da_alloc wait,check[/COLOR]
# vold-managed volumes
/devices/platform/mtk-msdc.0/mmc_host/mmc0 auto auto defaults voldmanaged=sdcard0:8
/devices/platform/mtk-msdc.1/mmc_host/mmc1 auto auto defaults voldmanaged=sdcard1:auto
/devices/platform/mt_usb/sda/sda1 auto auto defaults voldmanaged=usbotg:auto
/dev/bootimg /boot emmc defaults defaults
/dev/nvram /nvram emmc defaults defaults
/dev/recovery /recovery emmc defaults defaults
/dev/uboot /uboot emmc defaults defaults
/dev/misc /misc emmc defaults defaults
but the rest is the same with recovery.fstab. So, this is something you have to figure out by yourself from your device. Here is another example for a MTK phone with Ubifs file system:
Code:
# Android fstab file.
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
/[email protected] /system ubifs ro,noatime wait
/[email protected] /cache ubifs noatime,nosuid,nodev,noauto_da_alloc wait
/[email protected] /data ubifs noatime,nosuid,nodev,noauto_da_alloc wait,encryptable=footer
# vold-managed volumes
/devices/platform/mtk-msdc.0/mmc_host/mmc0 auto auto defaults voldmanaged=sdcard0:8,
/devices/platform/mtk-msdc.1/mmc_host/mmc1 auto auto defaults voldmanaged=sdcard1:auto
/dev/mtd/mtd6 /boot mtd defaults defaults
/dev/mtd/mtd2 /nvram mtd defaults defaults
/dev/mtd/mtd7 /recovery mtd defaults defaults
/dev/mtd/mtd5 /uboot mtd defaults defaults
/dev/mtd/mtd9 /misc mtd defaults defaults
To find more about partitions, mount points, paths related to your device, run this command in terminal:
Code:
adb shell ls /proc
and pay attention to the files names you see - ignore folders (numbers) at start. Then one by one run
Code:
adb shell cat /proc/[COLOR="Red"]the_name_you_see[/COLOR]
and choose the names that can give you partitions informations.
Here is my "proc list":
Code:
C:\Users\carliv>adb shell ls /proc
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
[HIDE]1
........
98[/HIDE] [COLOR="Red"]<- ignored[/COLOR]
aed
asound
audio
batdrv_log
boot_mode
bootprof
buddyinfo
bus
cgroups
clkmgr
cmdline
consoles
cpu
cpu_ss
cpufreq
cpuinfo
crypto
[COLOR="Red"]devices[/COLOR]
diskstats
dma-mappings
driver
[COLOR="Red"]dumchar_info[/COLOR]
emifreq
[COLOR="Red"]emmc[/COLOR]
execdomains
fat
fb
fgadc_log
filesystems
fm
freqhopping
fs
golden_setting
gpt_stat
gpufreq
interrupts
iomem
ioports
irq
kallsyms
kmsg
kpagecount
kpageflags
last_kmsg
lk_env
loadavg
locks
log_ts
mcdi
meminfo
misc
modules
[COLOR="Red"]mounts[/COLOR]
msdc_FT
msdc_debug
msdc_help
msdc_tune
msdc_tune_flag
mt_hotplug_test
mtd
mtk_battery_cmd
mtk_mdm_txpwr
mtk_sched
mtkcooler
mtkfb_size
mtktsbattery
mtktscpu
mtktspa
mtktspmic
mtktz
mtprof
net
nt35590_hd720_dsi_vdo_truly
pagetypeinfo
[COLOR="Red"]partitions[/COLOR]
pm_init
ptp
pvr
rid
sched_debug
schedstat
scsi
sd_upgrade
self
softirqs
stat
swaps
sys
sysram
sysram_flag
timer_list
tty
uid_stat
uptime
version
vmallocinfo
vmstat
wdk
wmt_tm
xlog
yaffs
zoneinfo
C:\Users\carliv>
Next open the init.{hardware}.rc from recovery folder, and you have to make some changes to be able to use sdcards and USB mass storage. Typical it looks like this:
Code:
import /init.recovery.${ro.hardware}.rc
on early-init
# Apply strict SELinux checking of PROT_EXEC on mmap/mprotect calls.
write /sys/fs/selinux/checkreqprot 0
# Set the security context for the init process.
# This should occur before anything else (e.g. ueventd) is started.
setcon u:r:init:s0
start ueventd
start healthd
on init
export PATH /sbin:/system/bin
export ANDROID_ROOT /system
export ANDROID_DATA /data
export EXTERNAL_STORAGE /sdcard
symlink /system/etc /etc
mkdir /boot
mkdir /recovery
mkdir /sdcard
mkdir /internal_sd
mkdir /external_sd
mkdir /sd-ext
mkdir /datadata
mkdir /emmc
mkdir /system
mkdir /data
mkdir /cache
mount tmpfs tmpfs /tmp
chown root shell /tmp
chmod 0775 /tmp
mkdir /mnt 0775 root system
mkdir /storage 0050 root sdcard_r
mount tmpfs tmpfs /storage mode=0050,uid=0,gid=1028
# See storage config details at http://source.android.com/tech/storage/
mkdir /mnt/shell 0700 shell shell
# Directory for putting things only root should see.
mkdir /mnt/secure 0700 root root
# Create private mountpoint so we can MS_MOVE from staging
mount tmpfs tmpfs /mnt/secure mode=0700,uid=0,gid=0
# Directory for staging bindmounts
mkdir /mnt/secure/staging 0700 root root
# Fuse public mount points.
mkdir /mnt/fuse 0700 root system
mount tmpfs tmpfs /mnt/fuse mode=0775,gid=1000
on fs
mkdir /dev/usb-ffs 0770 shell shell
mkdir /dev/usb-ffs/adb 0770 shell shell
mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18D1
write /sys/class/android_usb/android0/idProduct D001
write /sys/class/android_usb/android0/f_ffs/aliases adb
write /sys/class/android_usb/android0/functions adb
write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer}
write /sys/class/android_usb/android0/iProduct ${ro.product.model}
write /sys/class/android_usb/android0/iSerial ${ro.serialno}
on boot
ifup lo
hostname localhost
domainname localdomain
class_start default
on property:sys.powerctl=*
powerctl ${sys.powerctl}
service ueventd /sbin/ueventd
critical
seclabel u:r:ueventd:s0
service healthd /sbin/healthd -n
critical
seclabel u:r:healthd:s0
service recovery /sbin/recovery
seclabel u:r:recovery:s0
service setup_adbd /sbin/setup_adbd
oneshot
service adbd /sbin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery
disabled
socket adbd stream 660 system system
seclabel u:r:adbd:s0
service vold /sbin/minivold
socket vold stream 0660 root mount
ioprio be 2
seclabel u:r:recovery:s0
# setup_adbd will start adb once it has checked the keys
on property:service.adb.root=1
write /sys/class/android_usb/android0/enable 0
restart adbd
write /sys/class/android_usb/android0/enable 1
on property:sys.storage.ums_enabled=1
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idProduct D003
write /sys/class/android_usb/android0/functions mass_storage,adb
write /sys/class/android_usb/android0/enable 1
on property:sys.storage.ums_enabled=0
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idProduct D001
write /sys/class/android_usb/android0/functions adb
write /sys/class/android_usb/android0/enable ${service.adb.root}
but it won't mount well both sdcards because it's missing some parts. You can add those either in this file or in a separate init.recovery.{hardware}.rc file placed in /recovery/root folder. For defining sdcards take a look here, but keep in mind that is for Android system fstab, and for recovery things will be slightly different.
Few examples:
1. noemulated:
Code:
on early-init
# Apply strict SELinux checking of PROT_EXEC on mmap/mprotect calls.
write /sys/fs/selinux/checkreqprot 0
# Set the security context for the init process.
# This should occur before anything else (e.g. ueventd) is started.
setcon u:r:init:s0
start ueventd
start healthd
on init
export PATH /sbin:/system/bin
export ANDROID_ROOT /system
export ANDROID_DATA /data
[COLOR="Red"]export EXTERNAL_STORAGE /storage/sdcard0
export SECONDARY_STORAGE /storage/sdcard1[/COLOR]
symlink /system/etc /etc
mkdir /boot
mkdir /recovery
mkdir /sdcard
mkdir /internal_sd
mkdir /external_sd
mkdir /sd-ext
mkdir /datadata
[COLOR="Red"]mkdir /sdcard2[/COLOR]
mkdir /system
mkdir /cache
mkdir /data
mount tmpfs tmpfs /tmp
chown root shell /tmp
chmod 0775 /tmp
# See storage config details at http://source.android.com/tech/storage/
mkdir /mnt 0775 root system
mkdir /storage 0050 root sdcard_r
mount tmpfs tmpfs /storage mode=0050,uid=0,gid=1028
[COLOR="Red"]mkdir /mnt/media_rw/sdcard0 0700 media_rw media_rw
mkdir /mnt/media_rw/sdcard1 0700 media_rw media_rw
mkdir /storage/sdcard0 0700 root root
mkdir /storage/sdcard1 0700 root root
symlink /storage/sdcard0 /sdcard
symlink /storage/sdcard0 /mnt/sdcard
symlink /storage/sdcard1 /sdcard2
symlink /storage/sdcard1 /mnt/sdcard2[/COLOR]
mkdir /mnt/shell 0700 shell shell
# Directory for putting things only root should see.
mkdir /mnt/secure 0700 root root
# Create private mountpoint so we can MS_MOVE from staging
mount tmpfs tmpfs /mnt/secure mode=0700,uid=0,gid=0
# Directory for staging bindmounts
mkdir /mnt/secure/staging 0700 root root
# Fuse public mount points.
mkdir /mnt/fuse 0700 root system
mount tmpfs tmpfs /mnt/fuse mode=0775,gid=1000
on fs
mkdir /dev/usb-ffs 0770 shell shell
mkdir /dev/usb-ffs/adb 0770 shell shell
mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18D1
write /sys/class/android_usb/android0/idProduct [COLOR="Red"]D003[/COLOR]
write /sys/class/android_usb/android0/f_ffs/aliases adb
[COLOR="Red"]write /sys/class/android_usb/android0/functions mass_storage,adb[/COLOR]
write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer}
write /sys/class/android_usb/android0/iProduct ${ro.product.model}
write /sys/class/android_usb/android0/iSerial ${ro.serialno}
on boot
ifup lo
hostname localhost
domainname localdomain
class_start default
on property:sys.powerctl=*
powerctl ${sys.powerctl}
service ueventd /sbin/ueventd
critical
seclabel u:r:ueventd:s0
service healthd /sbin/healthd -n
critical
seclabel u:r:healthd:s0
service recovery /sbin/recovery
seclabel u:r:recovery:s0
service setup_adbd /sbin/setup_adbd
oneshot
service adbd /sbin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery
disabled
socket adbd stream 660 system system
seclabel u:r:adbd:s0
service vold /sbin/minivold
socket vold stream 0660 root mount
ioprio be 2
seclabel u:r:recovery:s0
[COLOR="Red"]# virtual sdcard daemon running as media_rw (1023)
service fuse_sdcard0 /system/bin/sdcard -u 1023 -g 1023 -w 1023 -d /mnt/media_rw/sdcard0 /storage/sdcard0
class late_start
disabled
# virtual sdcard daemon running as media_rw (1023)
service fuse_sdcard1 /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/sdcard1 /storage/sdcard1
class late_start
disabled[/COLOR]
# setup_adbd will start adb once it has checked the keys
on property:service.adb.root=1
write /sys/class/android_usb/android0/enable 0
restart adbd
write /sys/class/android_usb/android0/enable 1
on property:sys.storage.ums_enabled=1
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idProduct D003
write /sys/class/android_usb/android0/functions mass_storage,adb
write /sys/class/android_usb/android0/enable 1
on property:sys.storage.ums_enabled=0
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idProduct D001
write /sys/class/android_usb/android0/functions adb
write /sys/class/android_usb/android0/enable ${service.adb.root}
2. one emulated:
Code:
on early-init
# Apply strict SELinux checking of PROT_EXEC on mmap/mprotect calls.
write /sys/fs/selinux/checkreqprot 0
# Set the security context for the init process.
# This should occur before anything else (e.g. ueventd) is started.
setcon u:r:init:s0
start ueventd
start healthd
on init
export PATH /sbin:/system/bin
export ANDROID_ROOT /system
export ANDROID_DATA /data
[COLOR="Red"]export EXTERNAL_STORAGE /storage/sdcard0[/COLOR]
symlink /system/etc /etc
[COLOR="Red"]symlink /data/media/0 /storage/sdcard0[/COLOR]
mkdir /boot
mkdir /recovery
mkdir /sdcard
mkdir /internal_sd
mkdir /external_sd
mkdir /sd-ext
mkdir /datadata
mkdir /system
mkdir /emmc
mkdir /cache
mkdir /data
mount tmpfs tmpfs /tmp
chown root shell /tmp
chmod 0775 /tmp
# See storage config details at http://source.android.com/tech/storage/
mkdir /mnt 0775 root system
mkdir /storage 0050 root sdcard_r
mount tmpfs tmpfs /storage mode=0050,uid=0,gid=1028
mkdir /mnt/shell 0700 shell shell
# Directory for putting things only root should see.
mkdir /mnt/secure 0700 root root
# Create private mountpoint so we can MS_MOVE from staging
mount tmpfs tmpfs /mnt/secure mode=0700,uid=0,gid=0
# Directory for staging bindmounts
mkdir /mnt/secure/staging 0700 root root
# Fuse public mount points.
mkdir /mnt/fuse 0700 root system
mount tmpfs tmpfs /mnt/fuse mode=0775,gid=1000
on fs
mkdir /dev/usb-ffs 0770 shell shell
mkdir /dev/usb-ffs/adb 0770 shell shell
mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
write /sys/class/android_usb/android0/enable 0
[COLOR="Red"]write /sys/class/android_usb/android0/idVendor 0BB4
write /sys/class/android_usb/android0/idProduct 0C03[/COLOR]
write /sys/class/android_usb/android0/f_ffs/aliases adb
[COLOR="Red"]write /sys/class/android_usb/android0/functions mass_storage,adb[/COLOR]
write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer}
write /sys/class/android_usb/android0/iProduct ${ro.product.model}
write /sys/class/android_usb/android0/iSerial ${ro.serialno}
on boot
ifup lo
hostname localhost
domainname localdomain
class_start default
on property:sys.powerctl=*
powerctl ${sys.powerctl}
service ueventd /sbin/ueventd
critical
seclabel u:r:ueventd:s0
service healthd /sbin/healthd -n
critical
seclabel u:r:healthd:s0
service recovery /sbin/recovery
seclabel u:r:recovery:s0
service setup_adbd /sbin/setup_adbd
oneshot
service adbd /sbin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery
disabled
socket adbd stream 660 system system
seclabel u:r:adbd:s0
service vold /sbin/minivold
socket vold stream 0660 root mount
ioprio be 2
seclabel u:r:recovery:s0
# setup_adbd will start adb once it has checked the keys
on property:service.adb.root=1
write /sys/class/android_usb/android0/enable 0
restart adbd
write /sys/class/android_usb/android0/enable 1
on property:sys.storage.ums_enabled=1
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idProduct 0C03
write /sys/class/android_usb/android0/functions mass_storage,adb
write /sys/class/android_usb/android0/enable 1
on property:sys.storage.ums_enabled=0
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idProduct 0C01
write /sys/class/android_usb/android0/functions adb
write /sys/class/android_usb/android0/enable ${service.adb.root}
3. one emulated and one noemulated:
Code:
on early-init
# Apply strict SELinux checking of PROT_EXEC on mmap/mprotect calls.
write /sys/fs/selinux/checkreqprot 0
# Set the security context for the init process.
# This should occur before anything else (e.g. ueventd) is started.
setcon u:r:init:s0
start ueventd
start healthd
on init
export PATH /sbin:/system/bin
export ANDROID_ROOT /system
export ANDROID_DATA /data
[COLOR="Red"]export EXTERNAL_STORAGE /storage/sdcard0
export SECONDARY_STORAGE /storage/sdcard1[/COLOR]
symlink /system/etc /etc
[COLOR="Red"]symlink /data/media/0 /storage/sdcard0[/COLOR]
mkdir /boot
mkdir /recovery
mkdir /sdcard
mkdir /internal_sd
mkdir /external_sd
mkdir /sd-ext
[COLOR="Red"]mkdir /sdcard2[/COLOR]
mkdir /datadata
mkdir /system
mkdir /emmc
mkdir /cache
mkdir /data
mount tmpfs tmpfs /tmp
chown root shell /tmp
chmod 0775 /tmp
# See storage config details at http://source.android.com/tech/storage/
mkdir /mnt 0775 root system
mkdir /storage 0050 root sdcard_r
mount tmpfs tmpfs /storage mode=0050,uid=0,gid=1028
[COLOR="Red"]mkdir /mnt/media_rw/sdcard1 0700 media_rw media_rw
mkdir /mnt/shell 0700 shell shell
mkdir /storage/sdcard1 0700 root root
symlink /storage/sdcard1 /mnt/sdcard2[/COLOR]
# Directory for putting things only root should see.
mkdir /mnt/secure 0700 root root
# Create private mountpoint so we can MS_MOVE from staging
mount tmpfs tmpfs /mnt/secure mode=0700,uid=0,gid=0
# Directory for staging bindmounts
mkdir /mnt/secure/staging 0700 root root
# Fuse public mount points.
mkdir /mnt/fuse 0700 root system
mount tmpfs tmpfs /mnt/fuse mode=0775,gid=1000
on fs
mkdir /dev/usb-ffs 0770 shell shell
mkdir /dev/usb-ffs/adb 0770 shell shell
mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
write /sys/class/android_usb/android0/enable 0
[COLOR="Red"]write /sys/class/android_usb/android0/idVendor 0BB4
write /sys/class/android_usb/android0/idProduct 0C03[/COLOR]
write /sys/class/android_usb/android0/f_ffs/aliases adb
[COLOR="Red"]write /sys/class/android_usb/android0/functions mass_storage,adb[/COLOR]
write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer}
write /sys/class/android_usb/android0/iProduct ${ro.product.model}
write /sys/class/android_usb/android0/iSerial ${ro.serialno}
on boot
ifup lo
hostname localhost
domainname localdomain
class_start default
on property:sys.powerctl=*
powerctl ${sys.powerctl}
service ueventd /sbin/ueventd
critical
seclabel u:r:ueventd:s0
service healthd /sbin/healthd -n
critical
seclabel u:r:healthd:s0
service recovery /sbin/recovery
seclabel u:r:recovery:s0
service setup_adbd /sbin/setup_adbd
oneshot
service adbd /sbin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery
disabled
socket adbd stream 660 system system
seclabel u:r:adbd:s0
service vold /sbin/minivold
socket vold stream 0660 root mount
ioprio be 2
seclabel u:r:recovery:s0
[COLOR="Red"]
# virtual sdcard daemon running as media_rw (1023)
service fuse_sdcard1 /system/bin/sdcard -u 1023 -g 1023 -w 1023 -d /mnt/media_rw/sdcard1 /storage/sdcard1
class late_start
disabled[/COLOR]
# setup_adbd will start adb once it has checked the keys
on property:service.adb.root=1
write /sys/class/android_usb/android0/enable 0
restart adbd
write /sys/class/android_usb/android0/enable 1
on property:sys.storage.ums_enabled=1
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idProduct 0C03
write /sys/class/android_usb/android0/functions mass_storage,adb
write /sys/class/android_usb/android0/enable 1
on property:sys.storage.ums_enabled=0
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idProduct 0C01
write /sys/class/android_usb/android0/functions adb
write /sys/class/android_usb/android0/enable ${service.adb.root}
As you can see, for external sdcard (/storage/sdcard1), when it exists, the read write permissions include also "other/world" (-w 1023), but for internal sdcard, either emulated or not, only user and group have permissions.
If you want to use a separate init.recovery.{hardware}.rc file, just copy the extra stuff from these init.{hardware}.rc examples compared with default init.rc and keep same triggers (on init, on fs, on boot, etc.). Example for both sdcards noemulated, the init.recovery.{hardware}.rc file could look like this:
Code:
on init
export EXTERNAL_STORAGE /storage/sdcard0
export SECONDARY_STORAGE /storage/sdcard1
mkdir /sdcard2
# See storage config details at http://source.android.com/tech/storage/
mkdir /mnt/media_rw/sdcard0 0700 media_rw media_rw
mkdir /mnt/media_rw/sdcard1 0700 media_rw media_rw
mkdir /storage/sdcard0 0700 root root
mkdir /storage/sdcard1 0700 root root
symlink /storage/sdcard0 /sdcard
symlink /storage/sdcard0 /mnt/sdcard
symlink /storage/sdcard1 /sdcard2
symlink /storage/sdcard1 /mnt/sdcard2
on fs
write /sys/class/android_usb/android0/functions mass_storage,adb
on boot
# virtual sdcard daemon running as media_rw (1023)
service fuse_sdcard0 /system/bin/sdcard -u 1023 -g 1023 -w 1023 -d /mnt/media_rw/sdcard0 /storage/sdcard0
class late_start
disabled
# virtual sdcard daemon running as media_rw (1023)
service fuse_sdcard1 /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/sdcard1 /storage/sdcard1
class late_start
disabled
One other thing to check is your device "idVendor" and "idProduct":
Code:
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18D1
write /sys/class/android_usb/android0/idProduct [COLOR="Red"]D003[/COLOR]
write /sys/class/android_usb/android0/f_ffs/aliases adb
[COLOR="Red"]write /sys/class/android_usb/android0/functions mass_storage,adb[/COLOR]
Initial was:
Code:
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18D1
write /sys/class/android_usb/android0/idProduct D001
write /sys/class/android_usb/android0/f_ffs/aliases adb
write /sys/class/android_usb/android0/functions adb
but I changed that to activate mass storage function from start. That is up to you, but in any case you need to check those numbers. The "18D1" and "D001", "D003" are ok if you have google usb drivers installed, but also you can use specific vendor and product Ids. These can be found in boot unpacked ramdisk, in init.usb.rc file.
And for the next step, open BoardConfig.mk file. For now it looks like this:
Code:
USE_CAMERA_STUB := true
# inherit from the proprietary version
-include vendor/lenovo/P780/BoardConfigVendor.mk
TARGET_ARCH := arm
TARGET_NO_BOOTLOADER := true
TARGET_BOARD_PLATFORM := unknown
TARGET_CPU_ABI := armeabi-v7a
TARGET_CPU_ABI2 := armeabi
TARGET_ARCH_VARIANT := armv7-a-neon
TARGET_CPU_VARIANT := cortex-a7
TARGET_CPU_SMP := true
ARCH_ARM_HAVE_TLS_REGISTER := true
TARGET_BOOTLOADER_BOARD_NAME := P780
BOARD_KERNEL_CMDLINE :=
BOARD_KERNEL_BASE := 0x10000000
BOARD_KERNEL_PAGESIZE := 2048
# fix this up by examining /proc/mtd on a running device
BOARD_BOOTIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_RECOVERYIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_USERDATAIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_FLASH_BLOCK_SIZE := 131072
TARGET_PREBUILT_KERNEL := device/lenovo/P780/kernel
BOARD_HAS_NO_SELECT_BUTTON := true
So, we have to make some changes. First, if the mkvendor script didn't get your platform
Code:
TARGET_BOARD_PLATFORM := unknown
add it as you have in fstab.{hardware} and init.{hardware}.rc.
If you don't know your hardware, get it with adb:
Code:
adb shell cat /proc/cpuinfo
and you will find the hardware.
For me it is:
Code:
Processor : ARMv7 Processor rev 2 (v7l)
processor : 0
BogoMIPS : 2439.94
Features : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpv4 idiva idivt
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 2
[COLOR="Blue"]Hardware[/COLOR] : [COLOR="Red"]MT6589[/COLOR]
Revision : 0000
Serial : 0000000000000000
and I changed that line like this
Code:
TARGET_BOARD_PLATFORM := [COLOR="Red"]mt6589[/COLOR]
Next there are partitions size defines:
Code:
# fix this up by examining /proc/mtd on a running device
BOARD_BOOTIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_RECOVERYIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_USERDATAIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_FLASH_BLOCK_SIZE := 131072
Do what they say, using "adb shell cat /proc/mtd" or "adb shell cat /proc/emmc" or "adb shell cat /proc/dumchar_info" for a MTK phone, and replace every partition size with the correct value. For me it is:
Code:
# Partition sizes
BOARD_BOOTIMAGE_PARTITION_SIZE := 6291456
BOARD_RECOVERYIMAGE_PARTITION_SIZE := 6291456
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 939524096
BOARD_USERDATAIMAGE_PARTITION_SIZE := 1283457024
BOARD_FLASH_BLOCK_SIZE := 512
The board flash block size is specific to your platform. In MTK phones, that is usually 512, but it will work with default 131072 value too.
Also you can add here
Code:
TARGET_USERIMAGES_USE_EXT4 := true
if your phone uses ext4 file system (check in fstab or default.prop in boot.img ramdisk).
Next line that has to be corrected is
Code:
TARGET_PREBUILT_KERNEL := device/lenovo/P780/kernel
Remember you have the kernel now in prebuilt subfolder, so it should be:
Code:
TARGET_PREBUILT_KERNEL := device/lenovo/P780/prebuilt/kernel
In some cases you may need to use another flag:
Code:
TARGET_RECOVERY_PIXEL_FORMAT := "RGBX_8888"
if your phone has a custom PIXEL FORMAT. You need to find out that, or if the flag is not used you may see the recovery doesn't boot.
Now let's add the custom fstab and init.rc
Code:
TARGET_RECOVERY_INITRC := device/lenovo/P780/recovery/init.{hardware}.rc
TARGET_RECOVERY_FSTAB := device/lenovo/P780/recovery/recovery.fstab
for me it is
Code:
TARGET_RECOVERY_INITRC := device/lenovo/P780/recovery/init.mt6589.rc
TARGET_RECOVERY_FSTAB := device/lenovo/P780/recovery/recovery.fstab
If you want to use init.recovery.{hardware}.rc and you have that in /recovery/root folder, skip the first flag and use only
Code:
TARGET_RECOVERY_FSTAB := device/lenovo/P780/recovery/recovery.fstab
The path /device/lenovo/P780 is for my example; you should use your device path here.
And last, if you don't want to build regular CWM, you can use recovery variant flag. This way you can add a custom recovery folder in your bootable folder along with default "recovery" and "recovery-cm". You can use here what you want: recovery-twrp, recovery-philz or recovery-carliv. For every one you should check their threads and author's instructions for additional flags or modifications in BoardConfig or device tree.
Build a CWM-based Recovery
So if you want to build a stock Clockworkmod Recovery, you will use the default recovery from Cyanogenmod 11 building tree.
But if you want to build a CWM variant or custom you have to use a flag on BoardConfig, corresponding to that custom recovery folder: recovery-cm, recovery-twrp, recovery-philz, recovery-miui, etc. Place that flag on BoardConfig:
Code:
RECOVERY_VARIANT := twrp
or
Code:
RECOVERY_VARIANT := philz
and same goes for the other variants too.
If your phone is one with MTK platform,
you may need one more flag:
Code:
BOARD_CUSTOM_BOOTIMG_MK := device/lenovo/P780/mkmtkbootimg.mk
to append MTK header to compiled image. Remmember that the prebuilt kernel has MTK header stripped off and if you use the recovery image built without MTK header, it won't work. For correct this we will use a custom file developed by chrmhoffmann and inspired by bgcngm's mtk-tools scripts, which I named mkmtkbootimg.mk. There are some other custom boot makers for MTK phones (one is developed by Omnirom team for Oppo R819), but this one is the best for me. Copy it in your device folder if your phone is a MTK - or create a new mk file and paste the content in it, then add that BOARD_CUSTOM_BOOTIMG_MK flag. Even if you don't have a MTK phone you may need to use a custom boot maker script, as I saw in LG phones.
For MTK phones again, if you don't want to use a custom boot image maker, you can build normal, but after build is finished, take the recovery.img and using my CarlivImageKitchen, open a terminal in that folder and type:
Code:
./unpack_img recovery.img
and then
Code:
./repack_MTK_img recovery
to make it compatible with MTK phones (my utility will append the MTK header to kernel and ramdisk).
Anyway using a custom boot image maker file is a better solution.
Other thing you can add is this flag:
Code:
TARGET_RECOVERY_LCD_BACKLIGHT_PATH := \"/sys/devices/platform/leds-mt65xx/leds/lcd-backlight/brightness\"
Search in your phone with a root explorer the path for lcd-backlight (usually in /sys/devices/platform/leds something.... This is for recoveries that needs it (twrp, philz).
Also you can use a custom font for recovery. Take a look in /bootable/recovery or recovery-variant/minui folder and choose one. There are few fonts file with 00x00 in name: those are with and height for a character, so you know how to choose one for your screen resolution. As an example, for a screen res of 540x960 the best view is with "roboto_15x24.h" font.
Define it like this:
Code:
BOARD_USE_CUSTOM_RECOVERY_FONT := \"roboto_15x24.h\"
Finally now my BoardConfig looks like this:
Code:
USE_CAMERA_STUB := true
# inherit from the proprietary version
-include vendor/lenovo/P780/BoardConfigVendor.mk
TARGET_ARCH := arm
TARGET_NO_BOOTLOADER := true
TARGET_BOARD_PLATFORM := mt6589
TARGET_CPU_ABI := armeabi-v7a
TARGET_CPU_ABI2 := armeabi
TARGET_ARCH_VARIANT := armv7-a-neon
TARGET_CPU_VARIANT := cortex-a7
TARGET_CPU_SMP := true
ARCH_ARM_HAVE_TLS_REGISTER := true
TARGET_BOOTLOADER_BOARD_NAME := P780
BOARD_KERNEL_CMDLINE :=
BOARD_KERNEL_BASE := 0x10000000
BOARD_KERNEL_PAGESIZE := 2048
# fix this up by examining /proc/mtd on a running device
BOARD_BOOTIMAGE_PARTITION_SIZE := 6291456
BOARD_RECOVERYIMAGE_PARTITION_SIZE := 6291456
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 939524096
BOARD_USERDATAIMAGE_PARTITION_SIZE := 1283457024
BOARD_FLASH_BLOCK_SIZE := 512
TARGET_USERIMAGES_USE_EXT4 := true
TARGET_PREBUILT_KERNEL := device/lenovo/P780/prebuilt/kernel
TARGET_RECOVERY_INITRC := device/lenovo/P780/recovery/init.mt6589.rc
TARGET_RECOVERY_FSTAB := device/lenovo/P780/recovery/recovery.fstab
BOARD_HAS_NO_SELECT_BUTTON := true
BOARD_CUSTOM_BOOTIMG_MK := device/lenovo/P780/mkmtkbootimg.mk
BOARD_USE_CUSTOM_RECOVERY_FONT := \"font_17x33.h\"
DEVICE_RESOLUTION := 720x1280
TARGET_RECOVERY_LCD_BACKLIGHT_PATH := \"/sys/devices/platform/leds-mt65xx/leds/lcd-backlight/brightness\"
This is it, the device tree is done, good to build a recovery now, and you can add on it what you need to make it build a full ROM. We made now only the base of the device tree.
It's time to start building.
Back to cm11 building tree folder, open a terminal in it and initialize the building environment:
Code:
. build/envsetup.sh
You can see that my device is included. Next lunch device configuration
Code:
lunch cm_P780-eng
and start making recovery
Code:
make -j4 recoveryimage
The j number here is how many jobs you want your processor to do at same time. This has to be equivalent or +1,+2 with your CPU cores (from computer not phone).
At the end if everything goes well you will see this
or this, if the phone is a MTK and you use a custom boot image maker
And the new recovery ramdisk will be like this:
Errors
During the build process you may encounter some errors or warnings.
*********************
Code:
cp: cannot stat `/home/carliv/CM11-0/out/target/product/P780/root/[COLOR="Red"]init.recovery.*.rc': No such file or directory[/COLOR]
make: [/home/carliv/CM11-0/out/target/product/P780/recovery/root.ts] Error 1 (ignored)
This will not stop the build, and it appears if you don't use a init.recovery.{hardware}.rc file. Can be ignored, as the build process does.
**********************
Code:
[COLOR="Red"]find: `bootable/recovery/res-720': No such file or directory
No private recovery resources for TARGET_DEVICE P780[/COLOR]
This appears because of the following part from /build/core/Makefile
Code:
ifeq ($(TARGET_RECOVERY_SCREEN_WIDTH),)
ifeq ($(TARGET_SCREEN_WIDTH),)
TARGET_RECOVERY_SCREEN_WIDTH := 720
else
TARGET_RECOVERY_SCREEN_WIDTH := $(TARGET_SCREEN_WIDTH)
endif
endif
.......
ifeq ($(recovery_resources_private),)
$(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
endif
Also safe to ignore.
**********************
Code:
[COLOR="Red"]'cortex-a7' is not a recognized processor for this target (ignoring processor)[/COLOR]
If you're building for a MTK phone at the end you will see lots of these. The MTK platforms are not registered for cortex-7 arm processors, so that's the reason.
No problem, safe to ignore.
**********************
Code:
Checking build tools versions...
/home/carliv/CM11-0/out/target/product/P780/obj/APPS/SignatureTest_intermediates
"ebtables is disabled on this build"
[COLOR="Red"]find: `src': No such file or directory[/COLOR]
This one appears only in kitkat builds (all of them: AOSP, CM 11, Omnirom, CarbonRom, etc.) at start of building, and is generated by a missing src folder under /frameworks/base/tests/TileBenchmark. It was there until Android 4.3 (cm 10.2),
but is gone in any 4.4 building tree. I can't tell if this is an omission or that has to be, but if that is the way to be, then why the res folder is still there and in Android.mk file that src folder is called?
To solve this you have two solutions:
One is to edit the Android.mk file in TileBenchmark, and to change this
Code:
LOCAL_SRC_FILES := $(call all-java-files-under, src)
into this
Code:
LOCAL_SRC_FILES :=
or to copy that src folder from cm-10.2 TileBenchmark (it's not any difference between the two folders except the missing src in cm-11.0).
Well, you don't have to fix this error if you don't want to. It's safe to be ignored too, and won't stop the build.
**********************
Code:
[email protected]:~/CM11-0$ lunch cm_P780-eng
build/core/product_config.mk:239: *** _nic.PRODUCTS.[[device/Lenovo/P780/cm.mk]]: "device/lenovo/P780/device_P780.mk" does not exist. Stop.
Device P780 not found. Attempting to retrieve device repository from CyanogenMod Github (http://github.com/CyanogenMod).
Repository for P780 not found in the CyanogenMod Github repository list. If this is in error, you may need to manually add it to your local_manifests/roomservice.xml.
build/core/product_config.mk:239: *** _nic.PRODUCTS.[[device/Lenovo/P780/cm.mk]]: "device/lenovo/P780/device_P780.mk" does not exist. Stop.
** Don't have a product spec for: 'cm_P780'
** Do you have the right repo manifest?
[email protected]:~/CM11-0$
This one is serious, and will stop anything, you can't use lunch command. The reason? Keep in mind that the process is case sensitive, and my "mistake" is that instead of manufacturer name "lenovo" I used "Lenovo". So if this appears and you know you did setup the device tree right, check folders names and also all paths in device tree files:
Code:
device/lenovo/P780/
Check to see if there are missing letters or are uppercase where it should be lowercase, and so on.
This one you can't ignore and you have to solve it.
Look after I "correct" the folder's name:
Code:
[email protected]:~/CM11-0$ lunch cm_P780-eng
Trying dependencies-only mode on a non-existing device tree?
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.4.4
CM_VERSION=
TARGET_PRODUCT=cm_P780
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=cortex-a7
HOST_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.13.0-43-generic-x86_64-with-Ubuntu-12.04-precise
HOST_BUILD_TYPE=release
BUILD_ID=KTU84Q
OUT_DIR=/home/carliv/CM11-0/out
============================================
[email protected]:~/CM11-0$
The End! Happy building custom recoveries!
Enjoy!
I will surely try this when i hav tym .... Seriously ... Lot of work put in this.. Keep it up!!
Sent from my Micromax A88 using XDA Premium 4 mobile app
Thanks a lot for the detailed guide sir ^_^
1) can't we use parted cm-11 source instead of full cm-11 source? just like sir yuweng did in his philz recovery compilation guide? it will save us a lot of time & storage...
2) for mediatek devices, ro.serialno=null if we getprop it in recovery mode, so using this command in init.rc
write /sys/.../iSerial ${ro.serialno}
will set the wrong serial number for our device, i found the real path of mtk device serial number file
So i used this command in init.rc
cat /sys/sys_info/serial_number /sys/devices/virtual/android_usb/android0/iSerial
it didn't worked via init.rc, but if i execute the same command via terminal, it works... Why its not working via init.rc?
3)There is a strange issue with my mt6589 device (if i use stock kitkat kernel) these commands in init.rc have no effect
write /sys/class/android_usb/*
(e.g. write /sys/class/android_usb/android0/idProduct 0C03)
after a little bit of investigation i saw only symlinked paths are unaccessible by recovery, so i replaced those symlinked paths with real paths in init.rc
e.g. changed this
write /sys/class/android_usb/android0/idProduct 0C03
into this
write /sys/devices/virtual/android_usb/android0/idProduct 0C03
And it worked...
4) strangest issue, if [email protected] partition gets mounted within approximately 30 seconds after first bootup in recovery mode, it becomes busy even if we try to umount it, an error msg says unable to unmount /data partition, device or resource is busy... i cant unmount it even if i try to forcefully unmount it using "umount -f /data" in recovery terminal... The only command which works is, "umount -l /data"
What i want to know here is, how can i find what is keeping it busy? lsof, fuser are not workin too... is there any way i can mount and then unmount it on every bootup by adding some commands in init.rc? i cant even format data partition when it happens, same error message appears
i am using TWRP-2.8.2.0 (tried every version of TWRP 2.5.0 - 2.8.2.0)
EnerJon said:
Thanks a lot for the detailed guide sir ^_^
1) can't we use parted cm-11 source instead of full cm-11 source? just like sir yuweng did in his philz recovery compilation guide? it will save us a lot of time & storage...
2) for mediatek devices, ro.serialno=null if we getprop it in recovery mode, so using this command in init.rc
write /sys/.../iSerial ${ro.serialno}
will set the wrong serial number for our device, i found the real path of mtk device serial number file
So i used this command in init.rc
cat /sys/sys_info/serial_number /sys/devices/virtual/android_usb/android0/iSerial
it didn't worked via init.rc, but if i execute the same command via terminal, it works... Why its not working via init.rc?
3)There is a strange issue with my mt6589 device (if i use stock kitkat kernel) these commands in init.rc have no effect
write /sys/class/android_usb/*
(e.g. write /sys/class/android_usb/android0/idProduct 0C03)
after a little bit of investigation i saw only symlinked paths are unaccessible by recovery, so i replaced those symlinked paths with real paths in init.rc
e.g. changed this
write /sys/class/android_usb/android0/idProduct 0C03
into this
write /sys/devices/virtual/android_usb/android0/idProduct 0C03
And it worked...
4) strangest issue, if [email protected] partition gets mounted within approximately 30 seconds after first bootup in recovery mode, it becomes busy even if we try to umount it, an error msg says unable to unmount /data partition, device or resource is busy... i cant unmount it even if i try to forcefully unmount it using "umount -f /data" in recovery terminal... The only command which works is, "umount -l /data"
What i want to know here is, how can i find what is keeping it busy? lsof, fuser are not workin too... is there any way i can mount and then unmount it on every bootup by adding some commands in init.rc? i cant even format data partition when it happens, same error message appears
i am using TWRP-2.8.2.0 (tried every version of TWRP 2.5.0 - 2.8.2.0)
Click to expand...
Click to collapse
Sure, I think you can use the partial source, just like my friend yuweng wrote in his thread. I mention here a full repo sync because I'm thinking of this as a base for further development, not just building recovery. As you can see, I presented the official method with my additions and some updates.
About the other things, I can't say anything yet, I would like to see your kitkat stock boot and recovery image, and that twrp you've compiled. Can you post them here attached?
I will take a look and I will say my opinion after.
By the way, did you tried other recovery? Philz or CWM? What phone do you have?
Wow this is nice. Very nice write up
Bro please tell in 51.android rules for mtp devices we have to enter this following code :
But for qualcomm we have to enter the following command or not please give example for any htc qualcomm device
raveeshwadhawan said:
Bro please tell in 51.android rules for mtp devices we have to enter this following code :
But for qualcomm we have to enter the following command or not please give example for any htc qualcomm device
Click to expand...
Click to collapse
Check again that part and read the text under instruction for MTK in 51-android rules.
I got it now but stuck at jdk... For qualcomm after dual setup of jdk 7 and sun jdk 1.6 and after entering that update alternative we have to edit mbldenv.sh or not or have to setuo java alternatives??
U know repo sync require high speed internet and I have very slow internet connection is there any way to compress it I just want to compile recovery... Plz help me in making recovery

sbase for Android: tiny, full featured binaries and source code

These are a downstream distribution of the "suckless" binaries found at http://git.2f30.org/
They can be used as improved shell or in your application, root or otherwise.
A more reliable way to run native functionality than through Busybox.
For more information, access to source code and binaries, I suggest you head to http://fusion.github.io/sbase-for-android/
Here is a list of binaries currently available, source code included -- MIT license:
basename cal cat chgrp chmod chown chroot cksum cmp col cols comm cp cron
cut date dirname du echo env expand expr false find fold grep head kill
link ln logname ls md5sum mkdir mkfifo mktemp mv nice nl nohup paste
printenv printf pwd readlink renice rm rmdir sed seq setsid sha1sum
sha256sum sha512sum sleep sort split sponge strings sync tail tar tee
test time touch tr true tty uname unexpand uniq unlink uudecode uuencode
wc xargs yes
clear df dmesg halt id
lsusb mknod mkswap pagesize pidof respawn stat
sysctl truncate watch
Click to expand...
Click to collapse

Categories

Resources