[Q] Compile bash for droid? - Android Software/Hacking General [Developers Only]

I dont know if this is the proper place for this thread...and I know there is a bash compiled already floating around (which I have) but for the purposes of learning Im trying to create a custom ROM from scratch, building busybox,bash,froyo, etc..
I am trying to comile bash 4.1 from the source code, compiling process is pretty straightforward but im having trouble making it cross compile for ARM
Here is what spits out after I enter "file bash" after compiling.
ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, for GNU/Linux 2.6.15, not stripped
The part I'm missing is how to make it into the proper format which is:
ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.14, stripped
Any suggestions?
also is there a way to make it the default shell upon booting?

There's some toolchain tips here. Don't know if there any use to you.
http://android-tricks.blogspot.com/2009/02/hello-world-c-program-on-using-android.html

Pointed me in the right direction thanks .
heres the the code
I added the path of my arm-2010q1/bin to my .bashrc
then:
Code:
CC=arm-none-linux-gnueabi-gcc ./configure --prefix=/opt/arm_bash/ -host=arm-linux --enable-static-link --without-bash-malloc
conigured what I needed to and it cross compiled successfully after make.

drew408 said:
also is there a way to make it the default shell upon booting?
Click to expand...
Click to collapse
http://forum.xda-developers.com/showthread.php?t=727566

Related

Compiling kernel modules?

I'm trying to compile bnep as a module (needed for Bluetooth PAN), but I keep running into the following error when I try to load it:
insmod: init_module 'bnep.ko' failed (Exec format error)
Click to expand...
Click to collapse
I'm using kernel-android-msm-htc-2.6.25 and arm-eabi-4.2.1-gcc from the android source, so I'm not sure what's wrong. Anyone have any pointers?
rale00 said:
I'm trying to compile bnep as a module (needed for Bluetooth PAN), but I keep running into the following error when I try to load it:
I'm using kernel-android-msm-htc-2.6.25 and arm-eabi-4.2.1-gcc from the android source, so I'm not sure what's wrong. Anyone have any pointers?
Click to expand...
Click to collapse
hmm. good question. Unfortunately I don't have any advice right now :\. But it sounds interesting and now I want to see if I can build a minimal do-nothing kernel module and get it to load.
More to come
No joy here. I couldn't even figure out how to get it to compile a minimal "hello world" kernel module.
I am trying to make a driver too. But I am still not sure how to compile a module.
I was trying to make the whole source tree from my redhat machine, but no luck.
So instead, I plan to just compile my driver by using the toolchain from android source.
But I am sure how to make a makefile for this.
Could you share it?
Thanks,
Blues
The "exec format error" means that you compiled it for the wrong architecture.
For a quick reference to seeing what arch for which a binary is compiled, use the "file" command found on any Linux computer (but not present on the phone itself).
The file command is an extremely useful function for identifying files -- including files that are packaged together, such as the .img files in the updates (see the -k option).
Dynamically linked executable:
"ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped"
Statically linked executable:
"ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, stripped"
Object file:
"ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped"
More specifically, if it doesn't say 32bit ARM, it will not work.
This may prove useful to some:
http://www.gentoo.org/proj/en/base/embedded/handbook/index.xml?part=1&chap=6
(And the compilers references in "CROSS_COMPILING" must be in your path -- see also the CC variable)
This is file on wlan.ko pulled directly from the phone - a known working module:
wlan.ko: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped
This is the module I compiled:
bnep.ko: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped
There must be something else at work here...
I am having same problem now. I am also using the toolchain from Android source...
I haven't gotten this deep into Android yet, but make sure the kernel source tree you're compiling against is the same version as the kernel on the phone. Modules compiled for a different kernel version will not load on another one (usually).
rale00 said:
This is file on wlan.ko pulled directly from the phone - a known working module:
wlan.ko: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped
This is the module I compiled:
bnep.ko: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped
There must be something else at work here...
Click to expand...
Click to collapse
Right after you try to insmod the module, type dmesg. Look through the last part of the output and see if there is anything helpful..
yeah, that's the problem.
The version magic number doesn't match.
May I know where to get the RC19 source tree? Thanks.
JesusFreke said:
Right after you try to insmod the module, type dmesg. Look through the last part of the output and see if there is anything helpful..
Click to expand...
Click to collapse
Thanks, that was the key. Apparently kernel/scripts/setlocalversion queries git for part of the version string. I ended up just changing it to print "-01843-gfea26b0", which is the string for RC30, and the module worked fine.
Any Help for Compiling and Debug Native Apps is here
http://honeypod.blogspot.com/2008/01/debug-native-application-for-android.html

help porting a linux program to the android

hi all
i have created a custom rom for myself because i want to add a linux program: scanmem
i have copied the file in system/xbin
using this guide http://lukasz.szmit.eu/2009/12/making-your-own-rooted-android-rom.html on step6 for su command
the problem is that doesn't work ...
when i open a terminal in my desire and type :
su
scanmem
i receve this message:
scanmem: 1: syntax error: "(" unexpected
any help, suggestion ? scanmem is compiled for i386 32bit
kiokoman said:
any help, suggestion ? scanmem is compiled for i386 32bit
Click to expand...
Click to collapse
There's your problem.
Code:
[email protected]:/tmp$ file busybox
busybox: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.14, stripped
[email protected]:/tmp$
If you don't have the source, time and a cross-compiler, you have a problem It's also Little Endian from memory.
This is the busybox binary I tested in case you want to strip it down: http://benno.id.au/blog/2007/11/14/android-busybox
i found a lot of information with google
http://www.kbrandt.com/2009/06/how-to-cross-compile-the-bash-shell-for-android-15.html
i have the source maybe i can compile for arm
kiokoman said:
i found a lot of information with google
http://www.kbrandt.com/2009/06/how-to-cross-compile-the-bash-shell-for-android-15.html
i have the source maybe i can compile for arm
Click to expand...
Click to collapse
Precisely. You should also check the dependencies (if any) and make sure you cross-compile those too.
jayshah said:
Precisely. You should also check the dependencies (if any) and make sure you cross-compile those too.
Click to expand...
Click to collapse
oh my god
depends on libc6 and readline6, i have to cross-compile half gnu/linux
out of my hand
Shame :/
Why did you need it anyway? Perhaps there is another way for what you want to achieve.
jayshah said:
Shame :/
Why did you need it anyway? Perhaps there is another way for what you want to achieve.
Click to expand...
Click to collapse
i think it was an easy program to port and with a frontend for android I would have used it as the first cheats system like cheat engine for pc
I made this. I compile scanmem fo my android phone (p500) from sourses.
He even gets up and running, but not quite.
Opt for a process (pid command)
It finds regions of memory. But during the search, crashes ". bus Error"
Maybe it's because of the specificity of an android, or due to the fact that I had to change all calls to readline lib, because otherwise the project will not compile.
I will continue to watch and understand ...
Done. Scanmem works fine on my phone.

How to install 'gcc' and 'make' so I can compile bash, uname, and *****X?

How do I install gcc and make so i can make all ; make install any package I want? What about ldconfig and dynamic linking tools? At the very least bash should compile since it's basically just character strings and such, no specific libs required.
I believe most people would cross-compile the desired apps on a Linux box.

[java][debian][armv6][jre1.6][jdk 7] [jdk 8]

woo, I found this gem on a search and ended up at talk.maemo.org in the n900 section.
oracle released an armv6/armv7 headless 1.6 jre binary set! way back in april, but I hadn't seen it until today.
works in debian squeeze on my armv6 (msm7627) optimus v... it runs, but I haven't put it through its paces yet for any real testing.
I thought someone might enjoy this since for a long time it was really hard to find a jre for arm debian except for icedtea, which isn't as compatible with some things as the oracle release hopefully is.
here is the post including a download link for the jre.
another post by the same user points to an arm-friendly java7 download as well.
thank you Fabry.
official Oracle java jdk now released for ARM Linux!
download page
editbsolete.
since the sun java6 jdk is available for download to arm devices through debian apt-get, but it has a set of binaries which won't work on the armv6, someone enterprising might be able to patch the jre binaries into the jdk for a usable armv6 jdk.
/end edit
edit:
to use the 1.6 jre...
download it from Oracle
copy it to /opt in your armel debian install (or chroot)
untar it there
Code:
cd /opt
tar -xzvf ejre-1_6_0_25-fcs-b06-linux-arm-vfp-eabi-headless-14_apr_2011.tar.gz
ln -s /opt/java/ejre1.6.0_25/bin/java /usr/bin/java
thank you Dak.
after that, you should be able to use java at the command line.
further down in the first linked thread are instructions for linking the jre to fennec, probably adaptable to iceweasel.
edit:
newer JDK!
JDK 8 (with JavaFX) for ARM Early Access
for armv6 hard float applications. Installation instructions for the Raspberry Pi are linked from that page. You have to accept a license agreement.
I know this was quite a long time ago, but you state that sun-java6-jdk is in debian repositories for arm, but I am not finding it.
Is there a download link for sun-java6-jdk on arm?
Hope you see this.
Take care man. And thanks for the great info!
DiehlC said:
I know this was quite a long time ago, but you state that sun-java6-jdk is in debian repositories for arm, but I am not finding it.
Is there a download link for sun-java6-jdk on arm?
Hope you see this.
Take care man. And thanks for the great info!
Click to expand...
Click to collapse
It showed up back then when google searching for the package, but apt-get won't bring it in because of the jre dependency it can't fulfill.
they must've realized and removed it.
It may be possible to get the x86 .deb and repack it with the jre binaries or something... I actually had it installed on some chroot on my android phone to try building the android emulator on-device (which eventually worked, but the dang thing wouldn't boot in qemu.)
I'll dig around and see if I've still got it, but no guarantees.
bigsupersquid said:
It showed up back then when google searching for the package, but apt-get won't bring it in because of the jre dependency it can't fulfill.
they must've realized and removed it.
It may be possible to get the x86 .deb and repack it with the jre binaries or something... I actually had it installed on some chroot on my android phone to try building the android emulator on-device (which eventually worked, but the dang thing wouldn't boot in qemu.)
I'll dig around and see if I've still got it, but no guarantees.
Click to expand...
Click to collapse
I reolize this topic is a bit older but thought it would be worth letting you all know that installing orical's Java is way easier on Android running Linux. I've been at it awile and have a script set up to fully install the soft float version of JDK 7 and am working on a downloader script (it is actually a tall order reliably downloading the source from orical reliably) to incorperate in when debugged. Eventually I'll be testing/writing one for hard float versions too but for now you all can find what has been tested as working with "Debian Kit" from here https://github.com/S0AndS0/Debian-Kit-Mods check the readme for how to modify for your preferred version of Java and enjoy
Update 02272014- the java downloading script I mentioned earlier is now ready for testing; you may use it to download jre or jdk either hard float or soft float (4 options) and the installer script has been updated for soft float jdk version 7u51. I'll be working on making the download script call up the installer scripts today too
Update 03032014- try the "ARM_Linux_Mods" script in the above github; it will step you through the download and installation of Java JDK soft or hard float.
bigsupersquid said:
woo, I found this gem on a search and ended up at talk.maemo.org in the n900 section.
oracle released an armv6/armv7 headless 1.6 jre binary set! way back in april, but I hadn't seen it until today.
works in debian squeeze on my armv6 (msm7627) optimus v... it runs, but I haven't put it through its paces yet for any real testing.
I thought someone might enjoy this since for a long time it was really hard to find a jre for arm debian except for icedtea, which isn't as compatible with some things as the oracle release hopefully is.
here is the post including a download link for the jre.
another post by the same user points to an arm-friendly java7 download as well.
thank you Fabry.
official Oracle java jdk now released for ARM Linux!
download page
editbsolete.
since the sun java6 jdk is available for download to arm devices through debian apt-get, but it has a set of binaries which won't work on the armv6, someone enterprising might be able to patch the jre binaries into the jdk for a usable armv6 jdk.
/end edit
edit:
to use the 1.6 jre...
download it from Oracle
copy it to /opt in your armel debian install (or chroot)
untar it there
Code:
cd /opt
tar -xzvf ejre-1_6_0_25-fcs-b06-linux-arm-vfp-eabi-headless-14_apr_2011.tar.gz
ln -s /opt/java/ejre1.6.0_25/bin/java /usr/bin/java
thank you Dak.
after that, you should be able to use java at the command line.
further down in the first linked thread are instructions for linking the jre to fennec, probably adaptable to iceweasel.
edit:
newer JDK!
JDK 8 (with JavaFX) for ARM Early Access
for armv6 hard float applications. Installation instructions for the Raspberry Pi are linked from that page. You have to accept a license agreement.
Click to expand...
Click to collapse
I'm working on AOSP. I copied all extracted tar file to somewhere inside system folder. When I type
Code:
java -version
It says:
Code:
/system/bin/sh: java: No such file or directory
But it exist!
In other side, I typed
Code:
ln -s /system/ejre1.6.0_25/bin/java /usr/bin/java
and it said:
Code:
4 /system/linux_arm_sflt/jre/bin/java 4 /system/bin/java
What should I do now?
UPDATE:
When I run java directly Or symbolink), it says:
Code:
/system/bin/sh: java: can't execute: Permission denied
And when I run it with busybox, it says:
Code:
java: applet not found
UPDATE:
Even when I root my device, I get above errors.
dr_jacky_2005 said:
thank you Dak.
after that, you should be able to use java at the command line.
further down in the first linked thread are instructions for linking the jre to fennec, probably adaptable to iceweasel.
edit:
newer JDK!
JDK 8 (with JavaFX) for ARM Early Access
for armv6 hard float applications. Installation instructions for the Raspberry Pi are linked from that page. You have to accept a license agreement.
I'm working on AOSP. I copied all extracted tar file to somewhere inside system folder. When I type
It says:
But it exist!
In other side, I typed
and it said:
What should I do now?
UPDATE:
When I run java directly Or symbolink), it says:
And when I run it with busybox, it says:
UPDATE:
Even when I root my device, I get above errors.
Click to expand...
Click to collapse
you have to run Java in a Linux chroot.
Android shell can't handle it (system/bin/sh is definitely Android path)
bigsupersquid said:
you have to run Java in a Linux chroot.
Android shell can't handle it (system/bin/sh is definitely Android path)
Click to expand...
Click to collapse
What do you mean by run it in a Linux chroot?
If you means run it after type SU command, I did.
I root my device, then I can use su command in shell.
But if you means something else, please explain more in detail.
Thanks.
dr_jacky_2005 said:
What do you mean by run it in a Linux chroot?
If you means run it after type SU command, I did.
I root my device, then I can use su command in shell.
But if you means something else, please explain more in detail.
Thanks.
Click to expand...
Click to collapse
here's an example of how to use a chroot for Nexus 10
you can also look up lil debi, linuxonandroid, and variations of "chroot (debian, Ubuntu) on Android" with Google, for more information.
bigsupersquid said:
here's an example of how to use a chroot for Nexus 10
you can also look up lil debi, linuxonandroid, and variations of "chroot (debian, Ubuntu) on Android" with Google, for more information.
Click to expand...
Click to collapse
All of these installed a virtual Linux that can access with VNC!
But I want to put java binary and its libraries in my Android source, and compile it; then run my jar file with for wxampel installed terminal amulator.apk, or from PC (adb shell command).
Is that possible?
dr_jacky_2005 said:
All of these installed a virtual Linux that can access with VNC!
But I want to put java binary and its libraries in my Android source, and compile it; then run my jar file with for wxampel installed terminal amulator.apk, or from PC (adb shell command).
Is that possible?
Click to expand...
Click to collapse
probably not. the Java binary relies on Linux libraries, like libc instead of bionic. not seen anything about running Java under Android except for their dalvik java.
bigsupersquid said:
probably not. the Java binary relies on Linux libraries, like libc instead of bionic. not seen anything about running Java under Android except for their dalvik java.
Click to expand...
Click to collapse
Do you mean if I install a buildroot on my device, or pure linux from first (there is no android on my device anymore), then I can use JRE for armv7 and run a jar with GUI?
dr_jacky_2005 said:
Do you mean if I install a buildroot on my device, or pure linux from first (there is no android on my device anymore), then I can use JRE for armv7 and run a jar with GUI?
Click to expand...
Click to collapse
I've not had tons of luck getting Linux to run natively on devices, but if you can do it, yes that should work.
i like enlightenment as gui (e17) for debian on mobile device, if you're going that way.

Gingerbreak exploit file type

All, I need to edit the Gingerbreak exploit for rooting. Whwn I try to open in a text editor i get a bunch of gibbersih. What type of file is the actual exploit? (not the APK)
Thanks
It looks like it is an ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
I'm not an expert, but my guess is that you would need to make the changes to the source code and bake it in.
The code is binary and is compiled with the ARM C compiler. You can take a look at the C source code for gingerbreak here. See 2nd post.
http://forum.xda-developers.com/showthread.php?t=1044765

Categories

Resources