ls -l on Android device

Tom Spear speeddymon at gmail.com
Tue Jan 26 15:20:46 UTC 2010


> Hi Tom,
>
> Could you put toghether some king of tutorial, or at least the basic
> steps to make BusyBox work on Android? This can be much usefull to
> anyone retracing your steps... (like me :) I plan to get an Android
> Phone soon)
>
> Thanks,
> Alain
>
> Tom Spear escreveu:
>> On Wed, Jan 13, 2010 at 12:15 AM, Tom Spear <speeddymon at gmail.com> wrote:
>>> Ok. I'll try it this weekend. I don't think I'll have time before then
>>> unfortunately. :-(
>>>
>>> Thanks
>>>
>>> Tom
>>
>> I was finally able to get this done. I had to comment the pw_gecos
>> call to get it to compile:
>>
>> [tom at Speeddy testapp]$ agcc -o test test.c
>> test.c: In function 'dump':
>> test.c:15: error: 'struct passwd' has no member named 'pw_gecos'
>>
>> But once I did that, it compiled fine, output is below:
>>
>> [tom at Speeddy testapp]$ adb shell
>> # /system/bin/test 2000 shell
>> pw_name:shell
>> pw_passwd:(null)
>> pw_uid:2000
>> pw_gid:2000
>> pw_dir:/
>> pw_shell:/system/bin/sh
>>
>> pw_name:shell
>> pw_passwd:(null)
>> pw_uid:2000
>> pw_gid:2000
>> pw_dir:/
>> pw_shell:/system/bin/sh
>>
>> # /system/bin/test 0 root
>> pw_name:root
>> pw_passwd:(null)
>> pw_uid:0
>> pw_gid:0
>> pw_dir:/
>> pw_shell:/system/bin/sh
>>
>> pw_name:root
>> pw_passwd:(null)
>> pw_uid:0
>> pw_gid:0
>> pw_dir:/
>> pw_shell:/system/bin/sh
>>
>>
>> It looks like it all works fine, so I am unsure why the calls don't
>> return the name associated with the uid/gid.
>>
>> Thanks
>>
>> Tom
>> _______________________________________________
>> busybox mailing list
>> busybox at busybox.net
>> http://lists.busybox.net/mailman/listinfo/busybox
>>
>>
>

There are a couple of different guides already written, and I'm
writing this from memory as I am not at home, but a quick rundown goes
like this:

First, you need root access (phones sold by carriers don't come with
root by default). You can install busybox in /data/local/bin without
it, but it's highly recommended to get root access for testing it. If
your phone model hasn't been rooted yet, you can use the AOSP project
to build an emulated android phone running in qemu, though I have
never done that so I wouldn't be able to tell you how.

Once you have that, download and install CodeSourcery's ARM toolchain
2009q3 for Linux (the gcc binary will be prefixed with
arm-none-linux-gnueabi- which is how you know you have the right
one).. You will also need to download the Android SDK so you have
access to the Android Debug Bridge which allows shell on the phone via
USB, and you will need to go into the Settings menu, Applications
section, Development subsection, enable USB Debugging.

Install the Android SDK somewhere in your home directory. I like
~/android-sdk personally. Then add /path/to/android-sdk/tools to your
PATH and verify that the codesourcery bin directory is there as well.

After that you'd make defconfig

When you're ready to make, run make like this:
CFLAGS="--static" LDFLAGS="--static" make
CROSS_COMPILE="arm-none-linux-gnueabi-gcc"

Once it is finished making, use the following to get the busybox or
busybox_unstripped binary to the sdcard on the phone:
adb push /path/to/busybox /sdcard

In the above command, /sdcard is literal. That is the literal path to
the sdcard on the phone, so you wouldnt need to substitute anything in
it's place.

Once that is done, you would issue the following commands

adb shell     # to get into the shell on the phone
su     # to get root access
mount      # by itself to find out which mtdblock to use for the next command
mount -o remount,rw -t yaffs2 /dev/block/mtdblock(x) /system
#replace (x) with the mtdblock number for your /system partition, see
previous command
cat /sdcard/busybox >/system/bin/busybox      # use cat because
Android has a crippled mv command that does not allow cross device
moves, and no cp command
busybox sh     # to get into busybox's shell so you don't have to
prefix busybox to every command.

I'd highly recommend not running 'busybox --install' if you copy
busybox to /system/bin because there are symlinks that would be
replaced which should not be replaced (most commands are symlinked to
a binary called toolbox )

That should get you all set. Please CC me dire

Thanks

Tom


More information about the busybox mailing list