Tuesday, August 30, 2011

install busybox from source on Samsung GT-I9100

If you want a complete set of unix tools in your phone, here are the steps to cross-compile and install busybox from source (there's no need to root the phone and/or install everything using the busybox installer from the market).

Download the latest ARM gnueabi toolchain from codesourcery.

Get the busybox source code from the git repository:
  $ git clone git://busybox.net/busybox.git

Copy my busybox config file (or use your own config if you prefer, this can be just a starting point):

$ cd busybox
$ wget -O .config http://www.develer.com/~arighi/android/busybox/config

[optional] Change the busybox config if you want by running:
$ make menuconfig

Cross-compile busybox:
$ make oldconfig && make

At the end of the build the busybox binary should be available as a statically linked ELF for ARM:
$ file busybox
busybox: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.16, stripped

Upload the busybox binary to the device (you don't need root access to your phone):
$ adb push busybox /data/local/tmp/

Now busybox it's ready to be used:
$ adb shell /data/local/tmp/busybox CMD

Example:
$ adb shell /data/local/tmp/busybox lsusb
Bus 001 Device 001: ID 1d6b:0002
Bus 001 Device 002: ID 1519:0020

=== NOTE: all the following steps are optional ===

If you have enabled the adb root shell access to your phone (i.e., by rooting the phone or by installing my custom kernel), you can also install busybox in the /system partition and have all the commands available in the $PATH.

Remount the /system partition in read-write mode on your phone:
$ adb shell "mount -oremount,rw /dev/block/mmcblk0p9 /system

Upload the busybox binary to the /system partition:
$ adb push busybox /system/xbin/busybox

Install busybox by using busybox itself:
$ adb shell "chmod 755 /system/xbin/busybox"
$ adb shell "/system/xbin/busybox --install -s /system/xbin"

Remount /system in read-only:
$ adb shell "mount -oremount,ro /dev/block/mmcblk0p9 /system"

Now all the busybox applets are in your $PATH:

$ adb shell lsusb
Bus 001 Device 001: ID 1d6b:0002
Bus 001 Device 002: ID 1519:0020

No comments:

Post a Comment