Building BusyBox from source
January 15, 2012 in AOSP
One nice thing to include with an AOSP ROM is BusyBox, which is collection of Unix utilities such as vi, cp, wget, etc… Checkout the BusyBox website for more information. Building BusyBox from source isn’t too hard, and while you could just grab a compiled binary from somewhere else, it’s nice to know how to do yourself so that you can always keep on the most current version.
- Install an ARM cross compiler. Download and install the IA32 GNU/Linux Installer binary from here. In this case, the binary is called arm-2008q1-126-arm-none-linux-gnueabi.bin.
- Make the installer executable: chmod ~/Downloads/arm-2008q1-126-arm-none-linux-gnueabi.bin
- Launch the installer: ~/Downloads/arm-2008q1-126-arm-none-linux-gnueabi.bin
- Accept all of the defaults (though you may want to change the install directory).
- The installer should set the PATH for you, but for me it didn’t do it. You can verify by running “echo $PATH“. If it doesn’t, add it manually.
- Open ~/.bashrc with gedit: gedit ~/.bashrc
- Add the following to the file, adjusting your path as needed: export PATH=$PATH:/home/jon/CodeSourcery/Sourcery_G++_Lite/bin
- Save and exit gedit
- Log out and log back in for that PATH change to take effect
- We need to clone the repository. For this example we’ll use ~/code for our initial location.
- cd ~/code
- git clone git://busybox.net/busybox.git
- Next, we need to checkout the most recent branch. Currently that is 1_19_stable.
- git checkout remotes/origin/1_19_stable
- Now we set up the configuration.
- cd ~/code/busybox
- make menuconfig
- Enable the following setting: BusyBox Settings -> Build Options -> Build BusyBox as a static binary (no shared libs)
- Set the following equal to “arm-none-linux-gnueabi-”: BusyBox Settings -> Build Options -> Cross compiler prefix
- Enable the following setting: BusyBox Settings -> General Configuration -> Don’t use /usr
- Exit and save
- There is currently an issue where BusyBox will fail to compile due to missing mtd header file. Here is a workaround for now:
- cp -r /usr/include/mtd ~/code/busybox/include/
- gedit ~/code/busybox/include/mtd/ubi-user.h
- Below this line “#include <linux/types.h>” add the following lines:
- #ifndef __packed
- #define __packed __attribute__((packed))
- #endif
- Save and exit gedit
- Now, make BusyBox.
- cd ~/code/busybox
- make
There will now be a busybox binary in ~/code/busybox.
References:
- http://busybox.net/source.html
- http://mobisocial.stanford.edu/news/2011/02/compile-busybox-on-android-os/
- https://lkml.org/lkml/2011/6/12/9

















