How to build CyanogenMod (for 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.
- A local Linux machine (interface).
- A poweful remote Linux machine with a fast connection (builder).
- An already rooted u8150 device with a micro USB cable.
- ClockworkMod Recovery.
- Debian 7 (or Ubuntu Server) x86_64 (remote VPS), +2G RAM.
- Fedora 18 x86_64 (local machine).
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 root # cat /etc/apt/sources.list deb http://ftp.us.debian.org/debian wheezy main deb http://security.debian.org/ wheezy/updates main # apt-get update # apt-get upgrade
Install required files and libraries, you’ll need them later.
# whoami root # 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 builder % mkdir ~/bin % wget https://dl-ssl.google.com/dl/googlesource/git-repo/repo -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 user.email "[email protected]" % git config --global user.name "[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://github.com/CyanogenMod/android.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://github.com/CyanogenMod/android_device_huawei_u8150.git u8150
cd into the
u8150 directory, you’ll notice a
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 AABBCCDDEEFF device % cd ~/tmp % wget http://reventlov.com/tutorials/portable-hacking/extract-files.local.sh % chmod +x ./extract-files.local.sh % ./extract-files.local.sh ... 400 KB/s (37856 bytes in 0.092s)
You’ll end up with a single
u8150 directory, upload it to
on the remote end.
% ls u8150 propietary % scp -r u8150 [email protected]:/home/builder/projects/android/cyanogenmod/vendor/huawei/
And then use the
extract-files.remote.sh script to completely setting up the
% cd ~/projects/android/cyanogenmod/device/huawei/u8150 % wget http://reventlov.com/tutorials/portable-hacking/extract-files.remote.sh % ./extract-files.remote.sh
Let’s continue sourcing
envsetup.sh, this will allow us to call
% cd ~/projects/android/cyanogenmod % source build/envsetup.sh ... device/huawei/u8150/vendorsetup.sh ...
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/cm-7-20130622-UNOFFICIAL-u8150.zip e93e629f58a3dc3d52e1ea53d8d084f6 cm-7-20130622-UNOFFICIAL-u8150.zip
At the end you’ll get a
cm-7-YYYYMMDD-UNOFFICIAL-u8150.zip file, download it
to your local machine and push it to the sdcard:
% cd ~/tmp % scp [email protected]:[email protected]50/cm-7-20130622-UNOFFICIAL-u8150.zip . % adb push cm-7-20130622-UNOFFICIAL-u8150.zip /sdcard/update.zip
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
update.zip file you’ve just copied to the sdcard.
Now allow the phone some minutes to respawn…
And cool, you did it!
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