[Atrix 4G Android Development] sendust7:
I ported my automatic boot image modifier from Linux/Ubuntu to Windows. As with the Ubuntu version, my auto-modifier redirects ROM filesystem mounts from emmc (internal memory) to SD card (external memory) in the boot image to more quickly boot a ROM hosted on SD.

Features

Simple, lightweight install. No need to separately install Cygwin and required packages.

As with the Ubuntu version, the boot image ramdisk directory is automatically modified to redirect filesystem mounts for /system, /cache and /data from emmc to SD card so you can quickly boot a ROM hosted on SD. No other changes are made, though the Perl code can be altered as necessary to further modify ramdisk.

Tested working on XP using NottachTrix 1.3.1 AT&T boot image file. For Win 7, you may need to tweak User Access Control (UAC) to launch Cygwin.

Note: The unpacker script is just a copy of “split_bootimg.pl“ found here: http://www.enck.org/tools.html (Thanks Bill.)

Instructions

1. Download cygwin-auto-modify-boot.zip (50MB) here: http://www.mediafire.com/?kz9fqzwznzizb1z

2. Unzip files to Windows c:\ . OR, if you already have a fully functioning c:\cygwin build that contains the Perl v5.14.2, cpio and gunzip binaries, you should only need to extract the directory: cygwin\home\modify-boot to c:\. In any event, you should backup your existing c:\cygwin directory prior to unzipping.

3. Copy the original boot image file (boot.img in this example) to c:\cygwin\home\modify-boot

4. Navigate to c:\cygwin and launch c:\cygwin\cygwin.bat . This opens a cygwin command window, and also generates a set of user configuration files if opened for the first time.

5. In the Cygwin command window, enter: cd ../modify-boot . Here is my directory listing after Cygwin configured my system:

6. In the Cygwin command window, enter the command: ./modify-boot.sh boot.img and press Enter at the prompts. For me, the entire process took ~30 seconds to modify a NottachTrix boot image.

If everything goes right, the system creates a “boot-repack.img” file based on the modified ramdisk and stores it in the modify-boot directory. Various log/debug data are presented on screen and stored in the modify-boot directory.

That’s all! From here you can “fastboot flash boot boot-repack.img” to boot your SD-based ROM, or store the modified image in a boot configuration directory. See http://xdaforums.com/showthread.php?t=1645344

Please note: The size of my dev team has never exceeded one (me); yet I will try to field requests for help as I am able.

References and Credits

http://cygwin.com/install.html

http://www.enck.org/tools.html

http://xdaforums.com/showthread.php?t=1630130

+++++

Linux/Ubuntu Version

Many have studied this excellent tutorial on how to unpack, modify and repack Android ROM boot images: http://android-dls.com/wiki/index.php?title=HOWTO:_Unpack,_Edit,_and_Re-Pack_Boot_Images. Its contents form a solid baseline for customizing ROM boot images and ROMs in general. Here I attempt to automate the process of modifying boot images.

Results thus far provide an efficient means of booting ROMs that are cloned to SD card (see my clone thread: http://xdaforums.com/showthread.php?t=1764680 ), as shown in the example below.

modify-boot zip: http://www.mediafire.com/?luobv279pcv827k contains five files: three Perl scripts to unpack, modify and repack a boot image, the “mkbootimg” executable, and an executive batch file to run the three Perl scripts in sequence.

Boot image modifier script: modify-bootimg-atrix.pl features a useful example of how customizations can be pre-programmed by including code to redirect ROM filesystem mounts to SD card, thus enabling us to boot SD card-based ROMs --- almost on the fly.

Of course there are many references to customizing boot images, but to my knowledge this is the first published attempt to automate the process. And since there are some interesting projects related to hosting Perl on Android (see References below), I think it would be fun to develop a CWM-flashable zip (or similar tool) that loads a Perl script interpreter and then runs a pre-programmed boot image modifier --- all on phone, without computer aiding.

Preliminaries

Linux-based OS (Ubuntu 12.04 preferred --- it's still free)

Android SDK Platform Tools (includes adb and fastboot)

Perl (Ubuntu 12.04 includes Perl 5.14.2)

Example: Boot Neutrino V2.8 GT cloned to SD card

Suppose we have already cloned Neutrino V2.8 GT ROM (/system, /cache and /data) to SD card. To boot it:

1. Download modify-boot.zip: http://www.mediafire.com/?luobv279pcv827k to Desktop and extract directory: /modify-boot to ~/Desktop

2. Extract boot.img from Neutrino V2.8 GT ROM.zip and drop it in ./modify-boot

3. Open a terminal, get root and cd ~/Desktop/modify-boot

4. Enter: “sh ./modify-boot.sh boot.img” and follow prompts (Output file: boot-repack.img)

5. Boot to fastboot and connect phone to computer

6. fastboot flash boot boot-repack.img

7. fastboot reboot

Once phone is booted, we can run a sanity check by entering:

adb shell (access Android filesystems)

# mount

Results should include the highlighted device names for filesystem mounts:

[COLOR="Blue"]/dev/block/mmcblk1p2 on /system[/COLOR] type ext4 (rw,noatime,nodiratime,errors=continue,barrier=0,nobh,data=writeback,noauto_da_alloc,discard)
[COLOR="Blue"]/dev/block/mmcblk1p4 on /data[/COLOR] type ext4 (rw,nosuid,nodev,noatime,nodiratime,barrier=0,nobh,data=writeback,noauto_da_alloc,discard)
[COLOR="Blue"]/dev/block/mmcblk1p3 on /cache[/COLOR] type ext4 (rw,nosuid,nodev,noatime,nodiratime,errors=continue,barrier=0,nobh,data=writeback,noauto_da_alloc,discard)

We can now boot a cloned Neutrino V2.8 GT ROM from SD card, and/or save the modified boot image in a safe, visible location on SD card to configure dual boot (please see: http://xdaforums.com/showthread.php?t=1645344 ). Or, we can roll the modified image into a flashable zip for a standalone boot push.

Standard disclaimers apply. In short, I am not responsible for any harm you or your phone may incur by using any or all of this material.

References

http://code.google.com/p/perldroid/

http://code.google.com/p/android-scripting/

http://xdaforums.com/showthread.php?t=1585009

Credits

Many thanks to the Android Community Effort ( http://android-dls.com/wiki/index.php?title=Main_Page ), and to my friend and xda member ghost_og for his “mkbootimg” command-line fix that made boot image repacking work for Atrix.