Compiling CyanogenMod 9 for the Huawei U8185

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!

Preparation

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.

Use 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:

repo sync

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:

./vendor/cm/get-prebuilts

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:

repo sync

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.

Making bacon

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. 😉

34 thoughts on “Compiling CyanogenMod 9 for the Huawei U8185

  1. Alan

    en verdad te agradesco, y tambien entiendo que es mejor enseñar a las personas a trabajar que brindarles todo en bandeja de plata, se el trabajo que has hecho y quisiera haber colaborado, pero unicamente soy un entusiasta de la computacion, pienso que seria mas comodo pedirte que subas la rom del cyano para probarla, pero voy a morir en el intento, así voy a desinstalar mageia 2 e instalar ubuntu y seguir las instruciones del tutorial (a ver cuando se tarda mi athlon X2) pd. escribo en español por que mi ingles es muy malo y no quiero errar en lo que quiero decirte, nuevamente recive mi admiracion y agradecimiento, ademas de un saludo desde xochimilco, mexico,

  2. tengo el siguiente error

    Can't locate Digest/MD5.pm in @INC (@INC contains: external/webkit/Source/WebCore/bindings/scripts /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at external/webkit/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm line 29.
    BEGIN failed--compilation aborted at external/webkit/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm line 29.
    Compilation failed in require at external/webkit/Source/WebCore/bindings/scripts/CodeGenerator.pm line 130.
    Can't locate Digest/MD5.pm in @INC (@INC contains: external/webkit/Source/WebCore/bindings/scripts /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at external/webkit/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm line 29.
    BEGIN failed--compilation aborted at external/webkit/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm line 29.
    Compilation failed in require at external/webkit/Source/WebCore/bindings/scripts/CodeGenerator.pm line 130.
    make: *** [out/target/product/u8185/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/bindings/V8CSSCharsetRule.h] Error 2
    make: *** Se espera a que terminen otras tareas....
    make: *** [out/target/product/u8185/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/bindings/V8CSSFontFaceRule.h] Error 2
    Can't locate Digest/MD5.pm in @INC (@INC contains: external/webkit/Source/WebCore/bindings/scripts /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at external/webkit/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm line 29.
    BEGIN failed--compilation aborted at external/webkit/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm line 29.
    Compilation failed in require at external/webkit/Source/WebCore/bindings/scripts/CodeGenerator.pm line 130.
    make: *** [out/target/product/u8185/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/bindings/V8CSSImportRule.h] Error 2
    1. Hmm, it looks like you’re missing some perl modules (Digest/MD5). If you’re on Ubuntu, try installing libdigest-md5-file-perl

  3. Hi Alan, I really love your work… Which linux distribution are you using and I would really appreciate your help in my current project on android Kernels. Thanx

      1. When compiling the ICS kernel, I keep getting this error:

        drivers/media/video/msm/msm_camera.c: In function 'msm_camera_drv_start':
        drivers/media/video/msm/msm_camera.c:4182: error: 'camera_num' undeclared (first use in this function)
        drivers/media/video/msm/msm_camera.c:4182: error: (Each undeclared identifier is reported only once
        drivers/media/video/msm/msm_camera.c:4182: error: for each function it appears in.)
        drivers/media/video/msm/msm_camera.c:4192: error: 'camera_node_succee' undeclared (first use in this function)
        make[4]: *** [drivers/media/video/msm/msm_camera.o] Error 1
        make[3]: *** [drivers/media/video/msm] Error 2
        make[2]: *** [drivers/media/video] Error 2
        make[1]: *** [drivers/media] Error 2
  4. Ok with a bit of help, I got it building on debian sid!

    aptitude install bison flex g++-multilib gcc-multilib gperf lib32ncurses5-dev lib32z1-dev libc6-dev-i386 libx11-dev mesa-common-dev pngcrush

    did it!

  5. BTW it boots, but I get stuck with an alert at that point:

    E/AndroidRuntime( 2227): FATAL EXCEPTION: main
    E/AndroidRuntime( 2227): java.lang.RuntimeException: Unable to create application com.android.phone.PhoneApp: java.lang.RuntimeException: java.lang.ClassNotFoundException: com.android.internal.telephony.HuaweiQualcommRIL

    (many times over and over) — it’s possible you haven’t pushed that bit to git??

  6. Hi,
    great project. got my u8185 over dec, I’m getting cyanogen source at the moment.
    for us n00bs out here it would help to specify that the local_manifest file has a .xml extension.
    Thanks.

  7. everything goes smoothly till i get this error….please help
    Note: Some input files use or override a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.

    1. Hmm, that’s not the problem. If you were making with multiple parallel threads the error could be mixed with output from other threads. Try searching your terminal history for “Error”. Otherwise, you could simply build with less threads, ie: make -j1 bacon

      1. I have done that…but still the following occurs
        target Java: framework (out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes)
        Note: Some input files use or override a deprecated API.
        Note: Recompile with -Xlint:deprecation for details.
        Note: Some input files use unchecked or unsafe operations.
        Note: Recompile with -Xlint:unchecked for details.
        Copying: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes-jarjar.jar
        Copying: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/emma_out/lib/classes-jarjar.jar
        Copying: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar
        Copying: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/noproguard.classes.jar
        target Dex: framework

        It just remains there…. for like two hours now…no error,no anything…I displayed the properties of the out folder and the size kept increasing for about 45 minutes then it stopped and it’s been like that for more than two hours… I’m not sure if it’s an error or I should just wait….

        1. I love Java! Memory, nom nom nom. Check dmesg to see if there are any processes being killed, you might be out of RAM or something. Maybe you’re swapping to death.

          Maybe try to do this before you compile: sudo echo never > /sys/kernel/mm/transparent_hugepage/defrag. Turning off huge pages makes some disk-heavy workloads work better… not sure on the internals of it, but yeah.

        2. Thanks Alan…maybe it’s happening because I’m compiling on a virtual machine…I’ll install a clean copy of Ubuntu once school closes for an unfortunate two weeks…thanks btw!

  8. Alan, no se si leerá esto pero, Enserio le agradeciere que terminara esta Rom para Nuestro dispositivo
    Por favor, no lo abandone. Gracias.

  9. Hey Allan!? School has finally closed and I was able to successfully compile the cm9…been trying to fix the calling issue above all other minor stuff with no success… but not to worry, since I’ll be going on attachment this coming semester I’ll have time on my hands….I just wanted to inform you that i got CM7.2 working on this device!! I tried porting Roms from the U8150 upwards and finally settled on the U8655(y200)…Everything works amazingly well! even the camera!! down side is that the Bluetooth and WIFI don’t work…(which i can live without)…i got the Rom from this site http://www.myhuawei.net/Thread-ROM-CyanogenMod-7-2-Unofficial-U8655 . I followed the flashing instructions as stated in that site… works with both CWM 5…. and 6…. I just thought i should give you a heads up and see if you can make it a Rom for daily use on the U8185.

    1. Hah! Wow. I bet CM7.2 on that thing is much smoother than CM9. Although, CM10 was really nice to be honest, only that the backlight didn’t turn off when the screen turned off, so the screen was white. Otherwise CM10 was fucking fast and slick!

      Good work. You should try to find the U8655’s source tree and port it to U8185. Source is always better than binary porting!

  10. I get you man …. but I have been trying to contact the developer to no avail … I guess it’s coz he’s Russian?? well dunno …but I’ll continue trying… could you please try as well(if you find time)? maybe you’ll have better luck … cm10!? I haven’t had the chance to test it!! do you have a copy of it somewhere online? if not can you please give me the Repo for your device tree for the cm10…?

  11. Hello alan you can say to me since I do to compile cm – 10.1
    try it but it gave to me this mistake.
    Notice file: external/strace/NOTICE -/home/doki/android/system/out/target/product/u8185/obj/NOTICE_FILES/src // system/xbin/strace.txt make: *** Not bum to make target `vendor/cm/prebuilt/common/bin/modelid_cfg.sh ‘, needed by `/home/doki/android/system/out/target/product/u8185/system/bin/modelid_cfg.sh ‘. Stop sign. Make: *** Waiting for unfinished jobs….

  12. hey alan I have problems on having compiled cm10

    external/e2fsprogs/e2fsck/problem.c:1280:4: warning: missing initializer [-Wmissing-field-initializers]
    external/e2fsprogs/e2fsck/problem.c:1280:4: warning: (near initialization for ‘problem_table[229].second_code’) [-Wmissing-field-initializers]
    external/e2fsprogs/e2fsck/problem.c:1285:4: warning: missing initializer [-Wmissing-field-initializers]
    external/e2fsprogs/e2fsck/problem.c:1285:4: warning: (near initialization for ‘problem_table[230].second_code’) [-Wmissing-field-initializers]
    external/e2fsprogs/e2fsck/problem.c:1290:4: warning: missing initializer [-Wmissing-field-

    And it gives me this result

    host Executable: test_list_host (/home/doki/android/system/out/host/linux-x86/obj/EXECUTABLES/test_list_host_intermediates/test_list_host)
    host Executable: test_memory_host (/home/doki/android/system/out/host/linux-x86/obj/EXECUTABLES/test_memory_host_intermediates/test_memory_host)
    host Executable: test_set_host (/home/doki/android/system/out/host/linux-x86/obj/EXECUTABLES/test_set_host_intermediates/test_set_host)
    make[1]: *** [sub-make] Error 2
    make[1]: Leaving directory `/home/doki/android/system/kernel/huawei/u8815′
    make: *** [TARGET_KERNEL_BINARIES] Error 2
    make: *** Waiting for unfinished jobs….

  13. Hey, I’ve successfully built both cm9 and 10… they work fine, although cm9 has some issues with the Ril (Hoping to fix that soon)… I also visited your device manifest for the u8150 and saw that you have also added a gingerbread manifest… I have only one question, when doing ./extract-files (which I saw was a python executable so the .sh did not apply) do I pull from a device running stock 2.3.6 Safaricom firmware or the one i ported from the u8655…?

  14. hey Allan it’s me again … I have come arround to modifying your gingerbread device tree to build cm7 … I finally got it booting and everything (bootanimatoon and all that) …. problem is … it doesn’t go past that …. it just keeps going then shows a white screen (for a split second) then goes to the start of the boot animation …. could you PLEASE help me out ..thanks in advance

  15. Hey Allan….it’s me again….sorry for bbeing a bother…but today i’ve finnaly got to use it… seems there was an issue with the prebuilt kernel you provided… i flashed your cm9 boot image through and it worked!!! the only thing working is ril(sim card reads well and calling ), touchscreen…other than that nothing else works…graphics are a bit glitchy, sdcard, wifi, bluetooth..that bunch of stuff that gives developers hell!…. i’m downloading the source kernel to see if i can make it work…PEACE!

  16. Sorry again… but seems your prebuilt kernel was just fine…problem is the init.rc script from cm7!… i pointed the tree to the one fro your ics boot image and it works!!!…
    PS:SDCARD NOW WORKS!

Comments are closed.