Flashing

Understanding the Flash memory

There are two common types of flash memory partitions: mtd and mmc. This will let you determine the buildup of the rom in flash memory.

mount - show mounted partitions

cat /proc/devices - device major number

cat /proc/partitions- disk device major and minor number and name

cat /proc/mtd

cat /proc/emmc

Flashing a part of the ROM using CWM Recovery

Sometimes you don't want to flash the whole ROM but only a part, lets say the kernel (boot.img). When you have CWM Recovery installed you can easily do it with that in recovery mode.

From your PC:

  • adb recovery

  • adb put boot.img /sdcard (don't mount it, unmounted it is just a part of the recovery root)

  • adb shell

  • /sbin/flash_image boot /sdcard/boot.img

  • reboot

Flashing a part of the ROM using fastboot.exe (bootloader)

If your device supports a fastboot mode (bootloader) you can use fastboot.exe from your PC.

If your device is not bricked you can use the adb reboot bootloader command to put your device into the fastboot mode. On a "bricked" device it is usually something like push and hold a button during boot or push and hold a paperclip in the hole. If in fastboot mode you will see a RK30SDK or similar device in your Windows hardware tree. It requires other USB drivers then regular adb.

Fastboot is a Windows utility. All commands are done from the pc and are similar to that of the unix flash_image tool described earlier.

example: fastboot flash system system.img

Flashing Samsung (ODIN)

The flashtool ODIN is only for Samsung devices. You can flash the whole ROM using the tar.md5 file that you download for example from SamMobile.

But you can also flash only parts of the rom like boot.img. For that you need to pack the boot.img into a boot.tar file. DON'T rename the original img file.

Example: tar cvf boot.tar boot.img

An example of Samsung flash partitions on a phone:

mmcblk0p1: 000014 000000 "qcsblhd_cfgdata"

mmcblk0p2: 0000af 000000 "qcsbl"

mmcblk0p3: 005000 000000 "emmc"

mmcblk0p4: 000001 000000 "ebr"

mmcblk0p5: 0003e8 000000 "oemsbl"

mmcblk0p6: 0003e8 000000 "appsbl"

mmcblk0p7: 0007d0 000000 "ssd"

mmcblk0p8: 003000 000000 "boot"

mmcblk0p9: 000c00 000000 "modemst1"

mmcblk0p10: 000c00 000000 "modemst2"

mmcblk0p11: 001000 000000 "modembkp"

mmcblk0p12: 002000 000000 "persist"

mmcblk0p13: 003000 000000 "recovery"

mmcblk0p14: 001000 000000 "param"

mmcblk0p15: 001000 000000 "secure"

mmcblk0p16: 003000 000000 "efs"

mmcblk0p17: 006000 000000 "img_backup"

mmcblk0p18: 001000 000000 "misc"

mmcblk0p19: 000200 000000 "pit"

mmcblk0p20: 000800 000000 "md5"

mmcblk0p21: 145000 000000 "system"

mmcblk0p22: 0b4000 000000 "cache"

mmcblk0p23: 050000 000000 "hidden"

mmcblk0p24: 4e0e60 000000 "userdata"

pit contains the partition mapping (names, start address and sizes) in flash memory. (Partition Information Table)

md5 contains the checksum for each partition. If you flash a custom partition (like boot.tar or recovery.tar) you will see a yellow triangle or red exclamation mark icon the top left corner of your screen during normal boot or recovery.

Put your device in flash mode: boot it while holding the VOLUME DOWN and HOME BUTTON simultaneously. You must install the proper Samsung driver.

Start ODIN and check if it sees your phone on a com port. Don't mess with the default options!

Select the file you just created or complete ROM by clicking on the PDA button. Then click start. Never interrupt the process!

Flashing Mediatek (MTK Droid Tools / SP Flash Tool)

Mediatek devices can be flashed using the Smart Phone Flash Tool. It requires a "scatter" file, a file with the ROM layout in the device flash memory. It has names and start addresses with sizes for each Flash partition. The SP Flash Tool can also make backups of your current Flash content. Again you need the proper scatter file.

Turn off your Mediatek phone while connected to your PC with USB. You will need to install the Mediatek Preloader USB VCOM driver now.

The MTK Droid Tools to create scatter file can be downloaded here.

More information about how to use MTK Droid Tools here on xda.

Some handy tools to extract ROM images:

image unpack tools cmd line utils for unpacking roms (used in ROM Kitchens below)

Ext4 File explorer Windows program for extract files from ext4 partitions IMG files

Carliv Image Kitchen CMD menu app for (un-)pack BOOT.IMG (kernel) / RECOVERY.IMG also for MTK

Ricky ROM Kitchen CMD menu app for (un-)pack ROM and APK-JAR workshop