Related
Hi, I haven't seen any good resources for how to edit edify scripts, so I thought I would create this thread so we can pool our knowledge on the subject.
Intro
Inside your typical CWM zip there is a folder called META-INF, inside that there is a folder called com and come CERT files, inside that com folder there is a google folder, inside that is an android folder containing an update-binary file and an updater-script. If you only see an update-script, that means you are back in the Android 1.5 era and need to move on.
The updater-script
The updater-script file is a text file, it is linux formatted with regard to end of line conventions. If you use Windows then you have to edit the file using a program that keeps line feeds the way they are and has options for doing the conversion from <CR><LF> to just <LF>.
Like lisp, the contents of the text file evaluate to one big expression, but it does have the ";" end of command convention to make things more familiar, it just means perform the action on the left. (ref. google source README) You can ignore that and just treat everything as a series of commands for all practical purposes. I mention it because you need not worry about having too large a procedural block or worry about having extra spaces or worry about ending on a line boundary. You could have your entire script on one giant line and it wouldn't matter.
There are around a dozen commands, it's not terribly difficult to learn.
The updater-binary
There are a lot of updater-binary files out there in the wild, each manufacturer basically compiles there own with every other OTA update. Success in flashing your CWM zip is determined by picking the right one that works with what you are trying to do. If your knowledge says mount needs 4 arguments and the binary only supports 3, then you need to change your script to use 3 and vice versa. If you are trying to flash a radio, the updater-binary might have been recompiled to allow for that specific functionality and you will get a status 6 error when trying to flash it unless you use that update-binary. You will see the write_raw_image() function not supporting "/dev/block/mmcblk0p8" but instead "logo.bin".
However, by and large, the generic functionality is the same across the board.
Updater-script functions (In order of interest)
ui_print(msg1, .. msgN); This is the means you have to display something on the screen in CWM, it takes a series of comma separated arguments, each comma needs to have a space after it, this applies to all commands.
Ex. ui_print("Your version is: ", file_getprop("/system/build.prop", "ro.build.id"));
show_progress(TOTALAMOUNT, TIMEINSEC); This command and the following command control what you see in the progress bar at the bottom. It is not necessary to use it, it's just another way to display information.TIMEINSEC refers to how long it will take for the progress bar to move to the AMOUNT specified. You would use this perhaps when something is taking a long time, you know approximately how long and want the screen to keep showing something while it is going on. If you use zero for TIME then nothing is done, you have just set the maximum amount for use with set_progress. The amount is a decimal number, 0.5 would be half the progress bar being filled.
Ex. show_progress("0.300000", 10);
set_progress(AMOUNT); This command sets the pointer or fill amount of the progress bar according to the last show_progress command. It should never be greater than the total of the show_progress amount.
Ex. show_progress("0.300000", 0);
set_progress("0.15");
mount(TYPE, DEV, PATH); This is one version of the mount command. The TYPE arg is usually "MTD", which refers to memory technology device. The DEV for a MTD would be something like "system", "userdata", "cache", and the PATH would be "/system", "/data", or "/cache". You will also see TYPE be "vfat".
mount(FSTYPE, TYPE, DEV, PATH); This seems to be the more current mount command. It adds in the file system type. Ex. "ext3", "yaffs". TYPE with this command can be "MTD" or "EMMC". You would use "EMMC" with "/dev/block/mmcblk0p8".
umount(PATH); This simply removes a previous mounted PATH from the system. Ex. umount("/system"); You'll notice the double quotes around command arguments, they are not strictly necessary. Unless it's a reserved word (if then else endif) then they can be anything. "consisting of only letters, numbers, colons, underscores, slashes, and periods". So if you just spend 10 minutes uploading your zip to your phone and notice that your unmount command is umount(/system);, it will work just fine.
sleep(SECS); Simply pauses for SECS seconds.
package_extract_file(FILE, FILEWITHPATH); This command extracts one of your files from the CWM zip package and save it to the phone.
Ex. package_extract_file("bootanimation.zip", "/system/media/bootanimation.zip");
package_extract_dir(ZIPPATH, PATH); This command extracts an entire folder in your CWM zip to a folder on your phone.
Ex. package_extract_dir("system", "/system"); *This is where having system mounted would be handy, without it being mounted, the files would be copied to the ramdisk /system.
write_raw_image(PATH, PARTITION); This is one of those tricky ones, the PATH is somewhere on your phone with the image to be flashed to a PARTITION on your phone. The trouble is, how do you specify what partition gets flashed? Is there any restriction on where the file has to be? If MTD conventions are used, you are looking for "system", "boot", "recovery", "logo.bin". (All this means that each partition has a name stored somewhere, and if you know it, you can write to it.) Maybe it will accept device references like /dev/block/mmcblk0p8. This depends on the update-binary file you are using.
Ex. write_raw_image("/tmp/logo.bin", "logo.bin");
Ex. write_raw_image("/tmp/logo.bin", "/dev/block/mmcblk0p8");
write_firmware_image(PATH, PARTITION); You would think it would be the same as write_raw_image. Not sure what the difference is.
run_program(PROG, ARG1, .., ARGN); Pretty self explanatory, This command allows you to execute a program or script on the phone. Instead of all the bits of the command being separated by spaces, commas are used. It returns an error code as a string.
Ex. run_command("ls", "-R", "/system");
Assert(condition); You'll see this one a lot in OTA updates, all it does is abort the script if something goes wrong. If condition is false, the script ends displaying a description on the phone of what command caused the exit. You can put in more than one statement here, separated by ";", if any one of them returns with an error, the script exits.
Ex. Assert(mount("ext3", "EMCC", "/dev/block/mmcblk0p12", "/system")); *If you can't mount /system and your CWM zip only writes to system, you might as well stop it before continuing on to write to the ramdisk.
ifelse(condition, true path, false path); This is your basic conditional statement, the tricky bit is to figure out what statements in edify can trigger a true of false condition. As for the rest of it, the commas separate the two blocks.
Ex. ifelse(file_getprop("/system/default.prop", "ro.build.id") == "OLYFR1.2.3.4", ui_print("yes"), ui_print("false"));
abort(); This stops the script, useful with ifelse.
file_getprop(PATH, VALUE); This command looks for a text file containing A=B pairs and returns B if it can find an A.
Ex. file bob.txt exists in /tmp, it contains cool=yes, and dorky=true123 each on separate lines.
file_getprop("/tmp/bob.txt", "cool") == "yes"
file_getprop("/tmp/bob.txt", "dorky") == "true123"
getprop(VALUE); Functions the same as file_getprop, without the file part. It looks through the system value pairs for a matching value.
Ex. getprop("ro.build.id") == "OLYEM1.2.3.4"
delete(PATH1, ...,PATHN); Nothing to see here, just a delete command, full path to the file(s) as argument(s).
delete_recursive(PATH1, ...,PATHN); It's a delete everything in a folder, including subfolders command. The folder itself is deleted as well.
set_perm(UID, GID, MODE, PATH1, ..., PATHN); Set the linux permissions on a file, ownership and flags at the same time. Equivalent to chown and chmod in the one command.
Ex. set_perm(0, 0, 06755, /system/bin/su, /system/bin/shsu); *0 stands for root, so it would be owned by root, of the group root, with suid bit set and standard executable bits set.
set_perm_recursive(UID, GID, DIRMODE, FILEMODE, PATH1, ...,PATHN); Same as above except with folders instead of files. Use the DIRMODE to set the permissions and ownership of the folders themselves, and FILEMODE to set the permissions of the files within them.
symlink(TARGET, LINK1, ...,LINKN); It's the equivalent to the linux ln -s command. For our purposes, it might as well be called busybox install.
Ex. symlink("/system/bin/busybox", "/system/bin/awk", "/system/bin/wget", "/system/bin/sed");
To Be Continued..
References
http://devphone.org/development/edify-script-syntax-explained/
http://www.synfulgeek.com/main/index.php/articles/76-scratchpad-documenting-edify-commands-for-android-updater-scritps-based-off-of-kernel-source-code
https://github.com/koush/android_bootable_recovery/blob/eclair/edify/README
http://tjworld.net/wiki/Android/UpdaterScriptEdifyFunctions
Tips:
You can use the abort() command to step through your updater script, for instance if you wanted to check various combinations on syntax for write_raw_image();
In /tmp there is a text file called recovery.log, do a cat /tmp/recovery.log to see extra output of your script from failed commands.
NFHimself said:
The updater-script file is a text file, it is linux formatted with regard to end of line conventions. If you use Windows then you have to edit the file using a program that keeps line feeds the way they are and has options for doing the conversion from <CR><LF> to just <LF>.
Click to expand...
Click to collapse
If you are in windows, I have found that notepad++ does the job just fine.
http://notepad-plus-plus.org/
what about the FORMAT command?
actually i have error on a CM installation, its says
Code:
format() expects 3 args, got 2.
but my format command have 3 args:
Code:
format("ext4", "/dev/block/mmcblk0p10", "/system");
NFHimself said:
Hi, I haven't seen any good resources for how to edit edify scripts, so I thought I would create this thread so we can pool our knowledge on the subject.
Intro
Click to expand...
Click to collapse
Thanks for this... but I do have a question....
I am attempting to see if busybox is installed on a device, and if not install it, or proceed
so, so far I have:
Code:
ifelse(
BUSYBOX DOESNT EXIST,
(
ui_print("* Did not find it. Installing...");
set_perm(0, 1000, 0755, "/system/xbin/busybox");
symlink("/system/xbin/busybox", "/system/bin/busybox");
run_program("/system/xbin/busybox", "--install", "-s", "/system/xbin");
),
(
ui_print("* Found it. Proceeding...");
)
);
You can see where I'm lost I was thinking of using assert to run_program("/system/xbin/busybox", "vi", "/system/xbin"); just as a simple check... but from what I can see, if the assertion fails it will stop the script, and print out the failure message, which of course is not what I am after here... or maybe I am, can it be used to do a check rather than stop the script?
Just an idea (ie. untested):
Code:
ifelse(
run_program("/system/bin/sh", "-c", "test -e /system/xbin/busybox")
...
)
ravilov said:
Just an idea (ie. untested):
Code:
ifelse(
run_program("/system/bin/sh", "-c", "test -e /system/xbin/busybox")
...
)
Click to expand...
Click to collapse
trying to run that in adb sheel, and don't get a response, but it does seem like a good idea... I assume Edify would return a 1/0 or true/false string from it, and I can just check for that?
EDIT: Maybe I do get something back... after running that in adb shell my next line looks like the following:
Code:
1|[email protected]:/ #
Am I right in assuming that "1" is the output?
Yes. The command won't ever return any output, it only returns the exit status. Your shell is obviously set so it includes a non-zero exit status in the prompt. (Non-zero traditionally means error.)
ravilov said:
Yes. The command won't ever return any output, it only returns the exit status. Your shell is obviously set so it includes a non-zero exit status in the prompt. (Non-zero traditionally means error.)
Click to expand...
Click to collapse
that prompt means that the test failed, and I don't have busybox installed?
I'm just a tad confused... (this is my first full-on edify script), and I do have busybox installed
I appreciate the help, and once I get my tapatalk working right on my phone, I'll give ya all the "thanks" for the help with this
Eh... everything I 'test' returns the same thing
Code:
1|[email protected]:/ #
Hm, weird. It works for me...
Code:
# /system/bin/sh -c 'test -e /system/xbin/busybox'; echo $?
0 [color=silver]<-- no error - file exists[/color]
# /system/bin/sh -c 'test -e /system/xbin/busybox1'; echo $?
1 [color=silver]<-- error - file does not exist[/color]
I didn't try it in an edify script because I don't feel like rebooting my phone right now, but I don't see why it wouldn't work.
Try running the "sh -c test ..." command in adb shell while in recovery and see what happens.
Also, just a side note: backslash is NOT the same as slash. If you are going to write shell/edify scripts, you need to know at least that distinction. That is why your
Code:
tags are not working right.[/b][/i][/size]
ravilov said:
Hm, weird. It works for me...
Code:
# /system/bin/sh -c 'test -e /system/xbin/busybox'; echo $?
0 [color=silver]<-- no error - file exists[/color]
# /system/bin/sh -c 'test -e /system/xbin/busybox1'; echo $?
1 [color=silver]<-- error - file does not exist[/color]
I didn't try it in an edify script because I don't feel like rebooting my phone right now, but I don't see why it wouldn't work.
Try running the "sh -c test ..." command in adb shell while in recovery and see what happens.
Also, just a side note: backslash is NOT the same as slash. If you are going to write shell/edify scripts, you need to know at least that distinction. That is why your
Code:
tags are not working right.[/b][/i][/size][/QUOTE]
I see, I wasn't doing the echo, and what you posted shows exactly what you posted. DOH on the CODE :good:
So I have it on record (for my own personal reference)
[CODE]
ifelse(
((run_program("/system/bin/sh", "-c", "test -e /system/xbin/busybox; echo $?") == 1 ||
(run_program("/system/bin/sh", "-c", "test -e /system/bin/busybox; echo $?") == 1 ||
(run_program("/system/bin/sh", "-c", "test -e /system/xbin/busibox; echo $?") == 1 ||
(run_program("/system/bin/sh", "-c", "test -e /system/bin/busibox; echo $?") == 1),
(
ui_print("* Did not find it. Installing...");
set_perm(0, 1000, 0755, "/system/xbin/busybox");
symlink("/system/xbin/busybox", "/system/bin/busybox");
run_program("/system/xbin/busybox", "--install", "-s", "/system/xbin");
),
(
ui_print("* Found it. Proceeding...");
)
);
and yes, I meant the 'busibox' part, because I have seen that in some roms
Click to expand...
Click to collapse
You guys know way more about this stuff than I do... although i am a programmer
could I get some insight over here: http://forum.xda-developers.com/showthread.php?t=2796055
having an issue getting my shell scripts to actually run...
Rockin' it from my Smartly GoldenEye 35 NF1 (muchas gracias:* @iB4STiD @loganfarrell @muniz_ri @Venom0642 @ted77usa @rebel1699* @iB4STiD) ~ 20GB free cloud https://copy.com?r=vtiraF
Check me out online @ http://kevin.pirnie.us
note: the scripts do run in adb shell
published API docs
NFHimself said:
Hi, I haven't seen any good resources for how to edit edify scripts, so I thought I would create this thread so we can pool our knowledge on the subject.
Click to expand...
Click to collapse
I found some official documentation of the API on the Android Web site here:
https://source.android.com/devices/tech/ota/inside_packages.html
NFHimself said:
[*]write_raw_image(PATH, PARTITION); This is one of those tricky ones, the PATH is somewhere on your phone with the image to be flashed to a PARTITION on your phone. The trouble is, how do you specify what partition gets flashed? Is there any restriction on where the file has to be? If MTD conventions are used, you are looking for "system", "boot", "recovery", "logo.bin". (All this means that each partition has a name stored somewhere, and if you know it, you can write to it.) Maybe it will accept device references like /dev/block/mmcblk0p8. This depends on the update-binary file you are using.
Ex. write_raw_image("/tmp/logo.bin", "logo.bin");
Ex. write_raw_image("/tmp/logo.bin", "/dev/block/mmcblk0p8");
[*]write_firmware_image(PATH, PARTITION); You would think it would be the same as write_raw_image. Not sure what the difference is.
Click to expand...
Click to collapse
I didn't do a line by line comparison between your description and theirs, but I noticed this part because I was trying to find information about these functions. Only write_raw_image() is a published API function. This is the description:
write_raw_image(filename_or_blob, partition)
Writes the image in filename_or_blob to the MTD partition. filename_or_blob can be a string naming a local file or a blob-valued argument containing the data to write. To copy a file from the OTA package to a partition, use: write_raw_image(package_extract_file("zip_filename"), "partition_name");
Probably write_firmware_image() is used internally. It could be removed at any time, or it even could be a stub - not a good idea to use it.
How to install ubuntu on the Droid 4
Note to mods: this thread is a branch off of this thread
Huge thanks to zacthespack for creating the ubuntu installer app and original boot script and to zeroktal for modifying the script to work on the D4 and helping me get it working on my device.
I decided to take my experience in setting this up and put it into a how-to so that others could enjoy the experience of having ubuntu on the Droid 4. If zackthespac or zeroktal have any problems with me making and putting this guide up, please let me know and I will remove it.
Knowledge Required:
working knowledge of command line
working knowledge of vi
OR the ability to learn how to use both
Tools Required:
A rooted Motorola Droid 4
BusyBox (Android Market)
Terminal Emulator (Android Market)
Android VNC Viewer (Android Market)
Ubuntu Installer App (Android Market)
zeroktal's ubuntud4.zip file (attached to this post and mediafire)
Vi Cheat Sheet (lagmonster.org)
Step by Step:
Install BusyBox, Terminal, and Android VNC Viewer
Install and run Ubunutu Installer App
Follow the on-screen instructions and click next
Download either the Small or Large image to your phone, (use zeroktal's ubuntud4.zip file instead of the boot script provided in the guide) after the image downloads (will take a while because the file is HUGE) click next
For this screen, the instructions differ from the app.
1. With your D4 plugged into your PC in USB Mass Storage, create a directory (folder) called ubuntu in the EXTERNAL sdcard's root*
2. Extract the image you downloaded to that directory
3. Download and extract the attached .sh (ununtud4.zip) to that directory
4. Disconnect your phone from your PC
5. Open terminal and run the following commands:
su [ENTER]
mount -o remount,rw,exec,suid /dev/block/vold/179:1 /mnt/sdcard-ext [ENTER]
cd /mnt/sdcard-ext/ubuntu [ENTER]
sh ubuntud4.sh [ENTER]
960x540 [ENTER]**If you get an error message: ubuntud4.sh: 45: syntax error: end of file unexpected (expecting "then") see troubleshooting section below.killall -TERM Xtightvnc [ENTER]
vncserver :1 -geometry 960x540 [ENTER]**6. Open androidVNC app and enter the following settings:
Nickname: Anything you want
Password: ubuntu
Address: localhost
Port: 5901
Color Format: 24-bit color (4 bpp)
7. Hit connect
8. Hit your menu soft button and then set input mode to touchpad
9. You have ubuntu on your Droid 4!
To "shut down" ubuntu:
press the menu button, select disconnect in VNC
In terminal type this command 3 times (terminal will close itself when you are done):
exit [ENTER]
To "start up" ubuntu again:
Follow steps 5-8 above
Troubleshooting:
If you get the error message: ubuntud4.sh: 45: syntax error: end of file unexpected (expecting "then") you are about to have fun with vi at the command line.
Do the following from inside terminal:
su [ENTER]
cd /mnt/sdcard-ext/ubuntu [ENTER]
vi ubuntud4.sh [ENTER]If you see ^M or ^ at the end of any line (remember to scroll all the way to the right to see the end of long lines) remove it. once you do that, everything should work just fine. (See the Vi Cheat Sheet above for help with Vi)
Note: Vol Up + E is [ESC] by default in this terminal emulator
Notes:
* It does not have to be on the external SD, but if you put it on the internal SD you will have to modify things as needed-- if you dont know what needs to be changed, just put it on the external SD.
** Screen size can be whatever you want it to be, but 960x540 is the size of the D4 screen.
*** This is a fairly involved process... especially when it comes to editing the .sh file in vi things can get very frustrating and hard, but just take your time and you will get it. As always, doing anything with root access on your phone, especially on the command line has risks. I am not responsible if anything goes wrong with your phone... proceed at your own risk!
greekchampion04 said:
Notes:
* It does not have to be on the external SD, but if you put it on the internal SD you will have to modify things as needed-- if you dont know what needs to be changed, just put it on the external SD.
** Screen size can be whatever you want it to be, but 960x540 is the size of the D4 screen.
*** This is a fairly involved process... especially when it comes to editing the .sh file in vi things can get very frustrating and hard, but just take your time and you will get it. As always, doing anything with root access on your phone, especially on the command line has risks. I am not responsible if anything goes wrong with your phone... proceed at your own risk!
Click to expand...
Click to collapse
I actually got it up and running on my internal sdcard partition. Pretty much just have to modify the Mount remount command, and a few lines in the script.
Here's the original command
Code:
mount -o remount,rw,exec,suid /dev/block/vold/179:1 /mnt/sdcard-ext
And the modified one
Code:
mount -o remount,rw,exec,suid /dev/block/vold/179:57 /mnt/sdcard
Only things you have to change are the device location(179:57) and mount location(drop the -ext after sdcard)
Now, after that you also have to modify the script a bit. Just go through it, and anywhere that you see sdcard-ext, drop the -ext off the end.
thanks for putting that up for everybody! like i said, if you know what you are doing its not a hard swap to make.
Is anyone else getting just a gray screen when they remote in? What could be causing this?
i had that same problem at first... did you use zeroktal's ubuntud4.zip file? or did you use the ubuntu.sh file included in the app?
I used the sh file included. I did however fix the problem, when mounting at the start i confused vold with void. I did not get the file system mounted properly. This method does work!! however I am currently trying to get bash on my droid to replace sh as the shell. I've checked the forums but have not found anything yet about someone installing bash on the droid 4. With no way for nandroids I feel i should wait before I kill sh.
Sent from my DROID4 using XDA App
If you mod your init.sh in your root directory to the following, your vnc will work on startup without issue. It will also shutdown vnc on exit.
#!/bin/bash
#############################################
# Asks User to screen size and saves as REZ #
#############################################
#echo "Now enter the screen size you want in pixels (e.g. 800x480), followed by [ENTER]:"
#read REZ
##############################################
# Pick which desktop environment to use, this#
# is done by having a xstartup file for each #
# desktop, then renaming the one you want to #
# use to 'xstartup' before boot #
##############################################
echo "Please select which Desktop environment you want to use, type the number to select it then press [ENTER]"
echo "1 - LXDE"
echo "2 - Gnome"
echo "Make your Selection:"
read DESKTOP
if [ $DESKTOP == 1 ]
then
mv /root/.vnc/lxstartup /root/.vnc/xstartup
fi
if [ $DESKTOP == 2 ]
then
mv /root/.vnc/gxstartup /root/.vnc/xstartup
fi
###########################################
# Tidy up previous LXDE and DBUS sessions #
###########################################
rm /tmp/.X* > /dev/null 2>&1
rm /tmp/.X11-unix/X* > /dev/null 2>&1
rm /root/.vnc/localhost* > /dev/null 2>&1
rm /var/run/dbus/pid > /dev/null 2>&1
############################################################
# enable workaround for upstart dependent installs #
# in chroot'd environment. this allows certain packages #
# that use upstart start/stop to not fail on install. #
# this means they will have to be launched manually though #
############################################################
dpkg-divert --local --rename --add /sbin/initctl > /dev/null 2>&1
ln -s /bin/true /sbin/initctl > /dev/null 2>&1
###############################################
# start vnc server with given resolution and #
# DBUS server, (and optionally an SSH server) #
###############################################
dbus-daemon --system --fork > /dev/null 2>&1
/etc/init.d/ssh start
vncserver :1 -geometry 960x540
echo
echo "If you see the message 'New 'X' Desktop is localhost:1' then you are ready to VNC into your ubuntu OS.."
echo
echo "If VNC'ing from a different machine on the same network as the android device use the 1st address below:"
##########################################
# Output IP address of android device #
##########################################
ifconfig | grep "inet addr"
echo
echo "If using androidVNC, change the 'Color Format' setting to 24-bit colour, and once you've VNC'd in, change the 'input mode' to touchpad (in settings)"
echo
echo "To shut down the VNC server and exit the ubuntu environment, just enter 'exit' at this terminal - and WAIT for all shutdown routines to finish!"
echo
###############################################################
# Spawn and interactive shell - this effectively halts script #
# execution until the spawning shell is exited (i.e. you want #
# to shut down vncserver and exit the ubuntu environment) #
###############################################################
/bin/bash -i
#########################################
# Disable upstart workaround and #
# kill VNC server (and optionally SSH) #
# Rename used xstartup to its first file#
#########################################
killall -TERM Xtightvnc
/etc/init.d/ssh stop
Also save the follow lines between ### as remount.sh on your system partition. Then chmod 755 /system/remount.sh. Now you can just run run from a terminal /system/remount.sh and voila it remounts correctly and starts ubuntu(with the above fixes). Im still working on the unmounts.
####### for the internal sd card
mount -o remount,rw,exec,suid /dev/block/vold/179:57 /mnt/sdcard
/mnt/sdcard/ubuntu/ubuntu.sh
######
OR
####### for the external sd card
mount -o remount,rw,exec,suid /dev/block/vold/179:1 /mnt/sdcard-ext
/mnt/sdcard-ext/ubuntu/ubuntu.sh
#######
great stuff!
feel free
Feel free and take, modify, repost or edit anything I touch.
QUESTION:
After I delete all the ^M and ^ what do i do next? I try to hit the command ":x" to exit and save changes but it just creates another line. Also when I press VOL UP + E to escape nothing happens.
PhanTuhC said:
QUESTION:
After I delete all the ^M and ^ what do i do next? I try to hit the command ":x" to exit and save changes but it just creates another line. Also when I press VOL UP + E to escape nothing happens.
Click to expand...
Click to collapse
In vi, the command to save and exit is :wq (probably short for write and quit).
remember, read up on the vi quick-reference guide: http://www.lagmonster.org/docs/vi.html
OK I fixed it but now its not letting me connect with androidVNC. All the settings entered is correct but when I try to connect it says:
"VNC connection failed!" localhost/127.0.0.1:5901 - Connection refused"
ok, i've gone thru this a few times (slowly and deliberately) and must be missing something...the directions seem pretty straightforward! here's what i know...
busy/terminal/vnc are all installed
small 2.5gb image is unzipped in /sdcard-ext/ubuntu directory
the attached .sh file from page 1 is in the same directory
i removed all ^M using vi
but when I try sh ubuntud4.sh i get an error...
"mkdir failed for /data/local/mnt/ubun, No such file or directory"
(plus a few other errors)
should the directory be "ubun" or "ubuntu"? am I typing something incorrectly?
copy and paste new script
Copy and paste the new scripts I posted. They will fix your problem. Remember to use the remount script from /system/ the rest will work perfectly if you are root. I'll check back later on your progress.
Ok, well I started from scratch (deleted both .img and .sh files) and it's still not working.
I have all the apps installed (and yes rooted, SU works just fine)
I used Ubuntu Installer app to download the image zip (tried both the large and small img)
I downloaded the .sh file from the first post
The /sdcard-ext/ubuntu/ folder now has two files: "ubuntu.img" and "ubuntud4.sh"
All ^M characters have been removed from .sh file
Still no joy...
Ideas? What am I missing?
In terminal, I can set SU permissions and the mount/cd commands work just fine...it's the last sh command that spits out a bunch of errors about not being able to create/find the directories.
I'm going to format the sdcard and try again...any help is appreciated.
Update: Even after re-formatting the SD and following the steps exactly, no luck!
Did you remember to remount the sdcard with exec and suid permissions?
Andbuntu will work much better than this method. It works on every single phone with modification to the "environmental variables".
http://code.google.com/p/andbuntu/
Follow the directions in the script to make the process much easier than the first post.
instructions:
generate an image with rootstock on an ubuntu computer.
put it on /sdcard/ubuntu/ubuntu.img
run the script on your phone with "sh /path/to/script"
Here is the script. http://andbuntu.googlecode.com/svn/trunk/uboot
Also, run "firstRun" to make things like terminals work properly.
Adamoutler: That didnt work for me. The permissions were incorrect on the mounted partitions.
Sent from my DROID4 using XDA App
************************************
************************************
Note: Please uninstall Hashcode's Safestrap before you try installing this one. To accomplish this properly, you have to do two things:
1. Open up the Safestrap app from your launcher, and choose "Uninstall Recovery". Let it finish. It'll tell you whether or not it worked.
2. Then, go to Settings - Apps and find Safestrap. Click "Uninstall".
************************************
************************************
Installation of this app requires root privileges. If the installation does
not work, it is likely because you either:
a) don't have busybox installed.
b) you do have busybox installed but it doesn't have the functions we
need.
No problem. Just do this through adb or a terminal on the phone:
Code:
$ su
# mount -o remount,rw /system
# cp /system/xbin/busybox /system/xbin/busybox.old
# cp /data/data/com.hashcode.droid4safestrap/files/busybox /system/xbin/
# chmod 755 /system/xbin/busybox
# exit
Now it should work without a hitch.
************************************
************************************
Those of you who came from the Droid 3 might remember my customized version of Hashcode's Safestrap, which included a console, improved user-interface, non-safe flashing, etc.
I've finally got it to the point where I think it would be okay to release out in the wild. That being said, I'm not responsible for anything dumb you do to your own device.
I wouldn't bother using the non-safe flashing capabilities yet, seeing as how there hasn't really been any official releases using the new ICS kernels that have been leaked as of late. This feature is handy if you're a developer testing out update.zips for /systemorig, but for the average person you'd best pay heed to the warnings and just use Safestrap as it was originally intended; that is, leaving your /systemorig partition intact and only mess around with your "safe" /system. (Or /preinstall, actually, but that's not really important.)
The console is beyond useful. Editing build.prop settings on the fly without having to boot up and do it in a terminal emulator or via adb on the phone is much easier. If you know what you're doing, you can even extract single files from your old backups, modify your old backups, etc. That's just a small fraction, but those of you who would care about this functionality don't need me to say how important it can be.
I've included statically compiled versions of "bash" and "vim" so that there aren't any dependencies on the libraries usually found in /system/lib. Thus, you can use all of these utilities without having either /system or /systemorig mounted. You're free to add your own binaries in your home folder, which is located at /cache/.safestrap/home, or just pop them onto your sdcard.
Also, I have a battery monitor running so it will tell you what level your battery is at, and have put a lot of work into the visual appearance of the user-interface. There are so many things I've modified that it would be impossible for me to list them all here.
Anyways, try it out and let me know what you guys think. I hope you like it!
For those of you who are interested, I always post my sources on Github. You can find my code repositories here:
https://github.com/buddyrich
The .APK can be downloaded from my DropBox via the link below:
http://db.tt/tZdmUHl1
=========================
RECOVERY MENU REFERENCE
=========================
Select Highlighted Item - Enter or Power
Scroll Up - Volume Up or Left Arrow
**Note: The Left/Right Arrow keys may sound weird but since the menu is displayed in portrait mode, it just feels like you are pushing Up/Down.**
Scroll Down - Volume Down or Right Arrow
Direct Menu Selection - Hit the corresponding number/letter at the beginning of each menu item.
**ie: from the main menu, hit "6" to jump to the advanced menu.**
Go Back / Cancel - Caps Lock
===================
CONSOLE REFERENCE
===================
Keys:
--------------------
Tab - Tab
** Note: The Tab key is your best friend when using bash. It will auto-complete file/directory names for you, or list out the possible choices if you double-tap it after entering a few letters.
SYM - Alt
Shift - Shift
OK - Control
Caps Lock - ESC
OK+Shift - Toggle Caps Lock
OK+SYM - Toggle Alt Lock
** Note: The LED beside the Caps Lock button will illuminate when either Caps Lock or Alt Lock is enabled.
OK+Backspace - Force exit
OK+A - Home
OK+E - End
OK+C - Stop current process, ie: if a program you are running chokes up.
=========================
bash Commands:
--------------------
Here are a few of the more useful bash commands that you will use:
===========
ls, ls -a, ls -l, ll
===========
Code:
/ {}$ ls
- "ls" lists the files and directories within the current directory.
- You can also add a path after it to look for certain files or directories.
Code:
/ {}$ ls -a
- "ls -a" will list all files and directories, including hidden ones starting with a ".", ie: .bashrc in /cache/.safestrap/home. (The bash startup script).
Code:
/ {}$ ls -l
- "ls -l" will do a long listing, showing permissions, file sizes, etc.
Now, instead of using those parameters, I've made aliases within the .bashrc script so you will probably just want to type:
Code:
/ {}$ ll
- "ll" is an alias for "ls -a -l", so it will list all files/directories, hidden or not and list their properties.
Code:
/ {}$ ll
- By putting a path after "ll", it will single out the file. Add a "*" in there to act as a wildcard to list multiple files with the same first few characters.
- ie: "ll /system/lib/libc*" would display all the files and directories starting with "libc" within /system/lib as well as their properties.
========
cd
========
Code:
/ {}$ cd (path)
- Change directory. Pretty self-explanatory. Try doing:
Code:
/ {}$ cd ~/
- This takes you to the home folder. Pretty useless here but this is usually pretty handy in other scenarios.
Code:
/ {}$ cd ../
- Using "../" as your target will cause you to drop down a single directory in the tree.
**** Don't forget to hit tab to auto-complete directory/file names for you whenever you've already entered the first few characters. More accurate and much less typing. ****
=======
mv
=======
Code:
/ {}$ mv (source) (destination)
- "mv" is short for move. The source is the path to the file/directory you want to move, and I don't think i need to tell you what the destination is.
=======
rm
=======
Code:
/ {}$ rm (-r -f) (target)
- "rm" is used to delete the targetted files.
- "-r" means to recurse, or go into every inner directory automatically, erasing as it goes.
- You'll use the -r flag a lot, because you can't delete directories without it unless you use "rmdir", which is just more typing.
"-f" means force in case of permission errors, as long as you are root.
========
cp
========
Code:
/ {}$ cp (-f -a) (source) (destination)
- Copy the source file or directory to the destination.
- Use "-f" to force the copying, in the event of a potential overwrite.
- Use "-a" to maintain permissions of the original, you'll want to use this whenever you are copying anything important. I just use it all the time, but sometimes it won't work, such as when copying from an /sdcard to either the /system or /data partition.
-This is because the file system of your /sdcard doesn't care about permissions.
=========================
============
[VIM REFERENCE]|
============
Vim deserves, and has, entire websites devoted to it's use. Here are some of the basics.
------------
Using Vim|
------------
From the console, simply type:
Code:
/ {}$ vim
Where is obviously replaced by the name of the file you are editing.
Multiple files can be opened at once by just adding them as parameters to vim:
Code:
/ {}$ vim file1 file2 file3 file4 filen
---------------
Insert Mode |
---------------
This is the mode you want to be in to make any visible changes to the file you are editing.
- Enter Insert Mode by pushing "i" when vim opens.
- Exit Insert Mode by pushing Capslock.
Keys:
------
Backspace - In insert mode, deletes the previous character.
Capslock - Exits insert mode
---------------
Visual mode |
---------------
By typing in "v" instead of "i", you will enter visual mode; this is Vim's fancy way of saying you will be selecting text.
Keys:
------
- Copy or Cut text by hitting "y" or "d" after you've made a selection
- Paste with "p" or "P" (that is, Shift+p). Shift-"p" puts the text before the cursor whereas plain lowercase "p" will paste it after.
- When you're done highlighting what you want to either cut or copy, just hit Capslock to go back to Command Mode.
-------------------
Command Mode |
-------------------
Vim starts out in Command mode. It seems confusing but once you get used to it, you can't help but hate Notepad.
Some of the more common commands are listed below.
Keys:
------
u - Undo
Shift+r (Usually denoted as R) - Enter Replace Mode, where you are replacing text instead of inserting it.
[#]yy - Yank (copy) the current line if you just entered "yy", or copy "#" lines if you enter #yy, ie: 5yy to copy 5 lines.
[#]dd - Delete (cut) the current line, or delete # lines if preceded by a #.
p - Pastes after the cursor
Shift+p (usually denoted as P) - Pastes before the cursor
:[#] - (Ignore the square brackets; a colon followed by a number goes to that particular line in the text file you are editing. eg: ":5" goes to line 5. (Obviously, don't type the quotation marks in.)
Note: - If you are in Insert mode, you will have to push Capslock to exit and be allowed to enter Command Mode by entering a ":"
- It's fairly common practice to just hit Capslock twice whenever you're done inserting so that you are sure to be able to hit ":" and proceed to enter another command.
:w - Write (save) the currently open file.
:q - Quit. If you haven't saved since making any changes, it will prompt you to either save your changes or append a "!" after "q" to quit without saving. (See below)
:q! - Force quit without saving.
:wq - Save and then quit.
:e [path to filename] Opens up another file; you can use bash command-line completion to scan the current directory, or otherwise just enter another path.
:next or rev - Aptly named, move to the next or previous file if you opened vim with two or more files as parameters, ie:
Code:
/ {}$ vim file1 file2
:/[text] - Search for "text". ie: ":/search" will find instances of the text "search" in the current file and highlight them.
Note: You need to make sure you are aware of regular expressions/escape characters before using this reliably; it's not broken if you can't seem to search for a quotation mark or other special characters, you need to precede them by a \. ie: to look for a double-quote symbol " you would enter :/\". The \ tells it that the next character is meant to be taken literally and not symbolically.
:/[text]/[moretext]/gc - Replace "text" with "moretext" everywhere in the file and ask confirmation for each change. If you forget to type in the "gc" at the end, it'll just replace everywhere without asking you for confirmation.
That's all I'm going to put here. There are tons of guide out there and I've already preloaded a pretty awesome configuration (.vimrc located at /cache/.safestrap/home) and runtime files. If you want to quickly access the configuration file, you can type ",,e" in Command Mode and it will automatically pop open.
================
COLOR CHANGING
================
1. If you want to change the color scheme, you need to figure out what the RGB code for the color you want is. Here's a website that provides a large table of colors and their corresponding RGB color code:
http://web.njit.edu/~kevin/rgb.txt.html
For example, let's say we like the "SlateGray4" color from the table linked above want to use it for the menus in both Safe and Non-Safe mode. As you can see, in the "R;G;B; Dec" column, the three codes we are interested in are 108, 123 and 139.
2. Now that you know the color codes, in our case 108, 123 and 139, we simply do the following:
a) Push 7 from the main menu, or scroll down and select "console menu".
b) Push 1, or scroll down and select "open console"
(Don't panic if it takes a few seconds to load the console; on the first initialization or after wiping the /cache partition, it will take a few seconds to reconfigure itself.)
c) At the prompt, enter the following:
Code:
/ {}$ ns_rgb 108 123 139
/ {}$ s_rgb 108 129 139
/ {}$ cc
/ {}$ exit
Now, it'll take another second or two and when the menu pops back up, you'll see that it is the color we chose from the table. The "ns_rgb" command takes three parameters, each of which correspond to the R, G and B values of the color code, and uses them for the "Non-Safe" (hence the "ns") menu color.
Similarly, the "s_rgb" command, (well technically, it's a bash function but anyways...) takes the same three parameters. It is applied to the "Safe" menu color.
The "cc" command actually sets the color, so don't forget to enter it. Otherwise, you won't notice a change when you exit out from the console.
Feel free to experiment with different colors! If you don't what you've done and just want to reset it back to the way it way, just wipe the cache partition:
a) Push 3, or scroll down to "wipe menu".
b) Push 1, or just hit Enter on "wipe cache".
c) Confirm your selection by pushing 8 or scrolling down and selecting "yes - wipe cache".
=================================================
More to come as I have more time.
Awesome, just a couple questions:
1) where is the dropbox download
2) if I already have the hashcode safestrap installed, how does one install yours? And what happens if I am already running a custom ROM?
Sent from my XT894 running ICS
Good call, I should make that clear.
Make sure you uninstall Hashcode's Safestrap, both inside the app and from the Android Settings menu before you install this .APK.
- download the pimped apk, uninstalled safestrap recovery, uninstalled old safestrap
- installed pimped safestrap, install new safestrap recovery, reboot
looks fine
anyone who restorerd a full backup of ics leak with safestrap 2.0?
friend got a problem, and system was unbootable and lost root....
Yeah, I've done it about four times today. No problems using either my modified version or Hashcode's original Safestrap v2.00.
It was no problem recovering from a busted /system partition either; just fastbooted the /system and /preinstall partitions only from the .219 leak, then rebooted the phone into the stock recovery and re-applied the .208 leaked update .zip file. Re-rooted with the technique I posted the other day without a hitch.
Didn't even lose any data...
Rick#2 said:
Yeah, I've done it about four times today. No problems using either my modified version or Hashcode's original Safestrap v2.00.
It was no problem recovering from a busted /system partition either; just fastbooted the /system and /preinstall partitions only from the .219 leak, then rebooted the phone into the stock recovery and re-applied the .208 leaked update .zip file. Re-rooted with the technique I posted the other day without a hitch.
Didn't even lose any data...
Click to expand...
Click to collapse
I mean full restore in safestrap, not advanced restore.
After restore from systemorig cames an "error while restoring systemorig!" And system damage.
...Tapatalk
Rennert said:
I mean full restore in safestrap, not advanced restore.
After restore from systemorig cames an "error while restoring systemorig!" And system damage.
...Tapatalk
Click to expand...
Click to collapse
I'm not following you here, this happened to you using my version?
I've done it countless times while testing this before I released it and have been working with this code for a long time; it's pretty foolproof.
Rick#2 said:
I'm not following you here, this happened to you using my version?
I've done it countless times while testing this before I released it and have been working with this code for a long time; it's pretty foolproof.
Click to expand...
Click to collapse
No, this was tested with hashcodes safestrap. Restore in your version doesn't tested, but not need at time;-)
...Tapatalk
Having some issues with getting safestrap installed in the 208 ICS leak. The app installs fine, click install and it says install complete, but I have no safestrap. Even after a reboot it still says "Not Installed" in the safestrap app. Anyone else experiencing this issue?
Sent from my DROID4 using Tapatalk
jgardner said:
Having some issues with getting safestrap installed in the 208 ICS leak. The app installs fine, click install and it says install complete, but I have no safestrap. Even after a reboot it still says "Not Installed" in the safestrap app. Anyone else experiencing this issue?
Sent from my DROID4 using Tapatalk
Click to expand...
Click to collapse
make sure u installed/updated busybox
That was exactly it. Realized shortly after posting it. Thanks!
Sent from my DROID4 using Tapatalk
So I have tried to restore 2 different backups using your safestrap and I keep on getting MD5 mismatch errors. I have tried deleting and regenerating the checksum file via ADB, disabled signature check, changed the folder name, pretty much everything I could think of. So whats going on?
An MD5 error would indicate that your backup files don't match the checksum that was generated at the time the backups were initially generated, which most likely means that your backup files may have become corrupted... unfortunately, this can happen with any files stored on an SD card.
Don't worry too much though, there still a really good chance that you can manually restore your data, although if your MD5's aren't matching there's a tiny possibility that your backup files are toast.
*** I'll assume you are trying to restore a "safe" system backup. If it's a "non-safe" backup, then just interchange "/systemorig" and "non-safe" for "/system" and "safe", respectively. ***
You have to manually wipe your /data and /cache partitions in the wipe menu, then format "/system" in the mounts menu. This way you have a clean slate to extract your backups to.
Try this from within the console in the recovery. (Depending on whether you backed up to the internal (/emmc) or external (/sdcard) card, just mount the required partition as follows:
*** Don't worry if you get a message saying the device can't mount because it is busy, that just means it's already mounted. ***
Internal card:
Code:
{}$: mount /emmc
External card:
Code:
{}$: mount /sdcard
(To be sure, it won't hurt if you just mount both of them.)
I'll assume you used the external sdcard which is mounted at /sdcard. Now:
Code:
{}$: cd /sdcard/safestrap/backup
If you list this directory (using "ll", or "ls -l"), you'll see a list of backup directories, prefixed by either "safe" or "nonsafe" and followed by the date and time of the backup. Remember, you can use the Tab key to autocomplete file/directory names so you don't have to type in the entire path. Here's an example:
Code:
/sdcard/safestrap/backup {}$ ll
total 192
d---rwxr-x 6 1000 1015 32768 Jun 24 04:42 ./
d---rwxr-x 3 1000 1015 32768 Jun 6 04:41 ../
d---rwxr-x 5 1000 1015 32768 Jun 6 04:41 nonsafe-2012-05-25.19.22.55/
d---rwxr-x 2 1000 1015 32768 Jun 8 20:42 nonsafe-2012-06-08.13.35.00/
d---rwxr-x 2 1000 1015 32768 Jun 20 03:13 safe-2012-06-19.20.10.44/
d---rwxr-x 3 1000 1015 32768 Jun 24 13:17 safe-2012-06-23.16.25.49/
/sdcard/safestrap/backup {}$
Let's use "safe-2012-06-19.20.10.44" for my example, substitute your own directory name as I'm sure it'll be different.
Go ahead and list the contents by entering the next two commands:
Code:
/sdcard/safestrap/backup {}$: cd safe-2012-06-19.20.10.44
/sdcard/safestrap/backup/safe-2012-06-19.20.10.44 {}$: ll
You should see something like:
Code:
/sdcard/safestrap/backup {}$: cd safe-2012-06-19.20.10.44
/sdcard/safestrap/backup/safe-2012-06-19.20.10.44 {}$ ll
total 1117760
d---rwxr-x 2 1000 1015 32768 Jun 20 03:13 ./
d---rwxr-x 6 1000 1015 32768 Jun 24 04:42 ../
----rwxr-x 1 1000 1015 74135552 Jun 20 03:13 cache.ext3.tar*
----rwxr-x 1 1000 1015 225547776 Jun 20 03:12 data.ext3.tar*
----rwxr-x 1 1000 1015 201 Jun 20 03:13 nandroid.md5*
----rwxr-x 1 1000 1015 280272384 Jun 20 03:12 system.ext3.tar*
----rwxr-x 1 1000 1015 564430848 Jun 20 03:11 systemorig.ext3.tar*
/sdcard/safestrap/backup/safe-2012-06-19.20.10.44 {}$
Now that you're at the proper path for the backup you want to restore, we can manually extract the files from the backups. (If you haven't already done so, remember to wipe /data, /cache and /system.)
We have to mount /system, /data and /cache:
Code:
/sdcard/safestrap/backup/safe-2012-06-19.20.10.44 {}$ mount /system
/sdcard/safestrap/backup/safe-2012-06-19.20.10.44 {}$ mount /data
/sdcard/safestrap/backup/safe-2012-06-19.20.10.44 {}$ mount /cache
*** Don't worry if you get a message saying the device can't mount because it is busy, that just means it's already mounted. ***
Code:
/sdcard/safestrap/backup/safe-2012-06-19.20.10.44 {}$ tar xvf system.ext3.tar -C /
Wait a minute or two for it to finish, then:
Code:
/sdcard/safestrap/backup/safe-2012-06-19.20.10.44 {}$ tar xvf data.ext3.tar -C /
Wait some more... then:
Code:
/sdcard/safestrap/backup/safe-2012-06-19.20.10.44 {}$ tar xvf cache.ext3.tar -C /
Done. If you want, you can restore your /systemorig partition now but you probably don't want to do that, not if your MD5's don't match up.
Assuming you just restored a "safe" system backup and you are in "safe" mode, you can cross your fingers and reboot. If you aren't in safe mode, switch over to it from the safe-boot menu before you reboot.
At this point, you should have restored that backup manually. Hope that helps, it's always a bummer to lose your data.
You sir need a medal. That was the best response I could have expected. I will try this later at work. I regenerated the checksum file but like you said, it has to be at the time of the backup.
Hey man, no prob. I figure I might as well do it step by step so that others can reference this in the event of a similar situation. Hope it works out for you.
To be honest, I got frustrated and gave up. I have discovered that on the 7-4 AOKP build, if I lose data all I have to do is wipe cache and dalvik cache and boom, I have have 4G. Now if only I can get a init.d tweak to clear both on startup then all I would have to do is reboot the phone to restore data. So long story short, I'm sticking with the non ICS-Leak AOKP, no need to risk going off the upgrade path and alot less of a hassle.
@Rick#2
new Safestrap 2.10 for Droid4 is out, can you pimp this one too?
When you connect your MIUI device to the computer through USB in File Transfer (MTP) mode (that is, not in Photo Transfer), it also emulates a CD-ROM drive. The ISO image for the fake CD contains a copy of Mi Assistant, a device management tool for the PC, which is in Chinese only and can be downloaded from the Internet anyway. Basically, it's all useless and mildly annoying.
View attachment 3137500
Here's what you need to do to get rid of it:
Step 1. Edit /system/build.prop and add the line:
Code:
persist.service.cdrom.enable=0
Step 2. Edit /init.qcom.usb.rc and where it says:
Code:
on property:sys.usb.config=mtp
(a) Change the first line to remove mention of mass_storage (this is for the CD only):
Code:
write /sys/class/android_usb/android0/functions mtp
(b) Remove these two lines:
Code:
write /sys/class/android_usb/android0/f_mass_storage/lun/ro 1
write /sys/class/android_usb/android0/f_mass_storage/lun/file /data/miui/cdrom_install.iso
Similarly, where it says:
Code:
on property:sys.usb.config=mtp,adb
(a) Change the first line after the above to:
Code:
write /sys/class/android_usb/android0/functions mtp,adb
(b) Remove these two lines:
Code:
write /sys/class/android_usb/android0/f_mass_storage/lun/ro 1
write /sys/class/android_usb/android0/f_mass_storage/lun/file /data/miui/cdrom_install.iso
Step 3. Delete the ISO image file to free up some space.
File location: /data/miui/cdrom_install.iso
And here's how to do it:
Using Android Debug Bridge from the command line:
Code:
adb root
adb shell "mount -o remount,rw /system"
adb shell "echo persist.service.cdrom.enable=0 >>/system/build.prop"
adb pull /init.qcom.usb.rc
Now use your favorite editor to make changes as described above in step 2.
Code:
adb push init.qcom.usb.rc /
adb shell "mount -o remount,ro /system"
adb shell "rm -f /data/miui/cdrom_install.iso"
adb reboot
Using ES File Explorer:
Download from Play Store or the developer's website. Install. Open. In context menu (hold leftmost button for 1 second), switch Root Explorer to On (this will fail). Go back to the home screen. Open Security, Permissions, Root Access. Put the switch next to ES File Explorer to On. Now you can switch back to ES File Explorer, and follow the steps 1-3 above. Use the built-in editor the make changes in the files.
Unknown USB devices when connected in MTP mode
When your device is connected in MTP mode (File Transfer) there are 3 unrecognized USB devices. To check if you have them too, go to Control Panel and choose Device Manager or run mmc devmgmt.msc from the command line (screenshot 1). The devices appear to have no hardware IDs (screenshot 2) and their class number seems to be {c897b31c-e8d2-59e9-a212-ccf0962fe102} (full registry dump provided as attachment).
View attachment 3137478 View attachment 3137479
This problem appears to be caused by the CD-ROM emulation as well: the number of devices will actually increase to 4 when it's switched off following the instructions above, which means there must be one extra step to get rid of it completely. This doesn't seem to cause any problems and the issue appears to be purely cosmetic. If I have time to investigate it further, I will report the conclusions back here. Meanwhile, if anyone has an idea what the cause is, please feel free to share it (might also be a driver issue).
Disclaimer: there might be some mistakes in what I wrote. Please use at your own discretion. This should work with a "developer" stock ROM out of the box, otherwise you'll need to set-up root access first.
Update for a total fix, and a more elegant approach
So the missing link to make the mysterious devices disappear is to edit /init.qcom.usb.rc and where it says:
Code:
case "$cdromenable" in
0)
Comment out (put the # sign) in front of:
Code:
#echo "" > /sys/class/android_usb/android0/f_mass_storage/lun0/file
The best way to make the whole change seems to be to unpack boot.img, for example with Android Image Kitchen, apply the patches (diffs attached), rebuild the image, and flash it. The persist.service.cdrom.enable=0 property can be set in /default.prop so that all the changes are contained within the boot image. In summary:
Code:
unpackimg boot.img
echo "persist.service.cdrom.enable=0" >>ramdisk/default.prop
patch ramdisk/init.qcom.usb.rc < init.qcom.usb.rc.diff
patch ramdisk/init.qcom.usb.sh < init.qcom.usb.sh.diff
repackimg
cleanup
adb reboot bootloader
fastboot erase boot
fastboot flash boot image-new.img
fastboot reboot
@ Aqq123 thanks for the write up, I have a Mi 4C and the iso file is not in /data/miui/ but it still shows up when connecting to pc
I am currently working unsuccessfully on an application with XposedBridge and I have a lot of questions. I will start with the simple ones.
1. How can I get the debug.log file?
I cannot find the debug.log file. I have tried the phone shell as well as two adb ways :
A. adb shell data/data/de.robv.android.xposed.installer/log/debug.log
B. adb shell "su -c 'cat data/data/de.robv.android.xposed.installer/log/debug.log'"
C. adb shell cat data/data/de.robv.android.xposed.installer/log/debug.log
adb says : " No such file or directory "
The phone shell can cd to /data and /data/data but not after. Cannot ls neither of the data's. Says access denied. So does adb when I try adb ls.
The phone, Moto E XT1023, is rooted. Despite, shell cannot read some directories. I have posted a question why here but no one seems to care to answer.
I had to go to ES File Explorer. Managed to get to /data. ES says folder empty. Managed to get to Emulator/0/de.robv.android.xposed.installer or something alike. There was a subdirectory called files. Inside was the installer. No debug.log.
Searched all directories with ES for debug.log. Nothing found. I am sure many people on this forum have had these experiences. Please, reply.
2. Once I create the XposedBridge class in a separate file of the project and once I do whatever XposedBridge is supposed to do ( override methods, insert code before and or after the methods, etcetera ) the overridden methods or the methods with code run before and or after or the overridden data WILL CONTINUE TO BE OVEERRIDEN until the app exits. IS THIS TRUE?
3. Is there any simple, yet powerful and comprehensive manual or reference or, the best, a tutorial?
4. CAN I SPECIFY ANOTHER DIRECTORY FOR THE DEBUG.LOG.FILE?
5. In case I am able to make a directory \data\data manually, would this make the Xposed save debug.log there?
Please, be kind to answer these questions as I have been banging head for approximately a week.
Thanks.
OK. I am so happy I have managed to partially answer the first question which is not only related to XposedBridge but is a global root reach question for rooted phones, so I cannot even think of any other questions for now. I DO NOT HAVE A DEBUG.LOG BUT I HAVE ERROR.LOG AND I KNOW HOW TO READ THESE. Here is how in case anyone is interested :
In order to be able to reed XposedBridge log files :
1. Go to the specialised Moto E adb ( may work with a standard one too ).
2. Type :
************
* adb root *
************
to ensure root access.
3. The Dollar Sign $ must appear as the sign before commands. $ means the adb shell
environment has been entered.
4. After $, type :
******
* su *
******
5. The Sharp Sign # must appear as the sign before commands. # means root has been
entered. Once root has been entered, there is a full access to the phone. Thus :
**************************************************
* cd /data/data/de.robv.android.xposed.installer *
**************************************************
can be excuted and the directory /data/data/de.robv.android.xposed.installer will be
entered.
6. Type :
******
* ls *
******
to see the contents of this directory.
7. In case error.log or debug.log files are there, type :
*****************
* cat error.log *
*****************
and or
*****************
* cat debug.log *
*****************
to view these files.
8. Type :
********
* exit *
********
to return to the safer $ prompt.
9. Type :
********
* exit *
********
to exit adb.
Note : adb root may not run while a project is developed. The rest works, though.
I still do not have any debug.log. May be the XposedBridge lines do not run. Will check with some simple method from the manual.
Here is what I have found out, though. I have created an empty text file called debug.log on the computer and transferred the file to the main root of the device, the /sdcard directory, themn copied the file to /data/data/de.robv.android.xposed.installer/log just to see what happens. Nothing happens. The file is empty.
Here is what I have found out which may be helpful. PLEASE, COMMENT :
****
COMMANDS TO READ THE LOG FILES :
adb shell
su
cd /data/data/de.robv.android.xposed.installer/log
cat error.log
****
USE cp SOURCE DESTINATION after su shell, the # prompt, to copy files from one
directory to another on the device.
****
IMPORTANT NOTES :
****
All Xposed classes must be put in xposed_init, otherwise Android Studio 1.2 reports them as never used.
****
In built.gradle, have :
/* SSB : Added manually so the gradle builds with the XposedBridgeApi-54.jar which is
in the app -> libs but not to include the jar in the apk. */
dependencies {
provided fileTree(dir: 'libs', include: ['*.jar'])
}
THESE HAVE BEEN PUT MANUALLY.
****
Update : I have been able to clean the code and have managed to find why I do not have a debug.log. This is because the two XposedBridge classes I have ( one is initialisation of zygote and the other is the work file with hooks and replacements ) are not loaded. The error.log shows : Didn't find class " package ( strts without a com. ) NameOfThePackageWithoutComDot.NameOfTheExposedClass in the NameOfThePackageWithoutComDot-2.apk "
THIS IS SAID FOR THE TWO CLASSES.
PLEASE, RESPOND.