When Android Fails

I really have myself to blame.  Android is the right smart phone platform for me: provided you have a rooted phone, you can get inside the device and tinker and there are community created ROMs which let you change the base system.  It is effectively an embedded Linux platform with a java like application stack.  I tend to follow the CyanogenMod crowd.

On my ADP1, I’ve got the developer friendly “fastboot”.  Using this you can install what is called a “recovery image” – a secondary boot mode which lets you get in and do maintenance etc.  Recently I found myself in a state where I had lost my recovery image.  The forum has some good basic advice if this happens to you.

As I found myself needing to reinstall.  The recommended recovery image is Amon_RA.  I used the fastboot flash method, from my Ubuntu desktop using the fastboot binary.  Once I had the binary, it really was as easy as booting into fastboot mode (hold camera button while phone is booting) and runnning the fastboot program.

fastboot flash recovery recovery_of_choice.img

Now what got me to this state of no recovery image, was most likely a finger fumble while I was trying to recover the phone from a bad state.  (Did I mention I was to blame here?)  Now I suspect there is some sort of latent bug in the Dalvik cache management that leads to this bad state, but I don’t yet have enough data to make a strong statement here.

What happens is at one point, apps stop opening properly for me.  Specifically things like the web browser.  The 1st time this happened, I ended up wiping the phone and starting again from scratch. While this is a recommended step if you’re going to play in the ROM scene, it is annoying to lose all of your state.  To my dismay it happened again.

The symptom is a boot loop when you reboot.  Using some of the tools from the Android SDK, you can watch things as they happen on boot.  I use ddms for this.  In the most recent failure, the loop looked like this in the log:

07-04 16:17:28.114: DEBUG/AndroidRuntime(249): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
07-04 16:17:28.114: DEBUG/AndroidRuntime(249): CheckJNI is OFF
07-04 16:17:28.284: DEBUG/AndroidRuntime(249): --- registering native functions ---
07-04 16:17:28.544: ERROR/AndroidRuntime(249): JavaVM unable to find main() in 'com.android.internal.os.ZygoteInit'
07-04 16:17:28.544: DEBUG/AndroidRuntime(249): Shutting down VM
07-04 16:17:28.544: WARN/dalvikvm(249): threadid=3: thread exiting with uncaught exception (group=0x4001e178)
07-04 16:17:28.574: DEBUG/dalvikvm(249): DestroyJavaVM waiting for non-daemon threads to exit
07-04 16:17:28.574: DEBUG/dalvikvm(249): DestroyJavaVM shutting VM down
07-04 16:17:28.574: DEBUG/dalvikvm(249): VM cleaning u
p

Not good.  Something can’t be found that is fairly critical, so the Dalvik system is continually bailing out on its start-up, then trying again.

The fix was quite easy (if we ignore the step where during the investigation, I mess up my recovery image).  The adb tool found in the Android SDK is much more powerful than I initially understood it to be.  We can use it to stop the Android sytem.

> adb shell stop

This effectively stops the boot loop from spinning around and around.  Now issuing:

> adb shell

Gets you into the device, and we can go and fix the filesystem.  I located and cleared the Dalvik caches (deleted the contents of the directories).
cache/dalvik-cache
sd-ext/dalvik-cache
data/dalvik-cache

You may only need to clear the 3rd one, but that is the list I cleared out to get back into a working state.  Much easier than a full wipe and reconfigure.

Android 2.1 on G1

Thanks to the hard work by the Android hacking community CyanogenMod 5.0.7-test1 is now available for the G1. My phone was already running CyanogenMod (CM 4.2.115.1) thus there wasn’t any need to root the device, but I did need to upgrade the SPL.

The CyanogenMod wiki has instructions that cover exactly what I wanted to accomplish: install DangerSPL and upgrade to the experimental CM 5.0.7-DS-test1.  I’ll walk through the instructions I followed with some notes.  With any type of firmware modification you’re clearly going to void any warranty you may have, and it is recommended to read through the whole procedure at least once before starting.

The prerequisites are: Rooted G1 (check) and a compatible radio (mine was 2.22.19.26I).  You’ll need to download 3 files: DangerSPL, GoogleApps, and the new Firmware.  Connect your phone via USB and place these files on the root of the SD Card.

You also need a recovery image.  Mine is CyanogenMod 1.4 + JF, but Amon_ra is supposed to work as well. To verify you have a recovery image that is compatible, reboot your phone and hold down the home key – this will boot the recovery image.

To check that you are NOT already running the DangerSPL, enter fastboot mode.  Reboot the phone while holding down the camera button.  You’ll see something like:

DREA100 PVT 32B
HBOOT-0.95.3000
CPLD-4
RADIO-2.22.19.26I

The DangerSPL will have HBOOT-1.33.2005.  To exit fastboot mode, press call (green), menu, and power (red).

Allow me to stress – these instructions are all on the CyanogenMod wiki – reproduced here only to allow me to comment, all credit goes to the CyanogenMod crew.

1) Verify that you meet BOTH the prerequisites (G1/Dream & Radio)

If you don’t know if you’re phone is rooted, then it probably isn’t.  Try google for some help. To check the radio version look at Menu->Settings->About phone->Baseband version, the radio version is the 2nd part of the version info.  Or reboot into fastboot mode to check the radio version.

2) Copy DangerSpl (spl-signed.zip), CM 5.0.x, and gapps-ds-ERE36B (& Ebi1 port if required) to the root of your sdcard. Reboot into Recovery (CM Recovery or Amon_ra Recovery both work)

The Ebi1 port is for 32a phones.  Again I’ll refer to the fastboot screen indicating we’re are a 32b phone.

3) To reboot into Recovery, restart your phone and hold down the ‘home’ key before the G1 splash appears.

4) Make a Nandroid Backup (ext not required)

Steps 3 and 4 are pretty self explanatory.

5) Flash DangerSpl (spl-signed.zip). It will install and then ask you to reboot to finish the installation, so reboot. It will then finish installing and reboot into recovery so you can flash your ROM.

This is the “scary part”.  The DangerSPL originated as Haykuro SPL, this modified SPL takes away some of the /cache and allocates it to /system and /data – effectively allowing for lager ROMs.  You shouldn’t have to do this step again, once you have the modified SPL you’re good to go for ROM changes later.

6) Flash CM 5.0.x THEN gapps-ds-ERE36B (& Ebi1 port if required); then reboot (Boot may take longer than normal) DO NOT reboot between flashing ROMs!

This is the actual installation of the CM 5.0.7-test1 firmware.  The google apps portion is split off to avoid copyright issues for the CyanogenMod crew (in theory you should really be extracting the google apps from your existing device..)

That’s basically it.  I was a bit surprised that all of my settings made it across to the other side.

For anyone upgrading, I’d suggest you also review the normal upgrade link.  If you read that page you will find the comforting note:

Note: G1 users need to have DangerSPL, the instructions there will leave you with CM 5.0.x installed, no need to follow these instructions after (unless you nandroid restore).

You may also want to review the troubleshooting section of that same page.

I happened to have the Dalvik Debug Monitor (ddms) running to capture some screenshots.  It turned out to be quite useful as the 1st boot cycle is very long.

Issues so far

I had a fair number of apps installed, and once I had the DangerSPL and the new firmware installed, I immediately starting getting low on space warnings. With only 6MB free, I was having trouble starting some applications (GTalk).

The solution was to enable apps2sd.  The easiest way for me to do this was to unmount the SD card and use my Ubuntu desktop to repartition it with GParted.  Since GParted allows for partition resizing, it was trivial to add a new ext4 partition on the end of the card.

Now you’re not done yet.  Once you put the card back and rebooted, you want to modify the setting that tells the system where to put newly downloaded apps (on the SD card).  Menu->Settings->Applications->Apps2SD. Now for each installed application we need to toggle it to the SD card as well if we want to clear out some of the internal memory.  First head to: Menu->Settings->Applications->Manage applications, then select each application and use the Move button to change it’s storage location.

There are some rough edges.  Some of the stock apps (Gallery) I had linked on my home screen.  The gallery didn’t work, until I erased the short-cut and dragged a new copy out. Wow – the gallery is one of the most improved areas I’ve noticed so far.

You do need to fix your Sync settings.  Go to: Menu->Settings->Accounts & sync settings, click on your account and adjust the sync settings.  Most of them seemed to be disabled by default.

Initially I thought: wow – this is way faster.  After a while I either got used to the improved performance, or it isn’t really that much faster.  The 2.1 features are very nice to have.  I’ve also moved from Twidroid to the official Twitter client which is only available on 2.1.

Bugs:

Text messaging is sort of busted.
Poor battery life (workaround and also fixed in test2)

There are other issues too, but it is pretty remarkable how usable this is for an experimental version.  For more details go visit the forum.

Life with Droid

I’ve now had the G1 for a few weeks and wanted to write a little about some of my experience so far.  Previous to getting the G1 I had started to carry my iPod Touch with me on a regular basis, I still use the iPod Touch but I can imagine living without it.

Let’s talk about some of the basics.  I wanted to carry some photos of my family around – this was super easy to do and very Linux friendly.  Simply connect the phone to the Linux machine via USB, then on the phone choose to mount as a USB device. The PC will now detect a USB drive and hook you up.  Copying photos into a sub-folder of /DCIM was all I needed to have them appear in the gallery.  To disconnect, umount on your PC first – then on the phone.  Moving music is similarly easy.

If you’re willing to “go Google” then your Gmail, Google Calendar and Google Contacts will all sync to the device. I’ve previously talked about the state of Linux address books, and the calendar situation seems to be similarly dire. Email I’m still holding out on probably more because I’m stubborn.

A few tips on configuring your Android phone.  If you want to exclusively use wifi (as I do, since I’m not using a data plan) then you’ll want fiddle with the advanced wifi menu.  You certainly want to run CyanogenMod or similar, and when you do that you’ll want to consider using the spare parts option to keep the “Home app in memory” which for me seems to improve overall responsiveness.

Moving from the iPod Touch to the G1 I gained a camera, GPS, a built in microphone and phone functionality.  In general the same types of apps are available, so you aren’t missing out on any function.  The iPod is much slicker than the G1, the browser is faster the gestures and general UI experience is more uniform. I’m still completely sold on the Android path, the ability to tinker with the device is greater and it is possible to use it with a Linux based desktop without standing on your head.

Read on for a comparison between the apps I have on my iPod Touch vs. what is on my Android phone.

Continue reading “Life with Droid”