Compiling CyanogenMod 9

I initally added instructions here for compiling ColdFusionX as I was helping to maintain the project. Now that it looks like we’ll get an official CM9 for ZTE Blade, its been deprecated, so here’s the CM9 build instructions. It takes about 50mins to compile (including kernel) which is only about 10mins more than CM7+kernel would have taken on my 12Gb RAM, 3.2GHz Intel Core i5 Linux box with SSD.

1. Download CM9 (use repo sync to update) this is about 15Gb worth:

mkdir -p ~/cm9/vendor/zte/blade
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo
cd ~/cm9
repo init -u git://github.com/CyanogenMod/android.git -b ics

2. Download ZTE proprietary libs (use git pull to update) and copy into place. you’ll probably only have to do this once as they don’t get updated often:

cd
git clone https://github.com/koush/proprietary_vendor_zte.git -b ics
rsync -av --delete ~/proprietary_vendor_zte/blade/ ~/cm9/vendor/zte/blade/ --exclude='.git*'

3. Compile the rom – the first time you do this it will download the kernel source (you can add CM_EXTRAVERSION=-whatever on the end of the export line):

cd ~/cm9/vendor/cm/
./get-prebuilts
cd ~/cm9/
export USE_CCACHE=1 CM_SNAPSHOT=1
. build/envsetup.sh
lunch cm_blade-userdebug
make bacon -j8

Edify Scripting And Git Patches

I’ve been working on Edify scripting to create a flashable zip that allows me to patch a regular CM7 nightly build with a reverted libaudio.so and updated libcamera.so

There’s literally no documentation anywhere! There’s some very old posts about Amend scripts (update-script) on XDA but nothing about the newer Edify scripts (updater-script and update-binary) that CM7 uses.

My script is based on the script from gapps:

ui_print("Mounting /system");
run_program("/sbin/busybox", "mount", "/system");

ui_print("Extracting libraries");
show_progress(0.100000, 0);
package_extract_file("libcamera.so", "/system/lib/libcamera.so");
package_extract_file("libaudio.so", "/system/lib/libaudio.so");
show_progress(0.100000, 10);

ui_print("Setting permissions");
show_progress(0.200000, 0);
set_perm(0, 0, 0644, "/system/lib/libcamera.so");
set_perm(0, 0, 0644, "/system/lib/libaudio.so");
show_progress(0.200000, 10);

run_program("/sbin/busybox", "umount", "/system");
ui_print("Installation complete!");

There’s not a huge amount of documentation about the folder structure of a zip or apk, but essentially its this:

libaudio.so
libcamera.so
META-INF/com/google/android/
   updater-script
   update-binary

You have to take update-binary from another zip file, such as a the CM7 zip itself.

There’s also very little documentation about signing zips. I found that the command to do that is:

java -jar signapk.jar testkey.x509.pem testkey.pk8 update.zip update-signed.zip

signapk.jar can be found in the out/host/linux-x86/framework/ directory of a compiled build and the AOSP signing keys can be found in the build/target/product/security/ directory of the Android source tree.

To make a patch to revert libaudio I had to diff against the version before HEAD for that whole directory – we have to do it this way as the previous commit is different for AudioHardware to AudioPolicyManager – this is “get the previous commit, whatever that may be”, not “get this specific commit for this specific file”:

cd device/zte/blade/libaudio/
git diff HEAD^ > ~/libaudio.patch

Then I can apply the patch to HEAD (optionally check for errors first):

git apply --check ~/libaudio.patch

No we have a patch to revert to a previous version, kind of the opposite of what patches are usually for!

I’ve created a new directory on my server for all the CM7 stuff like patches and KANG builds here, which includes this signed zip patch.

Self-built CM7

I got fed up of waiting for the Cyanogenmod team to merge in the broken slidey keyboard revert so decided to take the plunge and install my own build on my Orange San Francisco smartphone. I did a “repo sync” and checked out the revert from Git then compiled what was essentially a nightly build of CM 7.1.0 RC0 between N71 and N72.

I installed it on my phone and put it up on my server for download, and posted to the MoDaCo forum, and now about 18 hours later I’ve had 222 downloads using a whopping 21Gb of bandwidth – I’m so glad that only works out as about 2% of my monthly allowance and we’re halfway through the month!

I’ve been running it on my phone for those 18 hours and haven’t seen any issues – the libaudio.so and new sensor libs were merged in before N71 and the screen orientation revert I merged in meant that the screen wasn’t stuck in landscape mode.

The only problem I can still see is that the dialler is using sensors all the time and stops the phone going into standby properly, so eats the battery after you’ve made/received a phonecall – intermittently. If they can fix that, then I reckon CM7.1 is ready to go RC1.

Cyanogenmod 7.1.0 nightly 59

Cyanogenmod 7.1.0 nightly 59 with Android 2.3.4 (GRJ22) is available for download. I installed it on my ZTE Blade and it doesn’t seem any better or worse than CM7.0.2 N57, of course this isn’t even 7.1 RC1 yet, its RC0.

I think the main focus of 2.3.4 was on video performance which probably won’t have much of an effect on the lowly Blade which can’t even run Flash.

I’ve also been playing with K4MobiDeDRM_v02.8_plugin.zip which is a Calibre plugin to strip the DRM crap from Amazon ebooks so that your ebooks are not tied solely to your Kindle3G, and can be opened on Linux or a non-Kindle ereader application on your Android/Mac for instance.

Plain old mobidedrm.py 0.29 no longer seems to work since the 2.5 firmware, but the K4 tools add some functionality to it and now you don’t even need a PID, just your Kindle serial number.

Update 1: Nightly 60 is out, I installed it and it seems ok now (after several reboots for some reason). Apparently 7.0.3 stable is coming soon, then development can concentrate on 7.1.0 RC1.

Update 2: Nightly 62 is out as is stable 7.0.3, here’s hoping for kernel 2.6.35 in N63…..

Update 3: Just installed Nightly 63 and its still 2.6.32 albeit with some fixes in it for battery life, I/O performance and touchscreen. There does seem to be a slight hissing after using the loudspeaker, confirmed on the issue tracker.

I also installed new gapps-gb-20110503-signed.zip which provides slightly updated Google Apps like Talk with video chat for 2.3.4

Update 4: Nightly 64 is out with some new music player features. Apparently the hissing from the loudspeaker was introduced when a new /system/lib/libaudio.so was merged in to fix some VOIP issues, sometime after moving to Gen2-only. I tried the patch on N64 but it seems to mute the speaker altogether rather than just stop the hissing!

Cyanogenmod 7.0.2 nightly 57

Well I finally bit the bullet and installed CM7 on my ZTE Blade (Orange San Francisco) as well as upgrading from the Gen1 radio to Gen2.

The install all went quite well using the TPT image-and-upgrade method.

Disappointingly my downloaded apps didn’t all reinstall automatically, so spent a while on the Market re-sending them to the phone. Also the paid-for LauncherPro+ didn’t automatically unlock itself, however ROMManager did.

I forgot to backup my SMS’s, but I found that you can unzip your nandroid backup’s data.img using unyaffs and use sqliteman or sqlite3 to open the SMS or contacts databases:

data/com.android.providers.telephony/databasesmmssms.db
data/com.android.providers.contacts/databases/contacts2.db

ClockworkMod Recovery 3.0.2.7 now works (doing a nandroid as I write this).

iGo 8.4.2 works fine. I don’t seem to have the charger reboot or GPS issues, although Google Maps caused the phone to reboot the first time.

Update: OK so the phone rebooted once when I yanked the USB cable – but I was overclocked to 710MHz from 604MHz stock at the time!

I’ve extracted the proprietary files from the phone into my cyanogenmod repo and have now compiled my own CM7 for the Blade. Nfc doesn’t seem to cause a problem for a Blade build like it does for the emulator.

Also it seems the platform version is 2.3.4 and the resulting zip is called update-cm-7.1.0-RC0-Blade-KANG-signed.zip, so major upgrades are afoot it seems….