Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
halfline
Old
#1  
Junior Member - OP
Thanks Meter 0
Posts: 20
Join Date: Jun 2010
Lightbulb Getting a wider set of development tools on the phone

So, I've been playing around with QuickSSHd and one thing I noticed is there aren't many tools available in the shell. I put an arm build of Fedora on the phone, and now I have access to strace, gdb, gcc, etc..

I figured I'd post my steps here in case anyone else is interested.

1) First thing I did was root the phone with the Unrevoked app.
2) Then I bought a 16 gb microsd card so I wouldn't have to split the 8gb card that came with the phone
3) I partitioned the new card on my linux box using fdisk. I did two partitions, the first a FAT partition and the second a linux one. It was something like:

# fdisk /dev/sdb
d 1
n
p
1
t
c
n
p
2
w

# /sbin/mkfs.vfat /dev/sdb1
# /sbin/mkfs.ext3 /dev/sdb2

4) One that was done, i mounted the ext3 partition and grabbed this prebuilt fedora chroot tarball:

ftp.linux.org.uk/pub/linux/arm/fedora/rootfs/rootfs-f12.tar.bz2

and untarred it into a directory i called "fedora" on the ext3 partition.

5) I then turned off my phone, pulled out the battery and swapped the existing sdcard with my newly formatted one, put the phone back together and booted it up. It took a long time to boot after this and in the notification panel it said it was "preparing the sdcard"

6) Then i started QuickSSHd back up and ssh'd to the machine as root
7) next i ran "busybox sh" to get a better shell than whatever was started before
8) then I created a shell script called f12.sh that looked like this:

--8<----------
#!/bin/sh
cd $HOME
mkdir -p mnt/fedora
mkdir -p dev
ln -sf /dev/block/vold/179\:2 dev/sdcard2
grep -q dev/sdcard2 /proc/mounts || mount dev/sdcard2 mnt/fedora
grep -q rootfs-f12/dev /proc/mounts || mount --bind /dev mnt/fedora/rootfs-f12/dev
grep -q rootfs-f12/sys /proc/mounts || mount --bind /sys mnt/fedora/rootfs-f12/sys
grep -q rootfs-f12/proc /proc/mounts || mount --bind /proc mnt/fedora/rootfs-f12/proc
grep -q rootfs-f12/tmp /proc/mounts || mount -ttmpfs tmpfs mnt/fedora/rootfs-f12/tmp

mkdir -p mnt/fedora/rootfs-f12/mnt/system
mkdir -p mnt/fedora/rootfs-f12/mnt/data
grep -q rootfs-f12/mnt/system /proc/mounts || mount --bind /system mnt/fedora/rootfs-f12/mnt/system
grep -q rootfs-f12/mnt/data /proc/mounts || mount --bind /system mnt/fedora/rootfs-f12/mnt/data

mkdir -p mnt/fedora/rootfs-f12/debug
grep -q rootfs-f12/debug /proc/mounts || mount -tdebugfs debugfs mnt/fedora/rootfs-f12/debug
export LD_LIBRARY_PATH=`pwd`/mnt/fedora/rootfs-f12/lib:`pwd`/mnt/fedora/rootfs-f12/usr/lib
export HOME=/root

cd mnt/fedora/rootfs-f12
lib/ld-linux.so.3 usr/sbin/chroot . bin/bash --login
------>8---------------------

I used vi for this, you could use cat > f12.sh instead.

One weird part of this is the /dev/block/vold/179\:2 symlink. The busybox version of mount apparently can't grok source devices with colons in them. The symlink is just to rename it to something that mount can understand. I imagine the 179 part varies from system to system.

9) Then i ran sh f12.sh which put me in a fedora chroot.
10) I notice the rpm database is a little screwy in the chroot so I ran
# rm -f /var/lib/rpm/__db*
# rpm --rebuilddb
11) At this point I could yum:

# yum -y install strace gdb screen gcc vim-enhanced powertop

Some useful things:

- The kernel debug filesystem is in /debug
- Parts of the phone OS are available in /mnt/data and /mnt/system
 
halfline
Old
#2  
Junior Member - OP
Thanks Meter 0
Posts: 20
Join Date: Jun 2010
Attached is an updated f12.sh (minor tweaks made as I've noticed issues come up)
Attached Files
File Type: txt f12.sh.txt - [Click for QR Code] (1.4 KB, 4 views)
 
joeykrim
Old
#3  
Recognized Developer
Thanks Meter 1083
Posts: 1,853
Join Date: Jan 2009
wow, this is quite interesting!
i might venture into giving this a try.

two pieces of information, only as an FYI, i make no claim to whether or not these are better than the method you provide, only an alternate method which might or might not be better. perhaps a combination of methods would be best? i'll leave it up to the end user to decide.

1) some of those binaries you mention, like strace are already provided by the userdebug PC36IMG.zip (root part 1) in system/xbin from HTC. if anybody wants these binaries, they can be extracted from the system.img inside of the .zip file using unyaffs. if requested, i can post.
2) android open source project, which contains all the source files for android, provides dropbear has a compact arm compiled ssh client.

thanks for taking the time to test all this out and posting up the detailed step by step along with your .sh file!!!
 
Post Reply+
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Go to top of page...