Android – Understanding, Modifying, Building and Installing

Once we have understood how our device boots up, we will then cover the technical aspects of how to flash our device. As in the boot sequence, the 3 main components that need to be transferred -”flashed”- to the board, are: The Bootloader, the Kernel and the OS (Android). We cover them in different posts, continuing here with the OS – Android.

Once the boot loader has loaded the kernel, the following step is mounting the root file system (Please refer here for further details on the boot sequence). In this post we will go through the process of compiling the Android system and uploading it image to our device. Sometimes, this image needs to be modified. Refer to this post in order to get more information on how to mount/unmount the Android system image.

Once again, this tutorial will be centered on a specific board, the ODROID-PC from hardkernel and therefore some of the information provided here is based from their documentation. Please note that porting this tutorial to another board should be straightforward for most cases, and at least should give a very good idea of what has to be done.

The ODROID-PC uses a Samsung processor, a Exynos 4 – ARM Cortex9. As it is the case in many other processors, some of the libraries needed to interact with it, are proprietary and therefore cannot be distributed. However, the binaries can be re-used when modifying the software in a board we have paid for. For this, we need to remember to recover those libraries from our board and located in the source code of our system so that they are compiled into the system image we will flash in our device afterwards. The libraries that have to be saved change from company to company and from device to device. Here we will state the libraries we had to extract from our specific board (we will also mention the libraries for the ODROID-A4, since most of them, are common libraries). For extracting files from our device we will make use of adb pull, which will transfer the libraries from our device to our host machine through a USB interface.

In our case, the Exynos 4210 we have as a processor, implements a variant of the Mali GPU, which is an ARM proprietary Graphic Processing Unit (GPU).  The Mali library is mainly a component that allows a given application to communicate with the mali kernel object (mali.ko) and use the Mali GPU. The Mali library is actually composed several shared libraries (.so extension) that work together, and we will need to extract them all.

To extract Samsung’s Mali shared libraries:

  • Connect usb cable from device to host computer
  • adb root
  • adb remount
  • adb pull /system/lib/ /device/samsung/exynos4/lib/mali_ump/
  • adb pull /system/lib/ /device/samsung/exynos4/lib/mali_ump/
  • adb pull /system/lib/ /device/samsung/exynos4/lib/mali_ump/
  • adb pull /system/lib/ /device/samsung/exynos4/lib/mali_ump/
  • adb pull /system/lib/ /device/samsung/exynos4/lib/mali_ump/
  • adb pull /system/lib/ /device/samsung/exynos4/lib/mali_ump/

We change access permissions to the shared libraries:

  • chmod -R 755 device/samsung/exynos4/lib/mali_ump/*

We need to extract the Open Source Mali GPUs Android Gralloc Module(libgralloc) and change access permissions: (Notice that here odroidpc refers to our specific board and this name will be different in other boards)

  • adb pull /system/lib/hw/ /device/samsung/exynos4/libgralloc_ump/
  • chmod -R 755 device/samsung/exynos4/libgralloc_ump/*

Now we extract specific sensor shared libraries of our board (if applicable). The ODROID-PC does not need this sensor libraries, however other boards or devices might do (e.g. the ODROID-A4). It is difficult to tell which of this shared libraries are needed without proper documentation from the fabricant. We will provide the commands to extract the necessary sensor shared libraries for the ODROID-A4 as an example of which of this libraries might be necessary:

  • adb pull /system/lib/hw/ vendor/invensense
  • adb pull /system/lib/ vendor/invensense
  • adb pull /system/lib/ vendor/invensense
  • adb pull /system/lib/ vendor/invensense
  • adb pull /system/lib/ vendor/invensense
  • adb pull /system/lib/ vendor/invensense

And change the permissions:

  • chmod -R 755 vendor/invensense/*

Once we have extracted all the proprietary shared libraries that we need to compile our Android, we just need to build the system and flash it. To build Android, first we need to initialize the environment with the script:

  • source build/

Then, we need to choose a target platform (e.g. full_maguro targets Galaxy Nexus and -eng stands for development configuration with additional debugging tools):

  • lunch full_maguro -eng

Finally…make! 🙂

  • make -jN (depending on our machine -number of CPUs, cores and threads) N can go from 4 to 32)

Once Android is compiled, we just need to flash it:

  • adb reboot bootloader
  • fastboot flash ramdisk out/target/product/$PLATFORM/ramdisk-uboot.img
  • fastboot flash system out/target/product/$PLATFORM/system.img
  • fastboot reboot

The boot sequence should start, load the kernel, the root file system and finally… Android! 🙂

For further information visit: