[Galaxy S 4 i9506 Android Development] DeHAWK:
Reserved

PIT file backup/restore etc.

In here you will learn how to backup/restore your PIT file and other VERY important files.

But first some information.

I've made a lot of research on this subject, mostly because I received a lot of PM's regarding corrupted pit files when trying to flash original or other custom firmware using Odin, but most of these people could use a custom recovery to flash.

Regarding all of this information: I've obtained it by browsing the internet, my own experience by experimenting and not to forget: The Galaxy S5 forum here on xda.

Before we start I'll explain a little about how the partition table is made. This information could be wrong, but I'm pretty sure this how it works.

All this information here is for the GT-I9506, 16GB model, NOT carrier locked. But it'll probably be almost the same on carrier locked phones.

You should look at your phones RAM as a HD on an PC.

In e.g. Windows, you can set up different partitions on your HD; name, size, file system etc. All this information is then stored in a so called partition table.

If your partition table gets screwed up, you'll no longer be able to access your HD's. Therefore I always keep a copy of my PC’s partition tables stored in a safe place. When Windows stars, if looks at the partition table what to mount, from what partition to boot etc. If no partition table can be found...Windows just don't boot, but will return with an error.

The Samsung PIT file works a little the same. BUT here, even if the partition table gets screwed up, you'll still, in most cases, be able to boot and use the phone.

But when trying to flash a new firmware using Odin...it will fail and give you an error. Why??? - Continue reading and you will soon know why.

In the PIT file all the mount points are defined and what file to flash on what partition..here's an example:

In the original firmware we find a lot of files, these files refers to partitions; modem.bin, file refers to a partition called MODEM. Logical!

But now look at this; NON-HLOS.bin, it refers to a partition named APNHLOS, logical? - NO.

Or this one: sdi.mbn, it refers to a partition named DBI, logical? -NO.

So how does Odin know what files to put where? - Well, actually it doesn't. - But the bootloader does, because it looks at the partition table (the PIT file) and then kindly tells Odin.

So what is a PIT File?

The PIT files contain the Partition Information Table (PIT) for your phone. Different firmware versions may require different partition layouts so the necessary PIT file 'tells' Odin how to set up the phone partitions correctly for the specified firmware to be installed.

The PIT file contains all the relevant information for each required partition such as Partition Name, Flash File Name, Block Size, Block Count etc. and also contains some unknown properties that could be identifiers or flags of some sort.

The functions and contents of many of these partitions are not very well described, nor easily found in one place. Further down are some further details, that apply primarily to our Qualcomm Snapdragon S4+ based Android devices.

But first let's have a look at the partition table in our phone.

Below you can see how our 16GB international GT-I9506 model is partitionered

Notice: The mmcblk0 is the whole 16GB RAM.

The mmcblk0pX is the the actual partition number placed on this 16GB RAM. All these partition names are defined in the PIT file, not by numbers but by names. Looking at the PIT file, with a HEX editor, reveals all these partions and their corrospondig flash file names, but it's also reveals some unknown partitions, not pointing to any mmcblks.

mmcblck number

----------

Partition name

--------

Odin flash file name

/dev/block/mmcblk0 -----> PIT file lays here! -------> MSM8974.pit

/dev/block/mmcblk0p1 ---> APNHLOS --------------> NON-HLOS.bin

/dev/block/mmcblk0p2 ---> MODEM ---------------> modem.bin

/dev/block/mmcblk0p3 ---> SBL1 --------------------> sbl1.mbn

/dev/block/mmcblk0p4 ---> DBI ---------------------> sdi.mbn

/dev/block/mmcblk0p5 ---> DDR --------------------> NOT used by Odin!

/dev/block/mmcblk0p6 ---> ABOOT -----------------> aboot.mbn

/dev/block/mmcblk0p7 ---> RPM --------------------> rpm.mbn

/dev/block/mmcblk0p8 ---> TZ ----------------------> tz.mbn

/dev/block/mmcblk0p9 ---> PAD --------------------> NOT used by Odin!

/dev/block/mmcblk0p10 --> PARAM ----------------> param.bin

/dev/block/mmcblk0p11 --> EFS ----------------------> efs.img.ext4

/dev/block/mmcblk0p12 --> MODEMST1 ------------> nvrebuild1.bin

/dev/block/mmcblk0p13 --> MODEMST2 ------------> nvrebuild2.bin

/dev/block/mmcblk0p14 --> BOOT -------------------> boot.img

/dev/block/mmcblk0p15 --> RECOVERY -------------> recovery.img

/dev/block/mmcblk0p16 --> FOTA -------------------> NOT used by Odin!

/dev/block/mmcblk0p17 --> BACKUP ----------------> NOT used by Odin!

/dev/block/mmcblk0p18 --> FSG ---------------------> NOT used by Odin!

/dev/block/mmcblk0p19 --> FSC ---------------------> NOT used by Odin!

/dev/block/mmcblk0p20 --> SSD --------------------> NOT used by Odin!

/dev/block/mmcblk0p21 --> PERSIST ----------------> persist.img.ext4

/dev/block/mmcblk0p22 --> PERSDATA ------------> persdata.img.ext4

/dev/block/mmcblk0p23 --> SYSTEM ---------------> system.img.ext4

/dev/block/mmcblk0p24 --> CACHE ----------------> cache.img.ext4

/dev/block/mmcblk0p25 --> HIDDEN ---------------> hidden.img.ext4

/dev/block/mmcblk0p26 --> USERDATA -----------> userdata.img.ext4

If your phone is rooted and have Busybox installed, you can try open a terminal and type in the following command:

ls -al /dev/block/platform/msm_sdcc.1/by-name

This will show you mostly the same as I wrote above.

Further partition information I've found out.

ABOOT: This is the bootloader. I'll add more information about this later.

BACKUP: This partition should contain a copy of MODEMST2. Whether it does or not, is described in the PARAM partition.

BOOT: This is the partition that enables the phone to boot, as the name suggests. It includes the kernel and the ramdisk. Without this partition, the device will simply not be able to boot. Wiping this partition from recovery should only be done if absolutely required and once done, the device must NOT be rebooted before installing a new one, which can be done by installing a ROM that includes a /boot partition.

CACHE: Contain the firmware update package which is downloaded from server, and the recovery log file. Other uses include storage for frequently accessed data and application components. Wiping the cache doesn’t effect your personal

data but simply gets rid of the existing data there, which gets automatically rebuilt as you continue using the device.

DATA / USERDATA: This partition contains the user's data – this is where your contacts, messages, settings and apps that you have installed go. Wiping this partition essentially performs a factory reset on your device, restoring it to the way it was when you first booted it, or the way it was after the last official or custom ROM installation. When you perform a wipe data/factory reset from recovery, it is this partition that you are wiping.

EFS: The EFS partition stores all your phones important, but accessible, hardware data, such as WiFi/BlueTooth MAC's, IMEI and some others.

FOTA: Is the Firmware Over The Air partition. After the update package has been downloaded from the server it is saved into the CACHE partition. After that the userspace application that does the download writes a special cookie into the FOTA partition. This cookie tells the bootloaders to take the necessary steps to boot into recovery mode

FSC: << unknown at time of writing >>

FSG: Probably stands for File System (FS) "Golden". According to Samsung documentation, this partition is a "Golden Copy". This is partially confirmed by RE of the PARAM partition, which indicate that this partition should contain a copy of MODEMST1.

MISC: Not found on my phone, but his partition contains miscellaneous system settings in form of on/off switches. These settings may include CID (Carrier or Region ID), USB configuration and certain hardware settings etc. This is an important

partition and if gets corruped or is missing, several of the phone’s features will will not function normally. Not all devices have this partition.

MODEMST1: << Still researching on this one >>

MODEMST2: << Still researching on this one >>

PARAM: This is the Parameter partition which contains a number of parameters, variables and settings of the hardware. Apparently it has an 88 byte header structure that tell us if the MODEMST1 and MODEMST2 have been backed up to the FSG and BACKUP partitions, respectively. Furthermore it contain all the debug settings (DLOW/DMID/DHIG etc), the "triangle" status of whether or not you have flashed custom ROMs and the flash count (). Current boot mode in use, and much more. The info about this partition could easily occupy a book by itself.

PERSIST: << unknown >> The use of this partition is unknown and apparently only exists on Qualcomm based devices.

PIT: Already described.

RECOVERY: Holds the recovery boot image. When updating the system we boot into recovery mode by using the boot image stored in this partition. It lets you boot the device into a recovery console for performing advanced recovery and maintenance operations on it.

SSD: "Secure Software Download" is a memory based file system (RAMFS) for secure storage, used to download and store "who knows what" on the eMMC. It is a referenced part in the Remote Storage RPC Client of the MSM kernel.

SYSTEM: This partition basically contains the entire operating system, other than the kernel and the ramdisk. This includes the Android user interface as well as all the system applications that come pre-installed on the device. Wiping this partition will remove Android from the device without rendering it unbootable, and you will still be able to put the phone into recovery or bootloader mode to install a new ROM.

TZ: << unknown at time of writing>>

To be continued!