[HTC Desire 526] BigCountry907:
Finishing Up the generator

We are going to add a few formulas to finish up.

This is exactly how the whole spreadsheet works.

So if you need to change something you will find out that all the data except for what we pasted is generated.

Step #1

Go to Cell AI4 and click on it.

Input the following formula.

=(AF4*2)

That means take the contents of cell AF4 and multiply it by 2.

A sector equals 2 blocks. So the No. Sectors is 2 times the No. Blocks in KB

Step #2

Lets get the start and end LBA.

For this we will go to the section of the generator that DECODES THE RAW HEX DUMP.

You will notice that everything is color coded.

This way when you need to see where the data is at you can find the same color.

Lets look at one example.

The color blue matches the color blue where we pasted the hexdump.

The first box is the cell numbers that the data is coming from.

The second box is just to add more color

The third box is the name we are translating the data into.

The 4th box is the exact data being used from the hexdump.

The 5th box green is the TRANSLATED Data.

You can see the actual hex data from the hex dump is the same color.

So all in all here is what this set of data means.

There are 68 partitions in this GPT.

A simple formula lets us convert the hexdump data to decimal data

=HEX2DEC(D42)

That means read cell D42 and convert it to decimal.

so 44000000 = 68 when converted.

Thus = the number of partitions

Be careful if you change any of these.

Different groups of bytes get translated in different forms

We need to know if any of our partitions are bootable.

So we can set the botable partitions flag.

WE can look at the Boot Flag in the GPT Header.

Ok so if we scroll down a little we can see our partition data.

For each partition. A total of 68.

Lets start with the First Partition Board_Info.

This is the board info partition block

You need to look at the Partition Attributes Data.

This tells us if it is a READ ONLY partition or not.

We need to know if any of our partitions are bootable.

So we can set the botable partitions flag.

We will look at the partition attributes. One of these bits is the bootable flag.

Im not sure which one.

But if it is zero then it is not bootable.

So if the data in the partition attributes cell is all zeros like this.

the partition flag for readonly is false

the partition flag for bootable is false.

We came here to fix the LBA lets do that.

In this block we have the starting LBA and Ending LBA of the partition.

The Logical Block Address

You can see the values here from the hex dump.

2200000000000000
4100000000000000

Since they are small enough that they are only 2 bytes we can convert them. ( 4 bytes we cannot convert )

The bytes are

22
41

In our converted values we show zero.

highlight the 2 cells and hit the delete key.

The converted data should look like this now.

We need to convert the bytes into the real start LBA and end LBA.

Input these formulas into the 2 cells. AB72 and AB73.

In cell AB72 enter

=HEX2DEC(AE72)

In cell AB73 enter

=HEX2DEC(AE73)

The converted data should now be

34

65

It will look like this.

Now we know that

Starting LBA of Partition #1 board_info = Cell AB72

Ending LBA of Partition #1 Board_info= Cell AB73

Lets go and fix the rest of our Generator with the Information we just created.

Back up in the partition size area we need to enter this start and end.

We need to make cell AG5 = AB72 and cell AH5 = AB73

Like this.

Now lets do some math. to calculate sizes

1 sector = 512 bytes

1 Block = 1KB = 1024 bytes

Bytes get counted from the beginning of the memory not the beginning of the partitions.

The GPT Partition Table is 17407 bytes long.

So the Number of Blocks in the GPT Partition table is

17407 / 1024 = 16.999 KB

We only use multiples of 16 since we are dealing with 16 byte line lengths.

That makes the number of blocks = 16 KB

16 KB * 1024 = 16384 bytes

That makes the number of sectors = 32 sectors

16384 / 512 = 32 sectors

To calculate the Ending LBA We take the 16 Blocks in KB and add them to the block size in KB of the partition.

So partition 1 = 16KB

The Last Byte Address is found like this.

16kb GPT Table + 16kb partition

so (((32 * 1024)/512)+1)=

((32768/512)+1)=

64+1=65

So the Last Byte Address of Partition 1 is indeed 65

Now for partition 2 we have the starting address.

it is the ending address of partition 1 plus 1.

That is 65 + 1 = 66. or AH5+1=AG6

Now we have a formula.

Put this in cell AG6

=AH5+1

Then select cell AG6 right click and select copy

scroll down to cell AG69 hold shift and click it.

Then right click AG69 select PASTE only and FORMULAS.

It will look like this.