How to build CyanogenMod (for Huawei IDEOS u8150)


CyanogenMod on Huawei IDEOS u8150

This is the first chapter of a series of four on how to use a cheap Android device (an old smart phone) as a portable hacking device.

By the end of the four chapters you’ll be able to carry a fully functional and unrestricted Linux machine powered by a battery… in your pocket!

We’ll start covering the Huawei IDEOS u8150 phone and we’ll end up featuring the HTC Wildfire S, two of the most affordable Android devices in the market, if you don’t have any of these devices keep reading, it may be not so difficult to adapt this tutorial to your specific device.


The first chapter is about how to avoid using a probably trojanized image in our phones by building CyanogenMod by ourselves, because you don’t want to get hacked, right? and you are paranoid, aren’t you?

The second chapter will cover how to compile and install a custom Linux kernel and make it boot in your phone, sometimes you’ll need to get your hands dirty and compile stuff that is not available with the default kernel.

The third chapter will cover cross-compilation and how to use a whole Linux distro on top of your Android phone.

And the final chapter will cover some use cases of our portable machine in the wild, let’s get creative!

Through this chapter you’ll be downloading a huge amount of data and will be using a lot of computing power, so I suggest you using a proper building machine with a fast Internet connection unless you want to wait lots of time, it does not have to be your local machine, I, in fact, used a VPS for a couple hours instead of my personal machine.

Note: This tutorial assumes that you’ve already rooted your phone and that you’ve installed CyanogenMod previously, at least once, if you haven’t done it yet that’s fine and you can keep on reading the tutorial until the end, but you’ll have to do it anyway if you actually want to install the system snapshot we’ll be building.

Build requisites

Build environment

Local setup

In order to communicate with the phone you’ll need to install the android development tools on your local machine:

# yum install -y android-tools.x86_64

Remember to put your phone in USB debugging mode as well.

Remote build machine

This is a fresh Debian 7 (wheezy) install, be sure that it is up to date:

# whoami
# cat /etc/apt/sources.list
deb wheezy main
deb wheezy/updates main
# apt-get update
# apt-get upgrade

Install required files and libraries, you’ll need them later.

# whoami
# apt-get install build-essential bison schedtool flex zip gperf pngcrush
# apt-get install gcc-multilib g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline-gplv2-dev
# apt-get install openjdk-6-jre openjdk-6-jdk
# apt-get install git

You’ll need this symlink too, if it is not there already.

# ln -s /usr/bin/python2.7 /usr/bin/python2

Now, as a normal user, get the repo tool.

% whoami
% mkdir ~/bin
% wget -O ~/bin/repo
% chmod +x ~/bin/repo
% export PATH=$HOME/bin:$PATH

And if you haven’t done it before, configure your git credentials:

% git config --global "[email protected]"
% git config --global "[email protected]"

Getting our hands dirty

It’s time to use repo and download the gingerbread branch of CyanogenMod, it will take some time.

% mkdir -p ~/projects/android/cyanogenmod
% cd ~/projects/android/cyanogenmod
% repo init -u git:// -b gingerbread
repo has been initialized in /home/builder/projects/android/cyanogenmod
% repo sync
Syncing work tree: 100% (315/315), done.

Now, get the configuration files for u8150.

% mkdir -p device/huawei/
% cd device/huawei/
% git clone git:// u8150

cd into the u8150 directory, you’ll notice a script, this script assumes that the building machine is also connected to the phone, that’s not the case with this tutorial, so we need to modify it a bit and split it into two separate scripts.

Connect the phone to your local machine, make sure adb devices recognizes it and pull the binary blobs:

% adb devices
List of devices attached
% cd ~/tmp
% wget
% chmod +x ./
% ./
400 KB/s (37856 bytes in 0.092s)

You’ll end up with a single u8150 directory, upload it to vendor/huawei on the remote end.

% ls u8150
% scp -r u8150 [email protected]:/home/builder/projects/android/cyanogenmod/vendor/huawei/

And then use the script to completely setting up the configuration files.

% cd ~/projects/android/cyanogenmod/device/huawei/u8150
% wget
% ./

Let’s continue sourcing, this will allow us to call lunch and brunch.

% cd ~/projects/android/cyanogenmod
% source build/

Execute lunch, it will show you some options, you can make your selection with a name or a number.

% lunch
6. generic_u8150-eng

After choosing the u8150 option, call brunch and wait.

If everything works as expected you’ll end up with a zip file containing your build, if someting fails you’ll probably need to download extra libraries or packages and try again.

% brunch u8150
Package complete: /home/builder/projects/android/cyanogenmod/out/target/product/u8150/

At the end you’ll get a file, download it to your local machine and push it to the sdcard:

% cd ~/tmp
% scp [email protected]:[email protected]50/ .
% adb push /sdcard/

Power off the phone and press power + volume up + green button at the same time to reboot in recovery mode, clean cache, apply factory reset and finally load the file you’ve just copied to the sdcard.

Now allow the phone some minutes to respawn…

And cool, you did it!

We did it

Now what?

On the next tutorial we’ll cover how to compile a custom kernel and make it boot in our device, I had to do this in order to use some special rules for iptables.

Sources and recommended reading