Late last night after several days of strace hell, much gnashing of teeth, and a bit of coffee; I finally booted up to the grassy wallpaper lockscreen of Gingerbread CM7 goodness.
I’ll be honest, I had no idea what it would take to get it running when I started.
My Droid 3 alpha port of CM, relied on several things:
- Right off the bat, I was lucky and was able to use cvpcs’s Bionic device board as an initial reference. Note that while the device board settings help get you started, it’s not a full working config. I’m guessing he has commits on his drive that aren’t at GitHub. And I had to make several alterations for the Sandbox configuration that I’m running (more later on this)
- Persistence.
- Persistence and oh some troubleshooting skills.
For the last week my nights have been:
- Boot into recovery
- Play with init* files via adb. (mainly setup tracing and or make config changes)
- Attempt a boot, get stuck at “Dual Core”
- Reboot recovery, grab logs. See errors.
- Try and fix errors. Goto step 1.
Part of what made the process more difficult was that I’m running a non-standard Bootstrap and a modified version of Koush’s recovery to bring the system up. I call it the “Sandbox Bootstrap” for the moment.
As a programmer I like to understand how things work, and one of the reasons I didn’t use the stock CM hijack was to get a feel for how locked bootloader phones get other versions of Android to run.
The idea for operating in a “sandbox” is simple:
- We have a locked bootloader, and if we play around with /system too much, we’re stuck with a fastboot recovery. (Didn’t your mother warn you about that?)
- Also, I’m not really a “developer”. My phone is actually a phone. On Monday morning, I need to make phone calls with it. I needed a way to “flip” back to a working state fairly easily and reliably.
- If you want to be a tester for one of my ROMs, then I want you to have the same smooth process for swapping into a testing environment and back out to a usable phone. Because god knows, I’m going to fuck this ROM all up as I go along. And your phone will be broke.
Enter the Sandbox Bootstrap (or 2nd-system). There are 3 main portions to it (just like any other Bootstrap):
- It does a “boot to recovery” check (booting from “BP Tools” mode)
- It then checks for file called “alt_system_mode” in /system/etc/recovery/flags. If that file is present, it 2nd-init’s. And resets the OS to boot from the /preinstall partition.
- If it doesn’t find either, then it lets the system boot normally.
I make use of a slightly customized version of Clockwork Recovery to help with this process. Right now, I’m working on smoothing out the transition from system #1 to system #2. The end result will be a “Swap Systems” option which does the following:
- adds/removes that alt_system_mode file under the original /system
- makes a backup of the current userdata
- restores an alternate set of userdata depending on which system you’re turning on
- and wipes the /cache.
All via 1 option (with a confirmation of course).
So, I can debug CM7 till I’m blue in the face till 3am, then swap back to MotoBlur and go to work at 7am with a working phone.
The other issue for the recovery is applying .zip updates. Normally, anytime a .zip makes changes to /system, it has the chance to break recovery and you’re left with a fastboot restore (again).
In my option, this is unacceptable for a phone that I like to “play” with. In my customized recovery it applies .zip updates to the /preinstall partition like it was /system. Now the caveat is if the .zip file mounts the block device for the original system (mmcblk1p21), then it will make changes to your main system. Beware these .zip files. :P
Hopefully, I’ll wrap a bow on all of this and put it out in the wild over the next day or so. Check back here for updates / downloads.
NOTE: Using my Sandbox Bootstrap will remove the files that the stock Bootstrap puts in place. Something to consider before choosing to use it (and the ROMs I will be putting out.) If there’s enough interest may also release ROMs with a more stock configuration to use with Koush’s standard hijack. We’ll see.