A few months ago I proposed a project to port CyanogenMod 9 (Ice Cream Sandwich) to the Huawei U8185. I got the project started by porting ClockworkMod Recovery, and then got CyanogenMod 9 booting not longer after that. I had some good momentum, but I was alone; not exactly what I had in mind when I set out on the project.
Now, months later, a few members of the Nairobi Linux Users Group (LUG) have bought the Huawei U8185 and beefed up their build boxes; it seems we’re finally ready to roll on this project!
Before you can start compiling, booting, and debugging, you have to make sure your computer is set up to build Android. The steps are nearly identical whether you’re building vanilla AOSP Android or CyanogenMod, but differ depending on which GNU/Linux distro your computer is running. The Android website has instructions for most recent versions of Ubuntu, see Initializing a Build Environment. CyanogenMod has similar instructions, which you might want to cross reference if you need help or clarification.
Assuming you’ve initialized your build environment, you should now have the
repo tool installed.
repo is a tool created by Google to manage large git-based projects like AOSP, and it simplifies working with projects containing dozens of sub projects (each with dozens of branches). Also of note, it integrates with Gerrit, Google’s open-source, web-based code review system.
Get the CyanogenMod source
I usually work on several versions of Android (AOSP, CM9, CM10, etc) at a time, so I keep my trees organized under
~/android; I’ll assume the same for this guide. Decide where you want to keep yours, and then create the directories as necessary.
repo to initialize the CyanogenMod 9 project into your directory of choice:
mkdir -p ~/android/CM9 cd ~/android/CM9 repo init -u git://github.com/CyanogenMod/android.git -b ics
This is a very lightweight operation, as it only sets up the current directory with the CyanogenMod manifest and configures your name and e-mail address (only useful if you plan on submitting patches to Gerrit). The CyanogenMod manifest, stored in
~/android/CM9/.repo/manifest.xml, is an XML file which contains a list of all projects, their associated git repositories, as well as where in the source tree they should be stored.
Now you’re ready to pull down the source code. Use the
repo tool again:
This is a big operation, and will take several hours/days to finish depending on your Internet connection. Also, while the CyanogenMod 9 source tree is around 10 gigabytes, you’ll need around two or three times that to actually build anything. So go grab a cup of coffee and start making some free space on your hard drive!
Once that’s done, we have to satisfy a one-time build requirement:
This downloads pre-built binaries which are needed during the compile process (in this case it’s a library for use by the Terminal Emulator application).
Get U8185-specific code
The Android manifest includes dozens of projects in it, but those are essentially just the Android system stuff; we need to tell the build system about our U8185-specific repositories. Because Android runs on many different shapes, sizes, and variations of devices, the common Android system is fairly generic. In order to actually boot on a device, you need to include a device tree and a kernel which are specific to that device.
Put the following in your
~/android/CM9/.repo/local_manifest.xml (create it!):
<?xml version="1.0" encoding="UTF-8"?> <manifest> <project name="alanorth/android_device_huawei_u8185" path="device/huawei/u8185" remote="github" revision="ics" /> <project name="alanorth/android_kernel_huawei_u8815" path="kernel/huawei/u8815" remote="github" revision="ics" /> <project name="alanorth/android_vendor_huawei_u8185" path="vendor/huawei/u8185" remote="github" revision="ics" /> </manifest>
And then sync again:
Of the three U8185-specific repositories in the the local manifest, the kernel is the only one which is of substantial size. All in all, though, it shouldn’t take too long to download.
There’s a long-standing joke about bacon in the CyanogenMod community. I’m not sure where it comes from, but when you
make bacon you are telling the build system to produce an optimized zip file for a given device.
Now set up your build environment, select
cm_u8185-userdebug from the “lunch” menu, and then start the build:
. build/envsetup.sh lunch cm_u8185-userdebug make -j4 bacon
This should take anywhere from 20 minutes (quad-core Core i7, 8+ GB of RAM, fast hard drives) to 2 hours (dual-core Core i5, laptop). If you’ve set everything up ok and nothing went wrong during the build, you’ll see something like this:
Optimizing MediaProvider.apk... Optimizing Provision.apk... Optimizing PhaseBeam.apk... Optimizing Exchange.apk... Optimizing Calendar.apk... Optimizing ApplicationsProvider.apk... MODVERSION: 9-20121014-UNOFFICIAL-u8185 Zipping package... Signing package... Cleaning up... Package complete: /home/aorth/android/CM9/out/target/product/u8185/cm-9-20121014-UNOFFICIAL-u8185.zip 16c1f54779dffb9632e98c507e109900 cm-9-20121014-UNOFFICIAL-u8185.zip
And you can take that
cm-9-20121014-UNOFFICIAL-u8185.zip and flash it in recovery! But this is only where the fun starts; it’s likely that barely anything is working, and you have lots more hacking and recompiling to do. 😉