[JASJAR, XDA Exec, MDA Pro ROM Development] VNInt:
[TUT] Simple way to add Flash Disk (a.k.a "Internal Storage") to your own ROM

It's so long time, no one answer this question "How to add Flash Disk to own-cook ROM?", so I tried to find it out myself and I had found 2 different ways to do that.

As promised, or just a way to say thanks to all this community, I will share the way which more simple than the other.

It worked with Universal devices and may work with others, too!

* What you need?

1. Your ROM file (OS.nb, a.k.a nk.nba, nk.fat), different kitchens use different file names.

2. Any HEX editor, I use XVI32 here.

3. My Flash Disk image template.

* How it work?

The maximum size for a Universal OS ROM is 63 MB (66.060.288 Bytes), normally, we use less than this size for our ROM, the remain size is useless at all, so we make it useful by partitioning it.

* Which things to modify?

- Nothing in your SYS and/or OEM.

- boot.rgu in your XIP (only if it is not XIP-ready :D)

- First 512 Bytes of your ROM file (called Master Boot Record) (only if it is not MBR-ready :D)

- First 512 Bytes of my Flash Disk template file (called Boot Sector or Boot Record), it is a must edit thing to do (determine the size of Flash Disk)

* Here we go!

1. Download my file below, extract it and your nk.nbf into the same folder.

2. Run HTC64, decode your nk.nbf into two files (nk.prj and nk.fat).

3. Run HEX editor (XVI32), open nk.fat and write down two values (or just remember if you can) RED value (from $1E6 to $1E8 [or from $1F6 to $1F8 if they are not all 00]) and BLUE value (from $1EA to $1EB [or from $1FA to $1FB if they are not all 00]).

- Note: I use luca16thebig 1.4.9 BETA1 ROM for example, values may different from your ROM or this ROM after rebuilt.

4. Close the file nk.fat and don't save if there is anything changed. Open VNIntFlashDisk.template (also in HEX editor).

Match two RED and BLUE values which you have writen down into two place RED (from $1C to $1E) and BLUE (from $13 to $14). Double check if the values are corrected and fixed into its places and save the template.

- Note: I have already done it with luca16thebig 1.4.9 BETA1 ROM's values, so just goto next step

5. Run combine.bat from my package, your original ROM file will be saved as nk.fat.original. The file nk.fat now is Flash Disk ready!

6. Run HTC64, re-encode two files (nk.prj and nk.fat) into nk.nbf and we are done!

* What is RED and BLUE values mean?

All two values are in HEX and reversed order, in this example we have:

- RED value is 80 88 01, so its true value is 1.88.80h, change it into decimal number, we have 100.480. It is the number of used sectors (1 sector = 512 Bytes). And... luca16thebig 1.4.9 BETA1 ROM's original size is 51.445.760 Bytes = 100.480 sectors x 512 Bytes.

- BLUE value is 80 6F, its true value is 6F.80h, in decimal is 28.544. It is the number of free sectors, so our Flash Disk size is 28.544 sectors x 512 Bytes = 14.614.528 Bytes ~ 14 MB.

- As you known, OS ROM maximum size is 66.060.288 Bytes = 51.445.760 Bytes + 14.614.528 Bytes.

If your ROM is MBR-ready, each time you rebuilt the ROM, all two values will automatically adjusted in MBR and you just match these values into my Flash Disk template. That all!

- Note: luca16thebig 1.4.9 BETA1 ROM is XIP-ready and MBR-ready. So, if your ROM doesn't work with this instruction, post your 512 Bytes MBR and your boot.rgu file here. I will analyse and make instructions how to make them ready.

When I release this instruction, I tried to make all things clearly from basic to advance but it seem so hard to... eat! So, I did it in reversed order, :D let you can do it first, then explain and/or clarify. More details will be add later (only when someone needed)!

Link: VNIntFlashDisk.rar