[REF] Investigation Into PIT Files

Search This thread

RyanZA

Senior Member
Jan 21, 2006
2,023
784
JHB
There is very little technical information on PIT files , so this thread is an attempt to find out some real details about PIT files, and perhaps eventually be able to create our own PIT files (by modifying Samsung ones, probably).

First, what we think we know PIT files do:

- PIT files only affect the 'STL' devices. That is, it affects the OneNAND and not the MoviNAND.
- PIT files appear to control the sizing (and maybe number) of STL devices that appear in Linux.
- PIT files appear to be used by Odin to map filenames inside .tar archives to STL partitions.


STL files are quite small, at under 2KB in size. Most of the file is made up of 0s. I have tried to compare the differences between the 512 513 and 803 PIT files we have available.

All the PIT files start with 76 98 34 12 0D - probably a signature to show it is a PIT file.

[Unimportant]

The 803 PIT file then has 00s all the way to the next common point. The 512 and 513 both have common data till the next common point - but this can't be too important as the 803 just has 00s.

The next common bit seems to read the following:
"oft IBL+PBL Server\90\To boot.bin inn; C:\Program Files\ESTsof
This probably indicates something to Odin. Strange that it has C:\Program Files\ - build path for the PIT file?

Next we have some 0s with common 1s inside them, followed by the word PIT, then more 0s, and then ries.pit. All common from here on with the words 'EFS' and 'efs.rfs'. Probably telling odin to map the efs.rfs file to the 'EFS' token. Tokens probably defined either in the kernel, or in the closed source STL library. More of the same of this, with 'SBL' 'sbl.bin', 'SBL2' 'sbl.bin' -- Both SBL and SBL2 map to the same sbl.bin file?

'PARAM' to 'param.lfs'
'KERNEL' to 'zImage'
'RECOVERY' to 'zImage' (this one is interesting - could we have seperate zImage and recovery? Could save some RAM here!)

[/Unimportant]

And now we'r onto the actual changes between the PIT files. 'FACTORYFS' maps to 'factoryfs.rfs'. However, before the FACTORYFS token, there are some bytes that likely control the partition sizes.

FACTORYFS
803 : A2 04 : 41476
512 : 7A 04 : 31236
513 : CA 04 : 51716

DBDATA
803 : F0 01 : 61441
512 : 18 02 : 6146
513 : C8 01 : 51201

CACHE
803 : 8C
512 : 8C
513 : 8C

MODEM
803 : 32
512 : 32
513 : 32

So there we have it. The only real changes between the PIT files are some seemingly garbage header information in 512/513 that is missing from 803, and FACTORYFS and DBDATA have different numbers -- probably sizes.

So assuming FACTORYFS maps onto /system, we can see that the only differences in the PIT files is moving space back and forwards between /dbdata and /system. The numbers themselves don't mean anything to me - can anybody work it out? :D
 
  • Like
Reactions: filou75

sztupy

Inactive Recognized Developer
Dec 21, 2008
1,061
877
Edinburgh
sztupy.hu
The numbers are little-endian, so you need to read them backwards per bytes. So instead of A12 it's actually 120A, etc. If you do so, you can see that the difference between 803 and 512 are actually minor, 40 "units" are shifted between probably DBDATA and SYSTEM.

Btw: doesn't the heimdal project klnow something about the pit files?
 

RyanZA

Senior Member
Jan 21, 2006
2,023
784
JHB
Nice, that gives us

FACTORYFS
803 : 04 A2 : 1186
512 : 04 7A : 1146
513 : 04 CA : 1226

DBDATA
803 : 01 F0 : 496
512 : 02 18 : 536
513 : 01 C8 : 456

1186+496=1682
1146+536=1682
1226+456=1682

So we have a match. :)
Now to work out why the fat.format can work with 536, but not with 496

EDIT: Also, need to determine why some roms require certain PIT files. Only possibility I can see is that junk in the header - could be some type of allow list for firmwares. The 803 PIT should therefore work on all firmwares, since it just has 00s. Maybe. :)
 
Last edited:

RazvanG

Senior Member
Aug 1, 2010
359
81
In 803.pit (compared to the .512 one) the system partition size has been increased by 10MB, while DBDATA partition size has been decreased the same amount (10MB).

PS: Dump the BML2 partition. The dump contains current partition mapping.

Hope this helps :)
 

sztupy

Inactive Recognized Developer
Dec 21, 2008
1,061
877
Edinburgh
sztupy.hu
Nice, that gives us

FACTORYFS
803 : 04 A2 : 1186
512 : 04 7A : 1146
513 : 04 CA : 1226

DBDATA
803 : 01 F0 : 496
512 : 02 18 : 536
513 : 01 C8 : 456

1186+496=1682
1146+536=1682
1226+456=1682

So we have a match. :)
Now to work out why the fat.format can work with 536, but not with 496

EDIT: Also, need to determine why some roms require certain PIT files. Only possibility I can see is that junk in the header - could be some type of allow list for firmwares. The 803 PIT should therefore work on all firmwares, since it just has 00s. Maybe. :)

I think the main cause is that some firmwares simply don't fit in the space reserved for them. Some of the m have larger system, some of them have larger dbdata partitions. Only a guess though, I think I start flashing pit files just for fun...
 
  • Like
Reactions: jaetm83

sztupy

Inactive Recognized Developer
Dec 21, 2008
1,061
877
Edinburgh
sztupy.hu
So this means:

BOOT (bml01) = 01 = 1 = 0.25 MB (bootloader)
PIT (bml02) = 01 = 1 = 0,25 MB (the partition table)
EFS (bml03) = 28 = 40 = 10 MB (imei data and such)
SBL (bml04) = 05 = 5 = 1,25 MB (secondary bootloader)
SBL2 (bml05) = 05 = 5 = 1,25 MB (secondary bootloader backup)
PARAM (bml06) = 14 = 20 = 5 MB (the images shown when something is wrong)
KERNEL (bml07) = 1E = 30 = 7,5 MB (kernel image)
RECOVERY (bml08) = 1E = 30 = 7,5 MB (kernel image backup)
FACTORYFS (bml09) = 47A = 1146 = 286,5 MB (/system)
DBDATA (bml10) = 218 = 536 = 134 MB (/dbdata)
CACHE (bml11) = 8C = 140 = 35 MB (/cache)
MODEM (bml12) = 32 = 50 = 12,5 MB (software for wireless)

total: 501 MB
 
Last edited:
  • Like
Reactions: adfree

RyanZA

Senior Member
Jan 21, 2006
2,023
784
JHB
I think the main cause is that some firmwares simply don't fit in the space reserved for them. Some of the m have larger system, some of them have larger dbdata partitions. Only a guess though, I think I start flashing pit files just for fun...

Not sure how true this can be -- Take 512 vs 513 for example. Newer Eclair roms stopped working on 513, and required 512. However, 513 has a smaller dbdata and larger system than 512. Since we know that a clean rom when flashed has a /dbdata of around 2mb, or 1% or so of available space, it can't be space related.

Must be more to than simple space allocations.

EDIT: And 501MB means we have space left over. Where is it hiding?
 

sztupy

Inactive Recognized Developer
Dec 21, 2008
1,061
877
Edinburgh
sztupy.hu
Not sure how true this can be -- Take 512 vs 513 for example. Newer Eclair roms stopped working on 513, and required 512. However, 513 has a smaller dbdata and larger system than 512. Since we know that a clean rom when flashed has a /dbdata of around 2mb, or 1% or so of available space, it can't be space related.

Must be more to than simple space allocations.

EDIT: And 501MB means we have space left over. Where is it hiding?

Yes, but the flashed dbdata.rfs was probably actually a large partition, that didn't fit into the allocated space.

Yes, the missing 11MB is strange, unless there is a 1MB "safety" gap between two partition (12 partitions = 11 gaps), or some other data.

EDIT: No, dumped BML0, it's only 501MB in length. The missing part might still be some space needed for the BML and STL to work.
 
Last edited:

dillovic

Member
Oct 17, 2010
45
1
Hi. I'm sorry for hijacking this thread but I need professional help from some geniuses (genii) and apparently you guys are firmware gurus.
Once you guys figure out how PIT files work, can you please help me figure out how to force flash Korean firmware onto an international phone without bricking it? The reason why I would like to do this, is because the Korean version has some really nice features for example native call recording (3rd party call recorders have bad quality). I made a thread for it here

Thanks a lot, köszönöm szépen!
 
Last edited:

Richthofen

Senior Member
Jul 13, 2010
387
78
In the land of the blind
Galaxy S I9000 PIT structure:

512.pit

PBL: 256KB (Primitive Bootloader)
PIT: 256KB
EFS: 10240KB (Non Volatile Memory)
SBL(1): 1280KB (Primary)
SBL(2): 1280KB (Backup)
PARAM: 5120KB
KERNEL(1): 7680KB (Primary)
KERNEL(2): 7680KB (Backup)
FACTORYFS: 293376KB
DBDATAFS: 137216KB
CACHE: 35840KB
MODEM: 12800KB

Total: 513024KB

513.pit

PBL: 256KB
PIT: 256KB
EFS: 10240KB
SBL(1): 1280KB
SBL(2): 1280KB
PARAM: 5120KB
KERNEL(1): 7680KB
KERNEL(2): 7680KB
FACTORYFS: 313856KB
DBDATAFS: 116736KB
CACHE: 35840KB
MODEM: 12800KB

Total: 513024KB

803.pit

PBL: 256KB
PIT: 256KB
EFS: 10240KB
SBL(1): 1280KB
SBL(2): 1280KB
PARAM: 5120KB
KERNEL(1): 7680KB
KERNEL(2): 7680KB
FACTORYFS: 303616KB
DBDATAFS: 126976KB
CACHE: 35840KB
MODEM: 12800KB

Total: 513024KB

In case there is backup blocks (e.g SBL and Kernel, Odin flashes them both while executing the flashing process).
 

Richthofen

Senior Member
Jul 13, 2010
387
78
In the land of the blind
Hi. I'm sorry for hijacking this thread but I need professional help from some geniuses (genii) and apparently you guys are firmware gurus.
Once you guys figure out how PIT files work, can you please help me figure out how to force flash Korean firmware onto an international phone without bricking it? The reason why I would like to do this, is because the Korean version has some really nice features for example native call recording (3rd party call recorders have bad quality). I made a thread for it here

Thanks a lot, köszönöm szépen!

Galaxy S M110S is completely different hardware.
All other I9000 variants use Infineon X-Gold 616 baseband (Modem), while M110S uses Qualcomm baseband chip.
 

sztupy

Inactive Recognized Developer
Dec 21, 2008
1,061
877
Edinburgh
sztupy.hu
Made a try modifying the PIT file, to add more space to /dbdata and take away space from /system. I added around 25MB extra space to /dbdata.

Wasn't that hard actually, and I didn't encounter many problems (except the fact that the values are for the bare bml device, from which the stl has an extra 4-10% overhead so instead of the originally planed 35MB I could only spare 25).

If anyone's interested I can upload the modified pit and rom files.

Some remarks / questions:
- If we use the bare BML device instead of the STL I know we lose wear leveling (at least according to the rfs docs from samsung), but can't we use yaffs or similar on those devices? Or what if we (can we?) use cramfs for the /system on the BML, to gain even more space we could use for the /dbdata partition?
- The overhead the STL has seems a bit random to me. /system and /dbdata has a 4% overhead, while /cache a 10% one.
 

hardcore

Senior Member
Sep 12, 2006
3,435
7,992
I'd be careful about resizing the partitions manually. Samsung should have aligned the partitions for best performance.

I'm not sure if its a placebo, but PIT 512 seems faster to me than PIT 803.
 

RyanZA

Senior Member
Jan 21, 2006
2,023
784
JHB
I'd be careful about resizing the partitions manually. Samsung should have aligned the partitions for best performance.

I'm not sure if its a placebo, but PIT 512 seems faster to me than PIT 803.

Aligning should not be terribly hard -- we already specify using 256kb pieces instead of raw bytes. The alignment therefore is somewhere between 256kb and 4mb. If we align for 4mb, we align for everything smaller too. So as long as the numbers used are cleanly divisible by 4*4=16, it will be correctly aligned.

Flashing a PIT file with repartition checked seems to (according to docs) reset the wear leveling (the current record of what was written where, I guess), so you should not tick repartition if you are flashing many times in a row. (Many times is probably some very big number.)

I can't see why we couldn't use YAFFS or similar filesystem. Might work really well. I've got no experience setting up YAFFS though, and I don't believe it is trivial.
 

vitalij

Senior Member
Jun 14, 2010
253
236
Kaunas
Aligning should not be terribly hard -- we already specify using 256kb pieces instead of raw bytes. The alignment therefore is somewhere between 256kb and 4mb. If we align for 4mb, we align for everything smaller too. So as long as the numbers used are cleanly divisible by 4*4=16, it will be correctly aligned.

Flashing a PIT file with repartition checked seems to (according to docs) reset the wear leveling (the current record of what was written where, I guess), so you should not tick repartition if you are flashing many times in a row. (Many times is probably some very big number.)

I can't see why we couldn't use YAFFS or similar filesystem. Might work really well. I've got no experience setting up YAFFS though, and I don't believe it is trivial.

I wonder if it is possible to make very small /system partition, and move it to mmcblk0 - since it is read only, performance will be ok. And make large dbdata partition, and keep /data/data there. That may be the ultimate lag fix :)

Sent from my GT-I9000 using XDA App
 

RyanZA

Senior Member
Jan 21, 2006
2,023
784
JHB
I wonder if it is possible to make very small /system partition, and move it to mmcblk0 - since it is read only, performance will be ok. And make large dbdata partition, and keep /data/data there. That may be the ultimate lag fix :)

Sent from my GT-I9000 using XDA App

It is possible, but how would you flash a firmware then?
We are quickly approaching the 'throw it all away, and start from scratch with our own tools and bootloader. :D
 

fane1

Senior Member
Dec 8, 2008
315
36
It is possible, but how would you flash a firmware then?
We are quickly approaching the 'throw it all away, and start from scratch with our own tools and bootloader. :D

So are u guys planning to release the new galaxy s series phone?? :D:D
You should rename it to galaxy-xda :)
 

huxflux2003

Senior Member
Dec 29, 2008
405
6
So, from the info you have gathered, is there any point in using a PIT file when repartition is not checked?
 

dupel

Senior Member
Jun 2, 2010
1,394
23
London
So, from the info you have gathered, is there any point in using a PIT file when repartition is not checked?

I don't really see much point, but than again PIT file will tell odin (if your flashing pda) explicitly where the kernel should be flashed.

Also, I noticed that kernel partition is only 7.5-6 mb. Doest it mean that we cant use larger kernels (cos I think voodoo might me larger - hence the screen tear on boot).
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 4
    The PIT data structures can easily be transformed into C data-structures. Attached are 512/513/803 PIT files as C source. Also included are the commands needed to create them.

    It seems that the first partition entry contains noise as if the structure was not properly zeroed before being populated.

    The second partition contains the PIT file itself, making the flash as a whole self-describing.

    It is worthwhile to note that the number of partition entries is configurable, and given the amount of free space available it would seem relative easy to have a dual/multi boot system.
    1
    There is very little technical information on PIT files , so this thread is an attempt to find out some real details about PIT files, and perhaps eventually be able to create our own PIT files (by modifying Samsung ones, probably).

    First, what we think we know PIT files do:

    - PIT files only affect the 'STL' devices. That is, it affects the OneNAND and not the MoviNAND.
    - PIT files appear to control the sizing (and maybe number) of STL devices that appear in Linux.
    - PIT files appear to be used by Odin to map filenames inside .tar archives to STL partitions.


    STL files are quite small, at under 2KB in size. Most of the file is made up of 0s. I have tried to compare the differences between the 512 513 and 803 PIT files we have available.

    All the PIT files start with 76 98 34 12 0D - probably a signature to show it is a PIT file.

    [Unimportant]

    The 803 PIT file then has 00s all the way to the next common point. The 512 and 513 both have common data till the next common point - but this can't be too important as the 803 just has 00s.

    The next common bit seems to read the following:
    "oft IBL+PBL Server\90\To boot.bin inn; C:\Program Files\ESTsof
    This probably indicates something to Odin. Strange that it has C:\Program Files\ - build path for the PIT file?

    Next we have some 0s with common 1s inside them, followed by the word PIT, then more 0s, and then ries.pit. All common from here on with the words 'EFS' and 'efs.rfs'. Probably telling odin to map the efs.rfs file to the 'EFS' token. Tokens probably defined either in the kernel, or in the closed source STL library. More of the same of this, with 'SBL' 'sbl.bin', 'SBL2' 'sbl.bin' -- Both SBL and SBL2 map to the same sbl.bin file?

    'PARAM' to 'param.lfs'
    'KERNEL' to 'zImage'
    'RECOVERY' to 'zImage' (this one is interesting - could we have seperate zImage and recovery? Could save some RAM here!)

    [/Unimportant]

    And now we'r onto the actual changes between the PIT files. 'FACTORYFS' maps to 'factoryfs.rfs'. However, before the FACTORYFS token, there are some bytes that likely control the partition sizes.

    FACTORYFS
    803 : A2 04 : 41476
    512 : 7A 04 : 31236
    513 : CA 04 : 51716

    DBDATA
    803 : F0 01 : 61441
    512 : 18 02 : 6146
    513 : C8 01 : 51201

    CACHE
    803 : 8C
    512 : 8C
    513 : 8C

    MODEM
    803 : 32
    512 : 32
    513 : 32

    So there we have it. The only real changes between the PIT files are some seemingly garbage header information in 512/513 that is missing from 803, and FACTORYFS and DBDATA have different numbers -- probably sizes.

    So assuming FACTORYFS maps onto /system, we can see that the only differences in the PIT files is moving space back and forwards between /dbdata and /system. The numbers themselves don't mean anything to me - can anybody work it out? :D
    1
    Nice, that gives us

    FACTORYFS
    803 : 04 A2 : 1186
    512 : 04 7A : 1146
    513 : 04 CA : 1226

    DBDATA
    803 : 01 F0 : 496
    512 : 02 18 : 536
    513 : 01 C8 : 456

    1186+496=1682
    1146+536=1682
    1226+456=1682

    So we have a match. :)
    Now to work out why the fat.format can work with 536, but not with 496

    EDIT: Also, need to determine why some roms require certain PIT files. Only possibility I can see is that junk in the header - could be some type of allow list for firmwares. The 803 PIT should therefore work on all firmwares, since it just has 00s. Maybe. :)

    I think the main cause is that some firmwares simply don't fit in the space reserved for them. Some of the m have larger system, some of them have larger dbdata partitions. Only a guess though, I think I start flashing pit files just for fun...
    1
    In 803.pit (compared to the .512 one) the system partition size has been increased by 10MB, while DBDATA partition size has been decreased the same amount (10MB).

    Hope this helps :)

    10MB = 40 units... That would give us 1 unit = 256kbyte. Nice.
    1
    So this means:

    BOOT (bml01) = 01 = 1 = 0.25 MB (bootloader)
    PIT (bml02) = 01 = 1 = 0,25 MB (the partition table)
    EFS (bml03) = 28 = 40 = 10 MB (imei data and such)
    SBL (bml04) = 05 = 5 = 1,25 MB (secondary bootloader)
    SBL2 (bml05) = 05 = 5 = 1,25 MB (secondary bootloader backup)
    PARAM (bml06) = 14 = 20 = 5 MB (the images shown when something is wrong)
    KERNEL (bml07) = 1E = 30 = 7,5 MB (kernel image)
    RECOVERY (bml08) = 1E = 30 = 7,5 MB (kernel image backup)
    FACTORYFS (bml09) = 47A = 1146 = 286,5 MB (/system)
    DBDATA (bml10) = 218 = 536 = 134 MB (/dbdata)
    CACHE (bml11) = 8C = 140 = 35 MB (/cache)
    MODEM (bml12) = 32 = 50 = 12,5 MB (software for wireless)

    total: 501 MB