[Touch Diamond, MDA Compact IV ROM Development] druidu:
How to make haret eat an Android 1.0 image

Actually, it's a bit over 20 MB. I did manage to strip some stuff off Android so the resulting initrd was accepted by Android. So you don't get your hopes up -- no, it doesn't boot but it gets pretty far.

Here are the details on how to get a basic Android 1.0 image from git sources (it does take a while to compile though, skip first 2 steps if you already have a compiled version):

1. First of all, compile your own Android from all the sources.

2. Now you have 3 .img files in out/target/product/generic/ (ramdisk.img, system.img, userdata.img). First is a gzipped cpio, next are yaffs2 images. There are also directories with the original filestructure (so you don't have to add yaffs2 support in your own kernel to extract system.img and userdata.img).

3. Copy directory out/target/product/generic/root to some temp work directory, let's say /tmp/android/. This will be main structure for your ramdisk.

4. Copy directory out/target/product/generic/system to /tmp/android/ (so that you now have /tmp/android/system/ with the files in the system.img image).

5. Same as above for out/target/product/generic/userdata so you will have /tmp/android/userdata/

6. Customize the init files /tmp/android/init.rc and /tmp/android/init.MACHINE.rc where MACHINE is goldfish for default compile (first word of machine description text, lowercase -- using kernel sources from our git with mtype set to RAPHAEL should be init.htc.rc). Note that they are not bash scripts, most are internal commands that the Android init scripts recognizes (check system/core/init/ in Android platform sources for more info). You'll want to comment the mount instructions in /tmp/android/init.rc that mount /system /data and /cache. They are already "mounted" since we include them in the inird. The mount for /sqlite_stmt_journals can stay since it's using tmpfs, and so can all the chown/chmod instructions. The essential line in here is what starts the actual Android service -- "service zygote /system/bin/app_process", and a few other critical services. I turned off what seemed unimportant for now (bluetooth, wifi), but you should experiment with these.

7. Start stripping! Initially I thought I could strip the browser and media libraries and a few other apps, but it seems that if you take out any libraries (/system/lib/*.so), zygote (main Android service) won't start. Here's what I think you can strip:

- /system/media/audio/ringtones/ - 1.9 MB - should work without these and we don't have sound anyway

- /system/usr/srec/ - 2.0 MB - speech recognition stuff, shouldn't be essential

- /system/app/*.app - only strip a few big files, try apps that seem to be less important (example: don't strip Launcher.apk, I'm guessing that's the homescreen); try: Browser, Camera, Email, IM, Mms, Music and one-two more if it still doesn't fit.

Don't foget that initrd is compressed with gzip, so deleting some files would impact less than it would seem (example: .apk or .ogg files are already compressed so they don't shrink much, but a large textfile wouldn't matter since text files compress very good).

8. You may want to apply netripper's patch to let you calibrate screen then start Android after that (move /init to /init-real, put the /init from his Android 0.8 initrd and also copy /system/bin/readtty from the same initrd).

Anyway, after stripping the ringtones, src and some apps, and booting linux... I get dropped to the shell (started from /init.rc by "service console /system/bin/sh") but in the background, zygote and some other services are also started (you can run "ps" to see, if you're quick). After a bit of time, Android seems to try to take over, console refresh stops (only first line is seen, rest of screen is black), then it crashes I guess... Must be some service/driver Android is not happy with (could be inter process communication driver, just a guess).

PS: as I said, I'm pretty busy with work right now and I don't have time to experiment with this anymore (I tried this a few days ago). If someone gets anywhere, post the image or list of changes to init scripts and files removed from image :)