rom cooking - unyaffs - Hero, G2 Touch Android Development

I'm not daily Linux user but I'm usually savvy enough to figure things out; however unyaffs is giving me quite some trouble.
I have downloaded unyaffs from Lox's Rom cooking thread and placed it in the /bin/ folder but when I type /bin/unyaffs system.img I get "cannot get execute binary file". Help please?

did you chmod +x it?

kendong2 said:
did you chmod +x it?
Click to expand...
Click to collapse
No, didn't know I needed to. So now I have am getting "syntax error: ")" unexpected.
I am brand new to Rom cooking; sorry if this seems simple or stupid.

It needs to be in your computer's /bin/, not your phone's. Actually, it can be anywhere as long as it's on your $PATH. It's usually suggested that you create a /bin/ directory at your home folder (~) and then run all your personal binaries from there, then you can include that /bin/ in your .bashrc so that it gets loaded on every new terminal.
Open up a terminal window and do either
Code:
~$ gedit ~/.bashrc
or
Code:
~$ nano ~/.bashrc
depending on which editor you're comfortable with. Add the following to the end of your .bashrc
Code:
PATH=$PATH:/path-to-home/bin/
export PATH
where path-to-home is, ofcourse, the path to your home folder (usually /home/username), you can't use the ~ wildcard in the .bashrc script.
After you have your ~/bin set up, restart the terminal then move the unyaffs binary to ~/bin/ and then chmod a+x it, that way you can run the tool from any location.
To run the tool, just pass an image file as a parameter, note that the contents will be output to the directory where the image file is stored, so say I have a hero system file on my Desktop:
Code:
~$ cd ~/Desktop
~/Desktop$ mkdir HeroSystem
~/Desktop$ mv system.img HeroSystem
~/Desktop$ cd HeroSystem
~/Desktop/HeroSystem$ unyaffs system.img
end of file.
~/Desktop/Herosystem$_
The contents, along with the system.img will be in ~/Desktop/HeroSystem

Okay so added the following to bottom of my bashrc:
PATH=$PATH:/home/tito/bin/
export PATH
New terminal:
Code:
cd ~/bin
chmod a+x unyaffs
cd ~/Desktop/HeroSystem
unyaffs system.img
bash /home/tito/bin/unyaffs: cannot execute binary file
Followed all directions but still getting this error.

Found this site: hotrobots.blogspot.com/2009/07/useful-tool-unyaffs.html
Managed to unyaff my system.img; thanks for the help.

Hi, I am getting the "cannot execute binary file" error aswell..
I copied unyaffs in /bin and it is executable for everyone.
Yet and still it won't work. Any ideas?
Or do I really have to put unyaffs in a seperate bin folder and then edit bashrc?
Oh, and I'm running Mac OS X, if that's of any importance.. Bash is bash I think, or are there any differences I'm not aware of?

royalmitkaese said:
Hi, I am getting the "cannot execute binary file" error aswell..
I copied unyaffs in /bin and it is executable for everyone.
Yet and still it won't work. Any ideas?
Or do I really have to put unyaffs in a seperate bin folder and then edit bashrc?
Oh, and I'm running Mac OS X, if that's of any importance.. Bash is bash I think, or are there any differences I'm not aware of?
Click to expand...
Click to collapse
in this case you need the binary for osx, but the rest of the instructions should apply AFAIK (i have never used macos myself).

Thanks, but where can I get a binary for OSX?
The code.google.com page only offers one version of the binary..

royalmitkaese said:
Thanks, but where can I get a binary for OSX?
The code.google.com page only offers one version of the binary..
Click to expand...
Click to collapse
it is probably easier to compile it yourself...

download xcode from apple developer site for free
download source unyaffs from google site
and run gcc -o unyaffs unyaffs.c.
thats it ur done

Thanks for everyone's help. Almost done with my rom.

royalmitkaese said:
Thanks, but where can I get a binary for OSX?
The code.google.com page only offers one version of the binary..
Click to expand...
Click to collapse
I've attached version i compiled for OSX 10.6

jabbslad said:
I've attached version i compiled for OSX 10.6
Click to expand...
Click to collapse
sorry for reviving a dead thread but i was getting the "cannot execute binary file" so i used your attached compiled unyaffs and now i'm getting "Bad CPU type in executable"
I'm not registered on apple as a developer and can't download xcode :/

i'm getting "Bad CPU type in executable"
Click to expand...
Click to collapse
Are you running a 32 or 64 bit kernel on osx. You need a compile binary that is correct for your cpu. Let me know I will attach the right one in a reply. Check under apple menu >> about this mac >> more info >> software >> 64 bit kernel and extensions, yes or no.

anika200 said:
Are you running a 32 or 64 bit kernel on osx. You need a compile binary that is correct for your cpu. Let me know I will attach the right one in a reply. Check under apple menu >> about this mac >> more info >> software >> 64 bit kernel and extensions, yes or no.
Click to expand...
Click to collapse
@anika200 I'm also getting "Bad CPU type in executable". Mine is a 32bit one...
64-bit Kernel and Extensions: No
Could you please build one for 32bit kernel?

I got a hold of xcode (i love torrents ) and compiled it myself.
Heres the attached compiled OSX 32 bit unyaffs
Extract it and place it wherever you want, and to use it in another directory make sure you append it to your .bash_profile

Hey alright. You got it done before I could even check the thread again. I figured it was a 64 bit. Now we have both on here, nice.

Anyone familiar with doing this on windows?
I tried a couple of binaries, but i get errors.
Microsoft Windows XP [Version 5.1.2600]
C:\g2orgsys>unyaffs systemg2.img
28852 [main] unyaffs 3212 _cygtls::handle_exceptions: Exception: STATUS_ACCESS
_VIOLATION
30677 [main] unyaffs 3212 open_stackdumpfile: Dumping stack trace to unyaffs.e
xe.stackdump
348883 [main] unyaffs 3212 _cygtls::handle_exceptions: Exception: STATUS_ACCESS
_VIOLATION
375003 [main] unyaffs 3212 _cygtls::handle_exceptions: Error while dumping stat
e (probably corrupted stack)
Perhaps windows just sucks with this. I've never really used bash, but I got some LiveCDs around. :/

I use the attached file, works fine on windows. I think you need cygwin installed but not sure.

Related

How to Theme JFv1.51 CRB43-US using Ubuntu

One may think that it was nearly imposible to theme or modify a Us cupcake rom from JesusFreke because of his method of saving space on the system partition. In fact we have extra room for bigger sized themes. Here I will explain to you how to easily open and close the Cramfs files to modify /system/framework folder.
Cramfs can be opened and closed only through a Linux based shell.
To do this in windows, you should download Virtualbox.
After you finish installing it go and download Ubuntu.
Open Virtualbox and click on new. Follow directions to create your new Virtualbox Ubuntu OS.
Make sure you enable usb sharing. So that you can transfer files back and forth to both OS's.
Once you got Ubuntu running, open the terminal.
Type:
Code:
sudo -s
enter your password
apt-get install cramfsprogs
This command loads the Cramfs program files to your (Virtualbox Ubuntu OS).
Once the package installs, your ready to go.
-Opening Cramfs files:
Open terminal on your Virtualbox Ubuntu OS.
Type:
Code:
cramfsck -x /home/username/Desktop/opened 'framework.cramfs'
Cramfsck -x /home/username/Desktop/opened= Where the un cramfs-ed folder will be placed and what the folder is called.
Replace username above, with your user name.
framework.cramfs= the cramfs file you want to open.(Drag and drop in terminal)
The system will create a folder called "opened" on your desktop. (Feel free the change the name of folder from /opened to your liking)
That folder contains the /system/framework files un Cramfs-ed.
-Closing Cramfs files
You MUST be logged on to ROOT before closing Cramfs!!!
You MUST use the ORIGINAL files from the framework and app's folders of CRB43-US to prevent problems!!!
Open terminal on your Virtualbox Ubuntu OS.
Type:
Code:
sudo -s
enter password
mkcramfs '/home/username/Desktop/opened' framework.cramfs
mkcramfs '/home/username/Desktop/opened'= Location of the cramfs file.(Drag and drop in terminal)
Replace username above, with your user name.
framework.cramfs=The name of the cramfs file.
The system will create a cramfs file, located in the /home folder.(Click Places)
I have uploaded a CRB43-US Theme template to make it easier for you.
CRB43_US_Theme_Template.zip
Edit the template's framework and apps files to prevent forcloser!
I hope that you find this information useful in any way.
Here's some helpfull links:
How to manuals for creating themes
How to edit XML's
How to edit .9.png
Great technique. I've not tried it yet however I tried it with Cygwin. Unfortunately I don't think I was able to get it to work with it. Any thoughts?
From the other thread:
You need linux to do this! I mean come on, Android is not a Microsoft product, it's Linux based....Time to get your hands dirty.
Click to expand...
Click to collapse
I'm going to try it on SUSE Linux soon.
blackknightavalon said:
I'm going to try it on SUSE Linux soon.
Click to expand...
Click to collapse
Well ****. I did the sudo -s and password instructions and when I typed in the "apt-get install cramfsprogs" one I got "bash: apt-get: command not found" error message. HALP!!!1!
/SUSE Linux 10
blackknightavalon said:
Well ****. I did the sudo -s and password instructions and when I typed in the "apt-get install cramfsprogs" one I got "bash: apt-get: command not found" error message. HALP!!!1!
/SUSE Linux 10
Click to expand...
Click to collapse
apt-get is for Ubuntu and (i think) other Debian based Linux system. You'll need to use Redhat Package Manager (rpm) or some similar package manager.
http://en.opensuse.org/Libzypp/Package_Management
-Andy in Indy
Binary100100 said:
Great technique. I've not tried it yet however I tried it with Cygwin. Unfortunately I don't think I was able to get it to work with it. Any thoughts?
Click to expand...
Click to collapse
I tried it through Cygwin and I gave up because of the long process. I had to download a mirror site to download the cramfs program. Then I had to relocate most of the folders I wanted to modify because of that shell. Then I got more errors, so I said ...... that!!! And did it the way I posted it. I'll try to get it running on Cygwin and I'll let you know if I'm successful. FYI- you have alot more options on Ubuntu to Open ,see, and modify files on the Android packages, then you would on Cygwin.
So this maybe a newb question for some of you but I installed VirtualBox and Ubuntu 9.04 and followed the instructions. But I've hit a bump.
When I opened Terminal and entered sudo -s it will not let me enter my password. It just stays as a black box that doesn't move. I can type everywhere else... just not there for some reason. What am I missing?
Binary100100 said:
So this maybe a newb question for some of you but I installed VirtualBox and Ubuntu 9.04 and followed the instructions. But I've hit a bump.
When I opened Terminal and entered sudo -s it will not let me enter my password. It just stays as a black box that doesn't move. I can type everywhere else... just not there for some reason. What am I missing?
Click to expand...
Click to collapse
It doesn't show **** or anything, but its entering. Type password and press enter!
RichieDaze said:
It doesn't show **** or anything, but its entering. Type password and press enter!
Click to expand...
Click to collapse
Heh. I was hoping it was that easy. Thanks. I'm playing with it now.
Andy_in_Indy said:
apt-get is for Ubuntu and (i think) other Debian based Linux system. You'll need to use Redhat Package Manager (rpm) or some similar package manager.
http://en.opensuse.org/Libzypp/Package_Management
-Andy in Indy
Click to expand...
Click to collapse
Okay, I checked with my laptop's bin folder and I have rpm installed already. Today's n00b question is "now what?"
Wubi
Why don't you guys just use the wubi installer for ubuntu?
Its pretty mind numbingly easy to set up... and i haven't had any issues with it for the last month I've been using it.
http://wubi-installer.org/
then you can just use apt
jonnybueno said:
Why don't you guys just use the wubi installer for ubuntu?
Its pretty mind numbingly easy to set up... and i haven't had any issues with it for the last month I've been using it.
http://wubi-installer.org/
then you can just use apt
Click to expand...
Click to collapse
The only thing I didn't like about that installation was that I had to reboot to use either OS. With Virtual Box I can run my Os + 1,2, or 3 other OS's at the same time. That how I had it installed before I started using the Live cd to do the work. Thanks for giving us an other option. I guess its up to the users preference. I do recommend its use if you don't mind to reboot.
n00b question time: Would I be able to use the mkfs.cramfs program using SUSE? If so, what are the terminal codes?
/seriously stuck on this
its not working wat am i doing wrong
[email protected]:~$ sudo -s
[email protected]:~# ******
bash: ******: command not found
[email protected]:~# apt-get install cramfsprogs
Reading package lists... Done
Building dependency tree
Reading state information... Done
cramfsprogs is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
[email protected]:~# cramfsck -x /home/ubuntu/Desktop/opened 'framework.cramfs'
cramfsck: stat failed: framework.cramfs: No such file or directory
[email protected]:~#
Click to expand...
Click to collapse
the ****** is the password.
i have the framework.cramfs
i also have the CRB43_US_Theme_Template.zip file on the ubuntu dektop
i tried this also
[email protected]:~# cramfsck -x C:\Documents and Settings\******\Desktop 'framework.cramfs'
usage: cramfsck [-hv] [-x dir] file
-h print this help
-x dir extract into dir
-v be more verbose
file file to test
[email protected]:~#
Click to expand...
Click to collapse
can someone help
bboy_201 said:
its not working wat am i doing wrong
can someone help
Click to expand...
Click to collapse
Did you pull the cramfs file from the zip onto your desktop before you dragged it onto the terminal?
yes i did..
its on my destop for my windows n my ubuntu desktop
Finally, progress!
Just to update you guys on one thing: After roughly 3 weeks of blindly thrashing about SUSE Linux Enterprise Desktop 10 and its buggy BIOS screen like a n00b, I FINALLY got installed Debian on my laptop! Next step: Figure out how to make a cramfs image and test-port my personal modded Moon Dust theme (with the Firefox logo on the browser and Carbon Black trashcan) before I actually start porting other devs (and them submitting the ports to the original devs for their approval).
Am I the only one actually working on this?
Progress Part The Second
blackknightavalon said:
Just to update you guys on one thing: After roughly 3 weeks of blindly thrashing about SUSE Linux Enterprise Desktop 10 and its buggy BIOS screen like a n00b, I FINALLY got installed Debian on my laptop! Next step: Figure out how to make a cramfs image and test-port my personal modded Moon Dust theme (with the Firefox logo on the browser and Carbon Black trashcan) before I actually start porting other devs (and them submitting the ports to the original devs for their approval).
Am I the only one actually working on this?
Click to expand...
Click to collapse
I had a few bugs to work out, but now Debian is working as good as I can hope to get it working on my laptop. Now I need to compare the differences between the CRB43 framework-res images and RC33's. After that, it'll simply be a matter of a one-for-one swap with the instructions courtesy of OP.
The main thing is that I got the "apt-get install cramfsprogs" part working!

Using Linux Mint instead of Windows...(SOLVED!!)

SOLVED! Followed the Guide in Post #5, than kept getting an error saying libncurse.so.5 cannot be found. I than opened the Package Manager and downloaded everything in the sun-java6-sdk and anything related to it. Than searched for anything of libncurse and installed those. than got a libc++ (or similar) missing than went back to Package Manager and download anything with libc++ in it. Afterwards, ran fine.
One quirk, as I'm sure this will be general knowledge to any Linux user but I am still a newbie at it. In root # i had to do ./adb to run the command, running just # abd gave me errors, exiting root back to $ alowed me to just use $ adb and not have to do ./adb
I know it's pretty shoddy, I think i downloaded 250MB of stuff I'm not sure I need. lol. I searched for the libncurse.so.5 file and had a lot of em, i think the package that actually did the trick was a ncurse32bit package, as I am on a 64 bit system. So take that into consideration
downloaded the android sdk, extracted it, however, when i use terminal and goto the tools folder and use adb
i get...
[email protected] /usr/bin/android-sdk/tools $ adb
No command 'adb' found, did you mean:
Command 'cdb' from package 'tinycdb' (main)
Command 'gdb' from package 'gdb' (main)
Command 'aub' from package 'aub' (universe)
Command 'dab' from package 'bsdgames' (universe)
Command 'zdb' from package 'zfs-fuse' (universe)
Command 'mdb' from package 'mono-debugger' (universe)
Command 'tdb' from package 'tads2-dev' (multiverse)
Command 'pdb' from package 'python' (main)
Command 'jdb' from package 'openjdk-6-jdk' (main)
Command 'ab' from package 'apache2-utils' (main)
adb: command not found
Click to expand...
Click to collapse
I read something about adding it to path, and i went into my .profile and added in the :/usr/bin/android-sdk/tools after the $PATH yaddayadda but it still didn't work.
Any help is appreciated. This is really the only thing keeping me from wiping the 120gb partition for Win7 and using Linux only(which only has a 21gb partition)
Nrre said:
downloaded the android sdk, extracted it, however, when i use terminal and goto the tools folder and use adb
i get...
I read something about adding it to path, and i went into my .profile and added in the :/usr/bin/android-sdk/tools after the $PATH yaddayadda but it still didn't work.
Any help is appreciated. This is really the only thing keeping me from wiping the 120gb partition for Win7 and using Linux only(which only has a 21gb partition)
Click to expand...
Click to collapse
Since the android sdk doesn't actually install on your computer but placed there by you, you must make sure everything is in place for it to work properly. I am relatively new to linux myself, but this is what i've done to get it working properly:
create /etc/init.d/adbd
you will need to do this as root.
Code:
gksu gedit /etc/init.d/adbd
paste this into the file
Code:
#!/bin/sh
#
# For ADB deamon (Android Device Bridge)
#
case "$1" in
start)
/usr/bin/android-sdk/tools/adb start-server
;;
stop)
/usr/bin/android-sdk/tools/adb kill-server
;;
*)
echo "Usage: $0 start|stop" >&2
exit 3
;;
esac
now run this:
Code:
sudo ln -s /etc/init.d/adbd /etc/rc2.d/S10adbd
What you just did there was make sure adb daemon started as root whenever you booted (if you don't start it as root you will get errors later on down the road)
I'm not sure about mint, but on ubuntu its easier to just add the tools folder to your /etc/environment file.
Code:
gksu gedit /etc/environment
the file should look something like this:
Code:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/bin/android-sdk/tools"
go ahead and reboot just to make sure everything sticks. You should be good from then on.
You could add the path to your profile, but then if you have to run something as sudo, or if you have another user trying to do something similar, it could be a headache. If you don't have a /etc/environment, or if the above still doesn't work, go ahead and see if you have a ~/.bashrc.
edit that:
Code:
gksu gedit ~/.bashrc
add this to the bottom:
Code:
export PATH=${PATH}:/usr/bin/android-sdk/tools
let me know if this works, and if there are any more experienced linux users out there who notice any mistakes of mine, or have better advice please chip in. I just know I went through a huge amount of frustration to get adb to work properly, through much trial and error. this is the culmination of what i went through that was easiest for me. BTW i stole that code for the daemon to startup as root from somewhere else.
EDIT: I just realized my daemon is still not starting on boot? although, with the above script i can start it via:
Code:
sudo service adbd start
someone smarter than me, chip in and tell me what i'm doing wrong?
OP, you can always start the daemon yourself as root by typing
Code:
sudo /usr/bin/android-sdk/tools/adb start-server
EDIT: woops. I fixed the code above, as well as fixed my problem. on creating a link to rc2.d i typed "s10adbd" originally and it should be "S10adbd".
OP, this is a great example why paying attention to capital/lower case letters are super important when learning linux.
i changed my link and everything works on my system.
think i'm still doing it wrong. i didn't have a .bashrc file but i did have a bash.bashrc file.
i know linux mint is based off ubuntu.
here is my command line after doing everything above
richard-laptop richard # /usr/bin/android-sdk/tools/adb start-server
/usr/bin/android-sdk/tools/adb: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
richard-laptop richard # sudo service adbd start
adbd: unrecognized service
richard-laptop richard # adb shell
adb: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
Click to expand...
Click to collapse
think i'll take the laptop into work and mess with it tonight.
If you don't setup a your bash file, you can issue adb commands by using standard terminal commands from the /tools directory:
user:~$ ./adb start-server
Click to expand...
Click to collapse
To setup your .bash file, right from Google:
# On Linux, edit your ~/.bash_profile or ~/.bashrc file. Look for a line that sets the PATH environment variable and add the full path to the tools/ directory to it. If you don't see a line setting the path, you can add one:
export PATH=${PATH}:<your_sdk_dir>/tools
Click to expand...
Click to collapse
From terminal, you can run
user:~$ gedit ~/.bashrc
Click to expand...
Click to collapse
Nrre said:
think i'll take the laptop into work and mess with it tonight.
Click to expand...
Click to collapse
Please follow these instructions (source = wiki.cyanogenmod.com):
Ubuntu: Android SDK, ADB, Fastboot.
There are various great tutorials online to help you set these options up for Windows, but the process of setting this up in Ubuntu Linux is rather fragmented across various different forums, and can be rather confusing! This is a tutorial I have put together after having real trouble setting it up myself, after trawling through numerous forums, and getting help from many very helpful folks on various forums including this one!
Tutorial: This will show you how to complete the basic set up of the Android sdk, and then how to enable the 'adb' and 'fastboot' connections so as to allow you to issue commands from the terminal directly to your phone.
Disclaimer: As always, you follow this tutorial at your own risk, nobody is forcing you to! I take absolutely no responsibility for damage to your computer / mobile phone etc. This is the process I have followed, and it is working fine!
Basic Android sdk installation and set-up:
You will need to download the following files before you start:
android_sdk_r05-linux_86.tgz [1]
Fastboot [2]
1. Extract the 'android_sdk_r05-linux_86.tgz' file to your 'Home' folder and rename it to 'sdk' to make things easier later on.
2. Move the fastboot file in to the 'Tools' folder inside the 'sdk' folder.
3. Now right click on both the 'fastboot' and 'adb' files (inside the tools folder) and choose 'Properties' and then the 'Permissions' tab, and ensure they both have the 'allow executing file as program' box is ticked...Now reboot the computer, sorted!
Set up ubuntu to recognize your phone, and the adb/fastboot commands in the terminal
1.Open your 'Home' folder. Press 'Ctrl' & 'H' at the same time to view hidden files, and then open the '.bashrc' file and add the following text to the top of the file:
#AndroidDev PATH
export PATH=$PATH:/home/username/sdk/tools
2.Obviously you will need to replace 'username' with your own...Save the file and exit.
3.Now log-in as root.
3. Navigate to the following directory in the root filesystem: /etc/udev/rules.d/
4. Create the following empty file:
(ubuntu 10.04)
99-android.rules
(ubuntu 9.10)
70-android.rules
(ubuntu 7.10/8.04)
51-android.rules
5. You then need to edit the file with the following text (depending on your version of ubuntu):
ubuntu 7.10/8.04/9.10:
SUBSYSTEM==”usb”, ATTRS{idVendor}==”0bb4”, MODE=”0666”
SUBSYSTEM==”usb”, ATTRS{idVendor}==”18d1”, MODE=”0666”
SUBSYSTEM==”usb”, ATTRS{idVendor}==”22b8”, MODE=”0666”
ubuntu 6.06:
SUBSYSTEM==”usb_device”, SYSFS{idvendor}==”0bb4”, MODE=”0666”
SUBSYSTEM==”usb_device”, SYSFS{idvendor}==”18d1”, MODE=”0666”
SUBSYSTEM==”usb_device”, SYSFS{idvendor}==”22b8”, MODE=”0666”
6. Save this file, and then open the terminal and enter the following command:
chmod a+rx /etc/udev/rules.d/70-android.rules
Change the '70' to '51' depending on your version of ubuntu.
For a list of the vendor ID's go here: VendorID's [3]
7. Now reboot the computer.
8. Open Terminal, and issue the following commands:
su
cd /home/username/sdk/tools/
./adb kill-server
./adb start-server
You will now be able to open a terminal and carry out 'adb' and 'fastboot' commands directly.
Credit and thanks to:
koalaboy, Apostasy, Cloverdale, wddglr, JgeZau.
EDIT: I have followed this tutorial to the letter myself today on my laptop to prove it works, for both yours the reader, and my own peace of mind as the writer! Enjoy, it works flawlessly!
Click to expand...
Click to collapse
I have followed these directions more than once and each time they work flawlessly. This should work with Linux Mint, since Mint's based off Ubuntu.
For Part 4, use Ubuntu 10.04 when creating the empty file and for Part 5, use this SUBSYSTEM: SUBSYSTEM==”usb”, ATTRS{idVendor}==”0bb4”, MODE=”0666” and paste that into your 99-android.rules file.
followed to a T.
not sure how to log in as root, so i just 'run as administrator' i can't find anything on root for this.
i still get the following after i do that entire guide
richard-laptop richard # cd /home/richard/sdk/tools
richard-laptop tools # ./adb kill-server
./adb: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
richard-laptop tools # ./adb start-server
./adb: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
Click to expand...
Click to collapse
Nrre said:
followed to a T.
not sure how to log in as root, so i just 'run as administrator' i can't find anything on root for this.
i still get the following after i do that entire guide
Click to expand...
Click to collapse
To login in as root, you enter:
Code:
sudo su
As for the "error while loading shared libraries: libncurses.so.5" -- I've never seen that error before. Might be Linux Mint problem? I currently run Ubuntu 10.04 32 Bit.
when i do SU it asks my password and the $ becomes a #
i assume that is root? i dont have to do SUDO i just did SU
yeah if i do SUDU SU i get a 'SUDO command not found'
gonna post this over on the linux mint forums see if they can help me to.
Nrre said:
when i do SU it asks my password and the $ becomes a #
i assume that is root? i dont have to do SUDO i just did SU
yeah if i do SUDU SU i get a 'SUDO command not found'
gonna post this over on the linux mint forums see if they can help me to.
Click to expand...
Click to collapse
Wait... wait.. are you trying to do following instructions on your phone or on your computer?
If you run su on your phone, sure you'll get root (# sign). But the command, sudo su was meant for your computer. The instructions I listed are for your computer with Linux Mint installed.
yeah i'm doing it on my computer =P
if i do SUDU SU it gives me that error, but SU gives me #
so...i was hoping it'd all be teh same since Mint is based off ubuntu and half my updates are ubuntu files.
[email protected] ~ $ sudu
No command 'sudu' found, did you mean:
Command 'sudo' from package 'sudo' (main)
Command 'sudo' from package 'sudo-ldap' (universe)
Command 'tudu' from package 'tudu' (universe)
sudu: command not found
[email protected] ~ $ SUDU su
SUDU: command not found
[email protected] ~ $ SUDU SU
SUDU: command not found
Click to expand...
Click to collapse
so, not sure what else to do.
sudo
not sudu
elegantai said:
sudo
not sudu
Click to expand...
Click to collapse
balls, well i still get the same result after i go through and make all the changes and use SUDO SU instead of just SU, i get the same prompt with #
this is still my end result.
richard-laptop richard # cd /home/richard/sdk/tools/
richard-laptop tools # ./adb kill-server
./adb: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
richard-laptop tools # ./adb start-server
./adb: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
Click to expand...
Click to collapse
makes me feel like i'm missing a file somewhere. i did download the newest android sdk and not the older version that is in the guide. but i still installed the packages for android 2.1 and 2.2
suppose i'll delete it all and start over.
EDIT: Went through, put in proper vendor IDs and noticed i put Richard in the Path and not richard, still, says it's missing the same "libncurses.so.5" so...not sure what to do. =/
I don't know that error either, but looking at this thread:
http://bbs.archlinux.org/viewtopic.php?id=66878
sounds like it could be a java issue? Didn't think to ask, have you installed the java sdk? which version of java are you running?
now that i think about it...i don't believe i downloaded a new java...
the worse news is my win7 got corrupted somehow =P so now i only have Linux so time to dig in and try this out.
I'd download the stuff now but I'm tethering through my phone so i'm lucky to get 600kbps download speeds in this reception area.
I could step 10 feet outside and hit 1200kbps though. So i formatted the HD and reinstalled Linux Mint. Once i get home I'll look into the JDK as that makes sense now that I think about it to.
EDIT: Should I install Eclipse also? Installing Android SDK and Java6 JDK right now. I really just want to use ADB for now to send commands to phone etc.
No need for eclipse.. That's just for actual development
ADB Error: /home/richard/sdk/tools/adb: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
'adb start-server' failed.
Click to expand...
Click to collapse
this shows up int he Android SDK/AVD manager as i install all the packages...
EDIT: opened up software manager, and downloaded every sun-java package, than installed everything that showed up when i typed libncurses ... once it's done will reboot and try again =P
2nd EDIT: i decided to search for libncurses.so.5 and i have 3 of em, one in usr/lib, /lib64 and something else.
so..not sure where else to put it, went into synaptics thing or something and downloaded ncurses32bit as i noticed none of my lib32 folders had it...giving it a go.
btw... my .bashrc is .profile, i copied .profile and renamed it to .bashrc and my prompt stopped showing up in terminal...linux is so weird.
3rd EDIT: Just isn't meant to be. got to ./adb kill-server and instead of missing the libncurse.so.5 i am now missing..
richard-laptop tools # ./adb kill-server
./adb: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
Click to expand...
Click to collapse
off i go to hunt this package down
it's working...finally
however...
richard-laptop tools # adb devices
No command 'adb' found, did you mean:
Command 'cdb' from package 'tinycdb' (main)
Command 'gdb' from package 'gdb' (main)
Command 'aub' from package 'aub' (universe)
Command 'dab' from package 'bsdgames' (universe)
Command 'zdb' from package 'zfs-fuse' (universe)
Command 'mdb' from package 'mono-debugger' (universe)
Command 'tdb' from package 'tads2-dev' (multiverse)
Command 'pdb' from package 'python' (main)
Command 'jdb' from package 'openjdk-6-jdk' (main)
Command 'ab' from package 'apache2-utils' (main)
adb: command not found
richard-laptop tools # ./adb devices
List of devices attached
HT*********** device
Click to expand...
Click to collapse
i have ot do ./adb and not just adb
EDIT: exit su, and in $, lets me just do adb.
THANK YOU EVERYONE <3 Wish I could +rep or Thanks your post here.!!
changed title to reflect it. was a good 'thrown under the bus' into linux. now to read up more on it. w/out losing half my CCNA knowledge i've gathered...ha
Enjoy Linux. You'll enjoy it once you get used to it.
Sent from my PC36100 using XDA App
Nrre said:
it's working...finally
however...
i have ot do ./adb and not just adb
EDIT: exit su, and in $, lets me just do adb.
THANK YOU EVERYONE <3 Wish I could +rep or Thanks your post here.!!
changed title to reflect it. was a good 'thrown under the bus' into linux. now to read up more on it. w/out losing half my CCNA knowledge i've gathered...ha
Click to expand...
Click to collapse
Since this has been solved, I would advise posting the resolution on the first page -- so new users are aware of what exactly you had to do to fix it.

[GUIDE] Beginner guide how to make your ROM *.img from Linux OS !!!

First you must to install yaffs!!!
Download attached archive and unpack it to /usr/sbin/ folder with your File Manager or Terminal window. I preffered File Manager, it is simpliest way.
After copyed mkfs.yaffs2 and unyaffs, you must to change permissions on these two files.
Open Terminal if you don`t previously opened and write...
[email protected]_name:~$ sudo nautilus
Nautilus is File Explorer on Ubuntu Linux. On other Linux distribution you may have other File Explorer. Anyway... open it with sudo command.
Enter your root password and navigate to /usr/sbin folder.
Find these two files mkfs.yaffs2 and unyaffs.
Right click mouse on it then click to see "Properties".
In properties tab you will see "Permissions" tab.
Click on it and set "read and write" option for all users and group in this tab then close window and Terminal.
You can change permission in the Terminal window with this command if you want...
[email protected]_name:~$ sudo chmod 667 /usr/sbin/mkfs.yaffs2
[email protected]_name:~$ sudo chmod 667 /usr/sbin/unyaffs
This is it for install mkfs.yaffs2 and unyaffs.
After that, create new folders on your desktop named as "newrom".
Copy system.img from ROM instalation folder to newrom folder and run unyaffs.
Open terminal and type... Only type BOLD text.
[email protected]_name:~$ cd /home/your_name/Desktop/newrom
[email protected]_name:~/Desktop/newrom$ unyaffs /home/your_name/Desktop/newrom/system.img
Wait unyaffs to uncompress all files and folders from system.img
When unyaffs has been completed uncompress procedure, you will see something like that...
end of image
[email protected]_name:~/Desktop/newrom$
Close terminal window if you want to close.
Open folder newrom and delete system.img file. Folder "newrom" contains everything from your system.img file. You may to change, delete or something else to create your new Android build. Yes you may to be ROM cookers.
After your intervention on files and many other stuff in your "new rom", you will be prepare to create your new "system.img" file.
This process must to be in other folder with diference name. Not to be in same folder where is your previous uncopressed folders and files. In my case this folder is "newrom".
Folder for new "system.img is my Desktop.
Ok, let see what we must to do... In case when you previous closed Terminal window, you must be placed on Desktop uses CD command in Terminal.
[email protected]_name:~$ cd Desktop
You must see this...
[email protected]_name:~/Desktop$
Enter this...
[email protected]_name:~/Desktop$ mkfs.yaffs2 newrom/ system.img
And you must see this...
mkfs.yaffs2: Android YAFFS2 Tool,Build by PowerGUI
at http://www.openhandsetalliance.org.cn
Building...
Build Ok.
[email protected]_name:~/Desktop$
After that you will see new system.img on your Desktop.
For boot.img file, procedure is same except name of *.img file.
That`s it. I hope that is help.
Thanks to everyone who helped me to write this guide.
Enjoy.
FileFixer.
so much thanks. i'll have a try~
Ignore this
I have extracted the files in to the directories as suggested but when I run the command to extract the system.img I get access is denied. I have tried this as my standard user account and logged on as root any ideas?
Edit: modified the permissions on the two files I dumped in to sbin and resolved the issue!
Yes... If you don`t permission you can login as root and change rigts on this two files.
In my case i just copy these two files in /usr/sbin folder and everything work fine.
This is, maybe i think,for per user mod.
I would be to edit thread for this problem...
Works very well very nice thread man. I was able to fully extract the img file from a gingerbread build and play arround with it and rebuild it cheers!
Pictures or video's?
You will be free to create them. I have no much time for this. if you try my procedure step by step, you can learn something...
@FileFixer
Maybe you could also post a way for us to edit the initrd.gz files in the rom builds, so we can make some changes that are necessary for SD builds to work with MAGLDR "AD SD" option ourselves?
Thanks, Santroph.
Unpack initrd.gz on your desktop and open cpio archive. Inside is a few scripts and few elf files.
I am not developer but i will trying to learn more about this.
Pretty useful tutorial i will try that soon.
FileFixer said:
Unpack initrd.gz on your desktop and open cpio archive. Inside is a few scripts and few elf files.
I am not developer but i will trying to learn more about this.
Click to expand...
Click to collapse
Cool guide did you have any help you would like to credit
No, i don`t have any help about this. I just playing with some files.
FileFixer said:
No, i don`t have any help about this. I just playing with some files.
Click to expand...
Click to collapse
KillaHurtz said:
Cool guide did you have any help you would like to credit
Click to expand...
Click to collapse
hehe
(10 chars)
When I use the command unyaffs /home/your_name/Desktop/newrom/system.img I get an error open image file failed.
Why is this not working for me?
...
Never mind, it worked!
Very useful topic!
Yo MUST be placed in to your "newrom" folder before start unyaffs command.
[email protected]_name:~$ cd /home/your_name/Desktop/newrom
then type this...
[email protected]_name:~/Desktop/newrom$ unyaffs /home/your_name/Desktop/newrom/system.img
Only type BOLD text.
Never mind, it worked for you!
After repack - no root
I did unpack and repack system.img according this guide (without any changes - only for testing). After flash the ROM works fine, but is not rooted. Original ROM is rooted.
Why? I didn't make any changes in unpacked system.img.
Can anyone help me with this, please?
Thanks.
I think that you must set permissions to all before pack img file.
santroph said:
@FileFixer
Maybe you could also post a way for us to edit the initrd.gz files in the rom builds, so we can make some changes that are necessary for SD builds to work with MAGLDR "AD SD" option ourselves?
Thanks, Santroph.
Click to expand...
Click to collapse
Hi,
Here's a quick howto
* mkdir initrd-temp
* cp initrd.gz initrd-temp
* cd initrd-temp
* gunzip initrd.gz -c | cpio --extract --make-directories
* rm initrd.gz
* Make your changes
* find .|cpio -H newc -o|gzip -9 -c - > ../initrd.gz
I hope that helps
Hey,
thanks for this useful thread!
I have problems in this whole process of booting a custom rom ( in my case Miui) in the Emulator . I have compiled the whole rom on a Linux VM with your Guide and pushed it in a Windows system into android-9/images/system.img but it won't boot I don't know what I am doing wrong. My system.img is 2 GB big I think this is not normal. if i am replacing the system.img with the original out of the emulator, it is booting. I just want to boot the Miui rom to port some features to Cyanogenmod... Thanks in advance. I have a HTC Legend btw .

[Q] Mac equivalent to flashtool?

Is there a Mac equivalent to FlashTool?
I also have the same question.
Hi there mmzubair!
In the end the best solution I found was just to install windows XP with bootcamp! Or if your Macs newer than mine (using a 4 year old Mac Mini) you could install XP using parallels so you don't have to rebooting every time you want to flash your phone!
Sent from my R800i using Tapatalk 2
I'm wondering if you can install and run flashtool with Wine?
Sent from my R800x using Tapatalk 2
beez1717 said:
I'm wondering if you can install and run flashtool with Wine?
Sent from my R800x using Tapatalk 2
Click to expand...
Click to collapse
I believe you can't because wine can't install driver software.
flashtool linux
the flashtool site explains a method of installing it on linux based systems, but it all sounds gibberish to me (because im a noob) and i cannot understand it, has anybody done this? please explain in pure english if possible. thank you.
Flashtool on Mac instructions
!! UPDATE, ALL
There is a flashtool for mac on androxyde's github.
Basically...
You need (in this order):
1/ Xcode, Download and install it from App store/your mac's supplied DVD/Apple developer website
> If using version 3 and earlier, make sure the "UNIX Development", "System Tools", "Command Line Tools", or "Command Line Support" is selected during the installation process,
> If using version 3 and earlier, Apple's Command Line Developer Tools are found at the Apple Developer Connection site
2/ MacPorts, See section 2 on http://www.macports.org/install.php.
Then:
3/ Download and unzip flashtool from androxyde's github
More prep work for the USB stuff:
4/ Open Terminal and type/run code:
Code:
ls -la /opt/local/lib/libusb-1.0.dylib
If "no file or directory" found then run code:
Code:
sudo port install libusb
Now, to run Flashtool (ASSUMING YOU DID NOT RENAME THE FLASHTOOL FOLDER AND PROGRAM NAME SINCE UNZIP!):
5/ Open Terminal and type/run code:
Code:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/lib; */Flashtool/FlashTool;
or
Code:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/lib; ~/Downloads/Flashtool/FlashTool;
Alternatively:
> Open up the "Flashtool" Unix Executable File in TextEdit
> Copy and paste
Code:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/lib
the the line directly underneath export OS=$(uname -s)
> Save it, and from now on, double click the FlashTool executable file to open flashtool
6/ Flashtool window should pop up and a smile appears on your face
Maintenance
7/ To update MacPorts and installed ports, open terminal and run:
Code:
sudo port -v selfupdate; sudo port -v upgrade outdated;
Themindbuddah said:
Is there a Mac equivalent to FlashTool?
Click to expand...
Click to collapse
J0YU said:
There is a flashtool for mac on androxyde's github.
Basically...
You need (in this order):
1/ Xcode, Download and install it from App store/your mac's supplied DVD/Apple developer website
2/ MacPorts, See section 2 on http://www.macports.org/install.php.
Then:
3/ Download flashtool from androxyde's github
More prep work for the USB stuff:
5/ Open Terminal and type/run code:
Code:
ls -la /opt/local/lib/libusb-1.0.dylib
If "no file or directory" found then run code:
Code:
sudo port install libusb
6/ Last line of code to run in Terminal for prep:
Code:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/lib
Now run Flashtool:
7/ Open the Flashtool folder which you unzipped in 3/
8/ Double click on "Flashtool" (Unix Executable File)
Hopefully that helps, haven't tried it out personally because I'm too lazy for 1/ and 2/ but reply/thanks if it works out fine!
Maintenance
9/ To update MacPorts, open terminal and run:
Code:
sudo port -v selfupdate
Click to expand...
Click to collapse
That's right there is a FlashTool Mac Edition check it out: http://androxyde.github.com/
Thanks for the post. The LD_LIBRARY_PATH variable was the key for me. With the 2 mods for steps 6 & 8 in bold, these directions worked on my MacBook Air. FlashTool now comes up and runs!
-- Cronin
6/ Last line of code to run in Terminal for prep:
Code:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/lib
Becomes:
Code:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/lib
​
Now run Flashtool:
7/ Open the Flashtool folder which you unzipped in 3/
8/ Double click on "Flashtool" (Unix Executable File)
Becomes:
go to your FlashTool folder
Code:
cd ../FlashTool
​execute the FlashTool:
Code:
- ./Flashtool
​
J0YU said:
There is a flashtool for mac on androxyde's github.
Basically...
You need (in this order):
1/ Xcode, Download and install it from App store/your mac's supplied DVD/Apple developer website
2/ MacPorts, See section 2 on http://www.macports.org/install.php.
Then:
3/ Download flashtool from androxyde's github
More prep work for the USB stuff:
5/ Open Terminal and type/run code:
Code:
ls -la /opt/local/lib/libusb-1.0.dylib
If "no file or directory" found then run code:
Code:
sudo port install libusb
6/ Last line of code to run in Terminal for prep:
Code:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/lib
Now run Flashtool:
7/ Open the Flashtool folder which you unzipped in 3/
8/ Double click on "Flashtool" (Unix Executable File)
Hopefully that helps, haven't tried it out personally because I'm too lazy for 1/ and 2/ but reply/thanks if it works out fine!
EDIT: check out the post below for more info/stuff
Maintenance
9/ To update MacPorts, open terminal and run:
Code:
sudo port -v selfupdate
Click to expand...
Click to collapse
I followed this guide and tried the other variation but when i launch flashtool this happen:
Macbook:~ Suz$ /Users/Suz/Downloads/FlashTool/FlashTool ; exit;
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'usb-1.0': dlopen(libusb-1.0.dylib, 9): image not found
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:179)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:252)
at com.sun.jna.Library$Handler.<init>(Library.java:140)
at com.sun.jna.Native.loadLibrary(Native.java:368)
at com.sun.jna.Native.loadLibrary(Native.java:353)
at se.marell.libusb.jna.LibUsb.<clinit>(LibUsb.java:11)
at se.marell.libusb.LibUsbSystem.<init>(LibUsbSystem.java:36)
at se.marell.libusb.LibUsbSystem.<init>(LibUsbSystem.java:73)
at linuxlib.JUsb.init(JUsb.java:38)
at gui.FlasherGUI.main(FlasherGUI.java:170)
logout
[Processo completato]
nothing else! Where am I doing wrong?
smayor said:
I followed this guide and tried the other variation but when i launch flashtool this happen:
Macbook:~ Suz$ /Users/Suz/Downloads/FlashTool/FlashTool ; exit;
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'usb-1.0': dlopen(libusb-1.0.dylib, 9): image not found
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:179)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:252)
at com.sun.jna.Library$Handler.<init>(Library.java:140)
at com.sun.jna.Native.loadLibrary(Native.java:368)
at com.sun.jna.Native.loadLibrary(Native.java:353)
at se.marell.libusb.jna.LibUsb.<clinit>(LibUsb.java:11)
at se.marell.libusb.LibUsbSystem.<init>(LibUsbSystem.java:36)
at se.marell.libusb.LibUsbSystem.<init>(LibUsbSystem.java:73)
at linuxlib.JUsb.init(JUsb.java:38)
at gui.FlasherGUI.main(FlasherGUI.java:170)
logout
[Processo completato]
nothing else! Where am I doing wrong?
Click to expand...
Click to collapse
i have the same problem can someone help me?
currently trying to diagnose it, I got the same problem too xD
The problem is that instead of */Flashtool/Flashtool you should replace before * with the the path from root to the file.
On my system this was:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/lib; /Users/<username>/Downloads/Flashtool/FlashTool;
Was getting same error and then it loaded
edit--
In fact, just open FlashTool in text wrangler or another editor and paste this in:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/lib
after line:
export OS=$(uname -s)
save that and it should work. I did this, then I got an app got Platypus and wrapped the whole thing into a .app file. I'd upload it but it is 80 megs and I have a quarter meg upload rate
You could probably put that jar on the same path as the other files and it would find it, and save others going through the other steps but I'm not sure. I've not had time to try.
brim4brim said:
The problem is that instead of */Flashtool/Flashtool you should replace before * with the the path from root to the file.
On my system this was:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/lib; /Users/<username>/Downloads/Flashtool/FlashTool;
Was getting same error and then it loaded
edit--
In fact, just open FlashTool in text wrangler or another editor and paste this in:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/lib
after line:
export OS=$(uname -s)
save that and it should work. I did this, then I got an app got Platypus and wrapped the whole thing into a .app file. I'd upload it but it is 80 megs and I have a quarter meg upload rate
You could probably put that jar on the same path as the other files and it would find it, and save others going through the other steps but I'm not sure. I've not had time to try.
Click to expand...
Click to collapse
oops, did the unix wildcard " * " not work on your machine? yeah it's either that or
Code:
~/Downloads/Flashtool/FlashTool
should also work. Thanks for the heads up, might update my tutorial more to cover more stuff and maybe release a moded FlashTool executable, I'm not sure
J0YU said:
oops, did the unix wildcard " * " not work on your machine? yeah it's either that or
Code:
~/Downloads/Flashtool/FlashTool
should also work. Thanks for the heads up, might update my tutorial more to cover more stuff and maybe release a moded FlashTool executable, I'm not sure
Click to expand...
Click to collapse
I hope you guys can help, I tried using the methods you gave (exporting the var and updating the file in textwrangler) but I'm still getting the error below. Would you know how to get around this?
I checked and I do have the file:
Users-iMac:FlashTool user$ ls -la /opt/local/lib/libusb-1.0.dylib
lrwxr-xr-x 1 root admin 18 May 12 00:25 /opt/local/lib/libusb-1.0.dylib -> libusb-1.0.0.dylib
Error below:
Last login: Sat Nov 3 00:47:57 on ttys001
Users-iMac:~ user$ /Users/user/Downloads/FlashTool/FlashTool ; exit;
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'usb-1.0': dlopen(libusb-1.0.dylib, 9): image not found
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:179)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:252)
at com.sun.jna.Library$Handler.<init>(Library.java:140)
at com.sun.jna.Native.loadLibrary(Native.java:368)
at com.sun.jna.Native.loadLibrary(Native.java:353)
at se.marell.libusb.jna.LibUsb.<clinit>(LibUsb.java:11)
at se.marell.libusb.LibUsbSystem.<init>(LibUsbSystem.java:36)
at se.marell.libusb.LibUsbSystem.<init>(LibUsbSystem.java:73)
at linuxlib.JUsb.init(JUsb.java:38)
at gui.FlasherGUI.main(FlasherGUI.java:170)
logout
[Process completed]
---------- Post added at 01:21 AM ---------- Previous post was at 01:02 AM ----------
Somehow, double clicking on FlashTool gives me that error... But doing a ./FlashTool in the terminal works. Thanks!
Would you guys happen to know if a Mac version of the rooting toolkit is available?
Somehow, double clicking on FlashTool gives me that error... But doing a ./FlashTool in the terminal works. Thanks!
Would you guys happen to know if a Mac version of the rooting toolkit is available?
Click to expand...
Click to collapse
Are you talking about ADB and FlashTool for mac?
Or like the actual rooting stuff like Superuser.apk and BusyBox (root_tools.rar in the attached files)?
Use wine
Sent from my R800x using xda app-developers app
problems with libusb
Hi guys,
thank you so much for this guide,
I have a problem when i try to open flash tool with the
Code:
~/Downloads/Flashtool/FlashTool
this error shows up
Minimum libusb version is 1.0.14. Found 1.0.9
It can be downloaded on
i have tried everything and i really cannot updated :crying::crying:
Please help me i never done it before
Java 1.6 or 1.7
Hi!
Whenever I try to run the commands, I get the following error message:
"Java version must be 1.6 or 1.7"
I have the latest version of Java installed on my Mac, and I can actually see the Java icon from the Control Panel. Any ideas about the error I get?
Thanks!
Hi!
Whenever I try to run the commands, I get the following error message:
"Java version must be 1.6 or 1.7"
I have the latest version of Java installed on my Mac, and I can actually see the Java icon from the Control Panel. Any ideas about the error I get?
Thanks!
Click to expand...
Click to collapse
1// What version of Mac OS X are you running on?
2// What do you get when you run java -version in terminal?
Hi guys,
thank you so much for this guide,
I have a problem when i try to open flash tool with the
Code:
~/Downloads/Flashtool/FlashTool
this error shows up
Minimum libusb version is 1.0.14. Found 1.0.9
It can be downloaded on
i have tried everything and i really cannot updated
Please help me i never done it before
Click to expand...
Click to collapse
I'm looking into it...
btw are you trying to run flashtool version v0.9.9.0 or an older one?
I written the tutorial a while ago lol

SOLVED! Python on the command line (scripts on post #17)

Hello everyone,
If your just reading this, skip to page 2 to save me some embarassment... Been a learning curve.
Go here .... http://forum.xda-developers.com/showpost.php?p=47607547&postcount=17
First post here and well I hope it's in the right place. I am definitely a novice programmer, am a little comfortable writing small python scripts which leads to this...
I got my phone rooted, I have sl4a ( It Nice! I like it. You like dogs?), and I just got my CM 10 source on Ubuntu 10 like Google recommends. I got adb working and Terminal IDE so I originally wanted to get python to be able to be called by the bash shell it provides ( I think its bash). I sorta got it working for a single session but what a drag, and I would get an error along the lines that the title suggests, so I,m not happy about that.
I also managed to get a copy of python from com.googlecode.pythonforandroid into /system/bin/ and now when I type "python" into an ADB shell I get the python interpreter!!! Whoo hooo, but I still got that same error. A "import sys", "import ephem", and maybe a few more workes but still something is wrong it said something thiss stuff here..
"""[email protected]:/data/data # python
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
'import site' failed; use -v for traceback
Python 2.6.2 (r262:71600, Mar 20 2011, 16:54:21)
[GCC 4.4.3] on linux-armv7l
Type "help", "copyright", "credits" or "license" for more information.
>>>
"""
update/bump
Ok so looking at the error message again it seems that it wants two prefixes for the $PYTHONHOME variable, I assume two paths and the secon one is to the executable that I put in /system/bin/ which is already in my path hence why python is callable. I had also fumbled around haphazardly with my $PATH vriables the other day and may have added the path to some of the libs python was asking for such as libpython2.6.so, I think I added the directory that lib is found in to my path (its found in "/data/data/com.googlecode.pythonforandroid/files/python/lib/" I think, need to double check that one), so thats what ive done that made this 'click' so to speak into popping out the python interpretor.
Also I found this file...MSM8960_lpm.rc but I forgot from where it came. It looks as if it contains some global variables that get set during boot, am I right?
This is the top part of it...
"""
on early-init
start ueventd
on init
sysclktz 0
loglevel 3
# setup the global environment
export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
export LD_LIBRARY_PATH /vendor/lib:/system/lib
export ANDROID_BOOTLOGO 1
export ANDROID_ROOT /system
export ANDROID_ASSETS /system/app
export ANDROID_DATA /data
export EXTERNAL_STORAGE /mnt/sdcard
export EXTERNAL_STORAGE2 /mnt/sdcard/external_sd
export USBHOST_STORAGE /mnt/sdcard/usbStorage
export ASEC_MOUNTPOINT /mnt/asec
export LOOP_MOUNTPOINT /mnt/obb
export BOOTCLASSPATH /system/framework/core.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/core-junit.jar
"""
So I am thinking that if I set the paths to my Python exec and libs here, as well as Paths for Lua, Perl, JRuby, Python 2.7, Etc, etc then I would have an assortment of scripting languages to launch into ffrom ADB, am I right? This would help me and others write scripts for ADB in many languages to do repetitive grunt work from scripts.
Any advice would be great as it works but its like python is injured, "import os" didnt work ;( but "import sys" did
It would also be nice if these same vriables could be set for Terminal Emulator, Terminal IDE, and the like, I know SSH is in the works with T. IDE and that one has telnet though I havent figured that out yet.
What should I do? This seems like an OS related issue but if the interpreter is there and compiled for arm and the libs aswell why would this not work?
python -v output
this is the "python -v" output to show what's happening, maybe it'll help....
"""
[email protected]:/ # python -v
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
'import site' failed; traceback:
ImportError: No module named site
Python 2.6.2 (r262:71600, Mar 20 2011, 16:54:21)
[GCC 4.4.3] on linux-armv7l
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import os
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named os
>>>
# clear __builtin__._
# clear sys.path
# clear sys.argv
# clear sys.ps1
# clear sys.ps2
# clear sys.exitfunc
# clear sys.exc_type
# clear sys.exc_value
# clear sys.exc_traceback
# clear sys.last_type
# clear sys.last_value
# clear sys.last_traceback
# clear sys.path_hooks
# clear sys.path_importer_cache
# clear sys.meta_path
# clear sys.flags
# clear sys.float_info
# restore sys.stdin
# restore sys.stdout
# restore sys.stderr
# cleanup __main__
# cleanup[1] zipimport
# cleanup[1] signal
# cleanup[1] exceptions
# cleanup[1] _warnings
# cleanup sys
# cleanup __builtin__
# cleanup ints: 3 unfreed ints
# cleanup floats
[email protected]:/ #
"""
That snippet you posted is from the init.rc inside the boot.img...so yes, it has all sorts of initialization code
CNexus said:
That snippet you posted is from the init.rc inside the boot.img...so yes, it has all sorts of initialization code
Click to expand...
Click to collapse
Ok, so I'll so some reading on setting $PYTHONHOME variable and others, I need to learn how that all works anyways. Most if not all of what I find documents how to set the variables for Windows, Mac, or Linux and not for Android. I will do my best to use that knowledge to fit this situation. I also need to dive around the file system a bit more and find all those libs and try to get the paths set for those to work with ADB and not just SL4A.
If I can do that maybe some more Linux programs/commands can be moved into Android's system, I know alot of the GUI apps for Linux have dependencies for python and gtk and qt, those modules might be portable to Android if they haven't already done so. Not to mention the other interpreters like Perl. To be perfectly honest what I want to do is port over Kali's toolset (at least the cmd line tools) over to android to they can be run from a terminal emulator or adb its self. Thats what I want to do with it, then wrap it all up into a ROM and build it. I know they have already compiled most of Kali's and BackTrack's programs on ARM so I was thinking of pulling those apps from there after an upgrade and then moving them into Androids system e.g /system/bin : /system/lib : /etc/* and so on, if the file systems are too different I suppose I can add directories and make a PATH for them or add them to $PATH once I learn how all that works.
Any good documentation on related issued anyone might be able to link to would be great, I'll be droppin by every so often while I'm grinding through google, thanks in advance for any help and thank you for your time, a bit of a read I suppose.
Environment variables like that would need to be set inside the boot.img, so if you want to unpack it and see exactly how things are defined and what other files are there (good exercise all around IMO), grab my tools from over here and unpack it for yourself and take a look:
cool tools
CNexus said:
Environment variables like that would need to be set inside the boot.img, so if you want to unpack it and see exactly how things are defined and what other files are there (good exercise all around IMO), grab my tools from over here and unpack it for yourself and take a look:
Click to expand...
Click to collapse
Well I downloaded twrp 2.3.1.0-d2spr and I used the split_boot tool in the package and got a little tree of files including the init.rc and the other msm one, they seem very similar if not identical (?), weird.
I just have a quick question, do I need to repack all this at a certain size? In other words, if I make any changes in the ramdisk image will it refuse to boot? I browsed over some sites and read somewhere that if I changed the kernal image it would fail a hash check and that the type of hashing ( I use bubble bags, but that's for another forum). How much attention do I need to pay to the size of these files I may alter before I repack and flash to the device?
Edge-Case said:
Well I downloaded twrp 2.3.1.0-d2spr and I used the split_boot tool in the package and got a little tree of files including the init.rc and the other msm one, they seem very similar if not identical (?), weird.
I just have a quick question, do I need to repack all this at a certain size? In other words, if I make any changes in the ramdisk image will it refuse to boot? I browsed over some sites and read somewhere that if I changed the kernal image it would fail a hash check and that the type of hashing ( I use bubble bags, but that's for another forum). How much attention do I need to pay to the size of these files I may alter before I repack and flash to the device?
Click to expand...
Click to collapse
Yes, actually. You need to repack at certain offsets/addresses or the device will be unable to read it properly
Run the boot_info script on your .img file and it will give you everything you need to know to repack the boot.img correctly
First you gotta repack the ramdisk (repack_ramdisk [optional out file])
Then after you do that, you can use the mkbootimg binary along with the info from my boot_info script to make a new boot.img with the right offsets
I've done a ton of boot.img splitting, so here's what it should look like (I forget the cmdline parameter)
Code:
mkbootimg --kernel KERNEL --ramdisk RAMDISK --base 0x80200000 --oversize 2048 --cmdline 'android.I.don't.remember.this.one' --ramdiskaddr 0x81500000 -o new_boot.img
Sent from my S3 on Sense 5 (you jelly?)
CNexus said:
Yes, actually. You need to repack at certain offsets/addresses or the device will be unable to read it properly
Run the boot_info script on your .img file and it will give you everything you need to know to repack the boot.img correctly
First you gotta repack the ramdisk (repack_ramdisk [optional out file])
Then after you do that, you can use the mkbootimg binary along with the info from my boot_info script to make a new boot.img with the right offsets
I've done a ton of boot.img splitting, so here's what it should look like (I forget the cmdline parameter)
Code:
mkbootimg --kernel KERNEL --ramdisk RAMDISK --base 0x80200000 --oversize 2048 --cmdline 'android.I.don't.remember.this.one' --ramdiskaddr 0x81500000 -o new_boot.img
Sent from my S3 on Sense 5 (you jelly?)
Click to expand...
Click to collapse
Thanks,
I actually just got the CWM ROM manager, I updated my CWM and am backing up my rom now, its pretty much stock lacking updates cuz of root I think, I eventually wanna get over to CM or some other rom but CM seems to be supported pretty well.
1) So the backup just finished a second ago, can I pull a boot image out of that? :EDIT: Check. I saw it in the recovered folder.
2) I'll use the boot info on that img when I get it.
3) I guess this is all for testing the variables and getting interpreters to run from adb and T.E. after that I need to install CM 10 to get some blobs, thats all thats hanging me up from modifying the source to build my own version, this is great exercise as it will need to be done when building this "Cyano-Kali" or whatever, I was also thinking "Kali0id" as in Kalioid and Kali zero i.d.
ok well I did some messing around and I got this lill chroot setup working from adb which is kool, I just took a no gui kali.img and a script I found to chroot into it ( Maybe Google "Weaponizing Android"), it needs a lil investigating though I get a couple errors, it looks like it was modified from a chroot into ubuntu (arm).
I put the script into /system/xbin/ and then made it executable (that seems to be the only place I could chmod), I looked at the sript at it points to a coded directory for the kali.img which is something like "/storage/sdcard0/kali/kail.img". This puts the script in a location that is already in the environ variable and you can call it from any cwd by typing "kali".
Note: Interesting tip (may be trivial to the pros), typing "bash" gives me a colorful interface and the bash interpreter, this is good for a first command when entering the terminal or adb because then you can modify the bash rc file found in "/system/etc/bash/" (I think, I'll double check later.*FIXED*).
So, I think I might be able to mod those variables there to include PYTHONPATH, PYTHONHOME, etc...
Then when I launch bash i should be able to launch python and whatever else. (*Check*, it works but you must first "bash" and then "python" to allow the bashrc file to get ran and add PYTHONHOME and PYTHONPATH to the enviroment)
I think the first shell that you get put into is shell and not bash but maybe I'm wrong.
*side note, If you want to su into bash its best ime to do that first, then bash, otherwise when you su while in bash you loose the color, idk why.
heres my results so far...
Code:
[email protected]:~$ adb devices
List of devices attached
xxxxxxxxxx device
[email protected]:~$ adb shell
[email protected]:/ $ su
[email protected]:/ # bash
void endpwent()(3) is not implemented on Android
localhost / # kali
ioctl LOOP_SET_FD failed: Device or resource busy
mount: Device or resource busy
net.ipv4.ip_forward = 1
[[email protected] ~$ cd .. && ls
bin dev home lost+found mnt proc run selinux sys usr
boot etc lib media opt root sbin srv tmp var
[[email protected] /$ which macchanger
/usr/bin/macchanger
[[email protected] /$ which ophcrack
/usr/bin/ophcrack
[[email protected] /$ which reaver
/usr/bin/reaver
[[email protected] /$ which aircrack-ng
/usr/bin/aircrack-ng
[[email protected] /$ python --version
Python 2.7.3
[[email protected] /$ perl --version
This is perl 5, version 14, subversion 2 (v5.14.2) built for arm-linux-gnueabi-thread-multi-64int
(with 80 registered patches, see perl -V for more detail)
Copyright 1987-2011, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
[[email protected] /$ bash --version
GNU bash, version 4.2.37(1)-release (arm-unknown-linux-gnueabi)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[[email protected] /$ python
Python 2.7.3 (default, Jan 2 2013, 22:35:13)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import sys
>>>
[[email protected] /$ exit
Shutting down Kali ARM
failed: Device or resource busy
losetup: /dev/block/loop255: Device or resource busy
localhost / # exit
1|[email protected]:/ # ^D
1|[email protected]:/ $ ^D
[email protected]:~$
Does anybody know how to mount an external sdcard from the command line on the Debian version of Linux on Android?
Is that even possible, like driver wise and what not?
Nice!
To mount it, first you would need it's device name or UUID..
Sent from my S3 on Sense 5 (you jelly?)
Success!
Alright! I got Python working from the terminal emulator!
I ended up copying the files that got installed by the original installer into my system/ lib, xbin, and, bin directories I just kinda put stuff here or there and then I just got one error about platform independent libraries instead of both dependent and independent. I'm alil add about things sometimes. Then about ten minutes ago while chilling on the patio the syntax for the PythonHome and path variables became clear to me. So i changed it to export and wrapped the paths in quotes and figured out the prefix : exec_prefex thing.
Now python works!!!!!!! ill run it on adb tomorrow and show the results as well as exactly how to get it working after i figure out exactly what i did right. It was probably the last thing.
Edge-Case said:
Alright! I got Python working from the terminal emulator!
I ended up copying the files that got installed by the original installer into my system/ lib, xbin, and, bin directories I just kinda put stuff here or there and then I just got one error about platform independent libraries instead of both dependent and independent. I'm alil add about things sometimes. Then about ten minutes ago while chilling on the patio the syntax for the PythonHome and path variables became clear to me. So i changed it to export and wrapped the paths in quotes and figured out the prefix : exec_prefex thing.
Now python works!!!!!!! ill run it on adb tomorrow and show the results as well as exactly how to get it working after i figure out exactly what i did right. It was probably the last thing.
Click to expand...
Click to collapse
Nice
Sent from my S3 on Sense 5 (you jelly?)
Solution !
Ok I got everything cleaned up a bit, lets see whats going on here...
So hopefully bash is preinstalled for everyone, I just found it, the only changes I made in the past week are installing...
1) CyanogenMod, I believe you will need to already be rooted, have busybox, and a custom recovery to get this far. If you can get CyanogenMod working then you'll probably be able to replicate this, mayeb even with just root and busybox on a stock sprint rom, idk.
2) SL4A along with Python 2.6, Perl, and JRuby. (I hope normal ruby programs can be ran will JRuby, if not I'll either mod the programs or port ruby to android or look for another port.
3) Terminal IDE. This could have been a source of bash if it wasn't native to android or the Terminal Emulator/busybox.
Once you have The above, at least python 2.6 with SL4A, Terminal Emulator, Busybox, and root.
You can (the file system maybe different for different phones but since we are in a specific place of this forum I'll stick with what I found on my phone specifically)
Use a root browser and find a way to remount your file system to read/write or r/w or rw mode so you can write to /system directory. It is located in the / directory of the entire system, not just the sdcard0 partition.
You can open a terminal and type "set" to get a closer look at whats happening here on Android. We are mainly interested in the Environment Variables.
What I did was copy
"/storage/sdcard0/com.googlecode.pythonforandroid/extras/python" ----> "/system/etc/python" ##THIS IS A DIRECTORY
"/data/data/com.googlecode.pythonforandroid/files/python/lib/python2.6" ----> "/system/lib/python2.6" ##THIS IS A DIRECTORY
"/data/data/com.googlecode.pythonforandroid/files/python/bin/python" -> "/system/xbin/python ##THIS IS A FILE, IT IS AN EXECUTABLE!
"/"/data/data/com.googlecode.pythonforandroid/files/python/lib/" ----> "/system/lib/python2.6/" ##WE WANT ALL THE "*.so" FILES NEXT TO THE ORIGIONAL "*/PYTHON2.6/" DIR IN THE "DATA/DATA/" SIDE OF THE TREE TO BE COPIED TO THE SYSTEM SIDE AND INTO THE "/system/lib/python2.6/" DIR NEXT TO THE "/system/lib/python2.6/lib-dynload/" DIR
We want our "/system/lib/python2.6" directory to contain the following :
"/lib-dynload" is a dir; and all the .so files from earlier there are about 8 with a fresh install of python and no modules, some of you may already know how to incorporate modules from this point, but I still need to do some experimenting.
---------------------------------------------------------
OK
if you still following then your gonna wanna do the following
go to "/system/etc/bash" and open the bashrc file, we need to add PYTHONPATH and PYTHONHOME to it, this is how I set it up....
About half way down it will read
Code:
"""
# set some environment variables
HOME=/sdcard
TERM=linux (maybe change this to "Administrator" but that may break something)
"""
# Our additions follow:
export PYTHONHOME="/system/etc/python:/system/xbin/python"
export PYTHONPATH="/system/etc/python:/system/lib/python2.6/lib-dynload:/system/lib/python2.6"
Ok, now if you go to your teminal emulator or ADB shell you can type:
bash [press enter]
python [press enter]
and check out the results
or
su [enter]
bash [enter]
python [enter]
and see what happens
whats happening is that your PYTHONHOME and PYTHONPATH variables are being set when you enter bash, and since they are exported from the bashrc file they get carried over to any child activities that may spawn, such as "python". Correct me if I am wrong.
I may have forgot some little file I put somewere a few days ago or something so let me know if it doesn't work for you i'll do my best to help you get it working on your phone to,
other then finding a rc file for the shell that you start with when you launch the terminal or any other process maybe even, I may need to do what CNex suggested and complete the change in a boot.img to flash to my phone. that should result in the variables being passed to all activities.
Peace yo
Any questions I'll drop around if this dies of from here, well live and let die I suppose.
Just a screen shot
Just a screen shot.
I found the "mkshrc" file in "/system/etc" today so I added the PATHs to that file and now when teminal emulator starts it has access to python's libs. ("/system/etc/mkshrc" should be the location)
I've run into two problems, the first I can live with, the second is only more reason to port Kali's toolset into android.
1) I can't yet access the pydocs for interactive help, for example...
Code:
[email protected]:~$ adb shell
[email protected]:/ $ python
dlopen libpython2.6.so
Python 2.6.2 (r262:71600, Mar 20 2011, 16:54:21)
[GCC 4.4.3] on linux-armv7l
Type "help", "copyright", "credits" or "license" for more information.
>>> import android
>>> help (android)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/manuel/AptanaStudio3Workspace/python-for-android/python-build/output/usr/lib/python2.6/site.py", line 431, in __call__
File "/home/manuel/AptanaStudio3Workspace/python-for-android/python-build/output/usr/lib/python2.6/pydoc.py", line 1720, in __call__
File "/home/manuel/AptanaStudio3Workspace/python-for-android/python-build/output/usr/lib/python2.6/pydoc.py", line 1766, in help
File "/home/manuel/AptanaStudio3Workspace/python-for-android/python-build/output/usr/lib/python2.6/pydoc.py", line 1508, in doc
File "/home/manuel/AptanaStudio3Workspace/python-for-android/python-build/output/usr/lib/python2.6/pydoc.py", line 1314, in pager
File "/home/manuel/AptanaStudio3Workspace/python-for-android/python-build/output/usr/lib/python2.6/pydoc.py", line 1338, in getpager
File "/home/manuel/AptanaStudio3Workspace/python-for-android/python-build/output/usr/lib/python2.6/tempfile.py", line 286, in mkstemp
File "/home/manuel/AptanaStudio3Workspace/python-for-android/python-build/output/usr/lib/python2.6/tempfile.py", line 254, in gettempdir
File "/home/manuel/AptanaStudio3Workspace/python-for-android/python-build/output/usr/lib/python2.6/tempfile.py", line 201, in _get_default_tempdir
IOError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']
>>>
And
2) When I chroot into Kali.img the PYTHONPATH and PYTHONHOME variables get carried over and interfear with python within Kali. ????
Work around: is just modifing "bashrc" then when you want python or other inerpreters launch bash first and call kali from shell.
Solution: is porting Kali's Toolkit and more Linux programs and commands into Android. Then release as rom or give instructions on how to set up.
No Really, I think I got it figured out this time.
If your running python 2.6 via Py4a then youll use the first script to access python from the command line or over adb, you'll need su to but it in /system/bin or /system/xbin and to use this command to write to the system partition "mount -wo remount systemfs /system" when your done use "mount -ro remount systemfs /system" (with out the quotes of course).
Note: adbd can only be ran as root, so this method will only work as root. Also I had some trouble disconnecting from adb as "exit", it hung till I unplugged the phone from usb. But, still I got to run scripts python that utilize the androids api with-out having to directly open sl4a and then the python interpreter from there.
Note2: Maybe one who was slick enough could get the source for sl4a and pick out the server and facade code, then make a little dex to be ran from the command-line instead of starting the server via "am" and instead of using sockets, maybe ashmem to share the JSON results that get sent back to python.
This is the script for 2.6 :​
Code:
#!/system/bin/sh
am start -a com.googlecode.android_scripting.action.LAUNCH_SERVER \
-n com.googlecode.android_scripting/.activity.ScriptingLayerServiceLauncher \
--ei com.googlecode.android_scripting.extra.USE_SERVICE_PORT 54326
export AP_PORT=54326
export AP_HOST=127.0.0.1
adbd &
export EXTERNAL_STORAGE=/mnt/sdcard/com.googlecode.pythonforandroid
export PY4A=/data/data/com.googlecode.pythonforandroid/files/python
export PY4A_EXTRAS=$EXTERNAL_STORAGE/extras
PYTHONPATH=$EXTERNAL_STORAGE/extras/python
PYTHONPATH=${PYTHONPATH}:$PY4A/lib/python2.6/lib-dynload
export PYTHONPATH
export TEMP=$EXTERNAL_STORAGE/extras/python/tmp
export HOME=/sdcard
export PYTHON_EGG_CACHE=$TEMP
export PYTHONHOME=$PY4A
export LD_LIBRARY_PATH=$PY4A/lib
$PYTHONHOME/bin/python "[email protected]"
This one is for 3.2 :​
Code:
#!/system/bin/sh
am start -a com.googlecode.android_scripting.action.LAUNCH_SERVER \
-n com.googlecode.android_scripting/.activity.ScriptingLayerServiceLauncher \
--ei com.googlecode.android_scripting.extra.USE_SERVICE_PORT 54332
export AP_PORT=54332
export AP_HOST=127.0.0.1
adbd &
export EXTERNAL_STORAGE=/mnt/sdcard/com.googlecode.python3forandroid
export PY34A=/data/data/com.googlecode.python3forandroid/files/python3
export PY4A_EXTRAS=$EXTERNAL_STORAGE/extras
PYTHONPATH=$EXTERNAL_STORAGE/extras/python3
PYTHONPATH=${PYTHONPATH}:$PY34A/lib/python3.2/lib-dynload
export PYTHONPATH
export TEMP=$EXTERNAL_STORAGE/extras/python3/tmp
export HOME=/sdcard
export PYTHON_EGG_CACHE=$TEMP
export PYTHONHOME=$PY34A
export LD_LIBRARY_PATH=$PY34A/lib
$PYTHONHOME/bin/python3 "[email protected]"
Explanation:​-First, the server which handles calls to Android's APIs gets starts by it's activity with am and port is set.
-Second, AP_PORT and AP_HOST get exported so that android.py will have its parameters set to interact with the "facade"
-Third, adbd gets started in the background (I cant give a full explanation, but I found the RPC mechanism between the python interpreter and the sl4a server when android.py is imported and droid.* is attempted)
-Fourth, Python's environment variables get set, doing it this way helps to avoid copying the whole python installation to /system (as I did in the past ), just put one of these scripts in /system/bin or /system/xbin and name it "python" then chmod the script "chmod 755 python" you will be able to call the interpreter and put the shabang in your python scripts (ie "#!/system/bin/python").
-Fifth, launch the interpreter.
Here is a short session over adb:​
Code:
[email protected]:/ # python
dlopen libpython2.6.so
Python 2.6.2 (r262:71600, Mar 20 2011, 16:54:21)
[GCC 4.4.3] on linux-armv7l
Type "help", "copyright", "credits" or "license" for more information.
>>> import android
>>> droid = android.Android()
>>> droid.makeToast("Hello!")
Result(id=0, result=None, error=None)
>>> droid.getLastKnownLocation()
Result(id=1, result={u'passive': {u'bearing': 0, u'altitude': 0, u'time': 1384816643565L, u'longitude': -67.551754299999999,
u'provider': u'network', u'latitude': 96.0520909, u'speed': 0, u'accuracy': 3533}, u'network': {u'bearing': 0, u'altitude': 0, u'time':
1384816643565L, u'longitude': -67.551754299999999, u'provider': u'network', u'latitude': 96.0520909, u'speed': 0, u'accuracy':
3533}, u'gps': None}, error=None)
>>> exit()
And some credit to others:
http://code.google.com/p/python-for...sh?r=997929b1bbaa53cdf76acfff419ec13c13f869b7
http://stackoverflow.com/questions/10839879/python-sl4a-development
Those are links to where I got some info from to help put this together. The adbd thing was just trying "adb forward tcp:xxxx tcp:xxxx" but that didn't work, so I tried adbd forward tcp:xxxx tcp:xxxx and it looked like it hung there, so I ctl^ c and then just adbd and it hung there again, but when used the "&" to background it and then went to python to try android.py, it worked:good:
And for a lot of fun, go here:
http://code.google.com/p/android-scripting/wiki/ApiReference
-or here-
http://www.mithril.com.au/android/doc/index.html

Categories

Resources