[Hero CDMA Android Development] tkirton:
Installing Support for Apps2SD in your Rom

How to add Apps2SD support to your Rom

If you are a new rom developer, chances are you are building a rom based on either someone else's work or you are using the stock rom. If you base your rom on someone else's work, chances are the previous developer included support for Apps2SD in the boot image.

However, if you are starting from the stock image, or you have grabbed a rom that doesn't have Apps2SD support, you aren't stuck. Here's a guide that will help you disassemble a boot image, edit the necessary files to activate Apps2SD, and reassemble a boot image.

To begin, you'll need a Linux or a Mac system and basic knowledge on how to navigate through your Linux or Mac via a terminal program. The tools presented in this guide will only work with those systems.

1. Create a directory called workspace. This will be where you work on the ramdisk.

2. Inside workspace, create another directory called scripts. This is where you will place the tools and scripts you will need.

3. Download the following and uncompress the files into the scripts directory: http://www.darktremor.info/files/tools/ramdisk-scripts.zip

4. Open a terminal window, change the directory to the workspace directory, and type chmod 755 *

5. Put the boot.img from the rom you are working on in the workspace directory.

6. In the terminal window, change to the scripts directory and type ./getramdisk

7. Change to the ramdisk directory located in the workspace directory.

8. Open a text editor and load init.rc

9. Look for a line called class_start default.

10. Choose a method:

11. Save the init.rc

12. Change to the scripts directory and type ./makeramdisk

13. Now it's time to create the boot image. In the scripts directory, you need to run the command makeboot, but you are going to need to enter some information on the command line:

a. You need the filename of the kernel code. This was created for you when you ran the getramdisk command. The file is called boot.img-kernel and it is located in the workspace directory.

b. You need the filename of the new ramdisk file you created. This was created for you when you ran the makeramdisk command. The file is called newramdisk.gz and it is located in the workspace directory.

c. You need to know what you are going to name your new boot image. You need to name it something other than boot.img (we'll fix that part later in the guide). Try newboot.img and save it to the workspace directory

d. You will need to know your kernel base address. Now I don't have all of the base addresses for all the phones, but I do have the four I normally work with when developers need me to check their boot image. This part is very important, as using the wrong base address will cause your phone not to boot (and you'll have to restore back from a recovery image). Use the following values for the base address and the kernel start commands:

From the scripts directory, type:

./mkbootimg --kernel <Path and filename to boot.img-kernel> --ramdisk <Path and filename to newramdisk.gz> --cmdline "<Command Line from above>" -o <Path and filename of new boot image> --base <Base Address from above>

Example: ./mkbootimg --kernel ../boot.img-kernel --ramdisk ../newramdisk.gz --cmdline "no_console_suspend=1 console=null" -o ../newboot.img --base 0x19200000

14. Move the newboot.img file into the directory that you are using to build your rom and rename it to boot.img (you will have to delete the old boot.img first).

Now, if all works well, you will have a boot image that actually boots and has Apps2SD support built in.

To use Apps2SD with the Apps2SD direct method, simply put a file with the Apps2SD code in /system/bin and name it a2sd

To use Apps2SD with the Busybox Run Parts method or the CyanogenMod Froyo method, simply put a file with the Apps2SD code in /system/etc/init.d and name it anything...just make sure it starts with a two-digit number (not sure if that's an actual requirement, but all the busybox run parts roms use it). Example of this is 04apps2sd.