Recovery系统包含了很多钩子程序,因此OAT更新除了可以更新Android系统也可以更新设备的其他部分。(如基带、无线电处理器)。
分区映射
从Android2.3起,平台开始支持eMMC存储设备和ext4文件系统。它同样支持MTD设备和yaffs2文件系统。
分区映射文件TARGET_RECOVERY_FSTAB一般会被recovery二进制程序和打包工具所使用,我们可以在BoardConfig.mk文件中配置映射文件的文件名为TARGET_RECOVERY_FSTAB。
下面是一个简单的分区映射文件结构。
device/yoyodyne/tardis/recovery.fstab
# mount point fstype device [device2] [options (3.0+ only)]
/sdcard vfat /dev/block/mmcblk0p1 /dev/block/mmcblk0
/cache yaffs2 cache
/misc m td misc
/boot mtd boot
/recovery emmc /dev/block/platform/s3c-sdhci.0/by-name/recovery
/system ext4 /dev/block/platform/s3c-sdhci.0/by-name/system length=-4096
/data ext4 /dev/block/platform/s3c-sdhci.0/by-name/userdata
在上面的分区映射文件中,/sdcard是个例外,因为在这里它是可选的。除了/sdcard,例子中所有的挂载点必须被定义。这例子中我们看到有五种文件系统类型,如下:
yaffs2
YAFFS(Yet Another Flash File System)是由Aleph One公司所发展出来的NAND flash 嵌入式文件系统。 因此yaffs2文件系统只能使用在MTD存储设备上。 "device" 必须是MTD分区的名字。而且必须在/proc/mtd中配置。
mtd
一个原始的mtd分区常被用于bootale分区,如boot分区和recovery分区。mtd不一定被挂载,但是挂载点常被用于一个key来查找分区。 "device" 必须是mtd分区的名字。而且必须在/proc/mtd中配置。
ext4
ext4文件系统常备用于emmc存储设备。“device”必须是块设备的路径。
emmc
一个原始的eMMC块设备,常常被用于bootable分区如boot分区和recovery分区,因此比较与mtd类型比较类似。eMMC从来没有被挂载,但是挂载点eMMc 习惯被用来在分区表中查找设备。
vfat
Vfat是一个FAT文件系统,被用于块设备中。这里通常指外设存储设备如SD卡。Device是块设备,device2是第二个块设备。如果第一个块设备挂在失败的情况下,会选择挂在第二个块设备。
所有的分区必须被挂载在根目录下。(例如挂载点的值必须是以斜线开始,而不能再有多余的斜线。这条原则仅仅应用于recovery中。主系统可以自由挂载在任何地方。 /boot, /recovery, 和/misc 目录必须是原始类型,(如:mtd或emmc), 二 /system, /data, /cache, 和/sdcard (如果可用) 应该是文件系统类型 如(yaffs2, ext4, 或 vfat).
从Android3.0版本开始recovery的.fastb文件增加了一个扩展项。一般仅仅用来指定分区的长度。
原文如下:
The recovery system includes several hooks for inserting device-specific code so that OTA updates can also update parts of the device other than the Android system (e.g., the baseband or radio processor).
The following sections and examples customize the tardis device produced by the yoyodyne vendor.
Partition map
As of Android 2.3, the platform supports eMMC flash devices and the ext4 filesystem that runs on those devices. It also supports Memory Technology Device (MTD) flash devices and the yaffs2 filesystem from older releases.
The partition map file is specified by TARGET_RECOVERY_FSTAB; this file is used by both the recovery binary and the package-building tools. You can specify the name of the map file in TARGET_RECOVERY_FSTAB in BoardConfig.mk.
A sample partition map file might look like this:
device/yoyodyne/tardis/recovery.fstab
<span class="com" style="word-wrap: break-word; color: rgb(136, 0, 0);"># mount point fstype device [device2] [options (3.0+ only)]</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);"> </span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">sdcard vfat </span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">dev</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">block</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">mmcblk0p1 </span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">dev</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">block</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">mmcblk0 </span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">cache yaffs2 cache </span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">misc mtd misc </span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">boot mtd boot </span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">recovery emmc </span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">dev</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">block</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">platform</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">s3c</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">-</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">sdhci</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">.</span><span class="lit" style="word-wrap: break-word; color: rgb(0, 102, 102);">0</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="kwd" style="word-wrap: break-word; color: rgb(0, 0, 136);">by</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">-</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">name</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">recovery </span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">system ext4 </span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">dev</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">block</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">platform</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">s3c</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">-</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">sdhci</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">.</span><span class="lit" style="word-wrap: break-word; color: rgb(0, 102, 102);">0</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="kwd" style="word-wrap: break-word; color: rgb(0, 0, 136);">by</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">-</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">name</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">system length</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">=-</span><span class="lit" style="word-wrap: break-word; color: rgb(0, 102, 102);">4096</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);"> </span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">data ext4 </span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">dev</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">block</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">platform</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">s3c</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">-</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">sdhci</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">.</span><span class="lit" style="word-wrap: break-word; color: rgb(0, 102, 102);">0</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="kwd" style="word-wrap: break-word; color: rgb(0, 0, 136);">by</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">-</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">name</span><span class="pun" style="word-wrap: break-word; color: rgb(102, 102, 0);">/</span><span class="pln" style="word-wrap: break-word; color: rgb(0, 0, 0);">userdata</span>
With the exception of /sdcard, which is optional, all mount points in this example must be defined (devices may also add extra partitions). There are five supported filesystem types:
yaffs2 A yaffs2 filesystem atop an MTD flash device. "device" must be the name of the MTD partition and must appear in /proc/mtd. mtd A raw MTD partition, used for bootable partitions such as boot and recovery. MTD is not actually mounted, but the mount point is used as a key to locate the partition. "device" must be the name of the MTD partition in/proc/mtd. ext4 An ext4 filesystem atop an eMMC flash device. "device" must be the path of the block device. emmc A raw eMMC block device, used for bootable partitions such as boot and recovery. Similar to the mtd type, eMMc is never actually mounted, but the mount point string is used to locate the device in the table. vfat A FAT filesystem atop a block device, typically for external storage such as an SD card. The device is the block device; device2 is a second block device the system attempts to mount if mounting the primary device fails (for compatibility with SD cards which may or may not be formatted with a partition table).All partitions must be mounted in the root directory (i.e. the mount point value must begin with a slash and have no other slashes). This restriction applies only to mounting filesystems in recovery; the main system is free to mount them anywhere. The directories /boot, /recovery, and /misc should be raw types (mtd or emmc), while the directories /system, /data, /cache, and /sdcard (if available) should be filesystem types (yaffs2, ext4, or vfat).
Starting in Android 3.0, the recovery.fstab file gains an additional optional field, options. Currently the only defined option is length , which lets you explicitly specify the length of the partition. This length is used when reformatting the partition (e.g., for the userdata partition during a data wipe/factory reset operation, or for the system partition during installation of a full OTA package). If the length value is negative, then the size to format is taken by adding the length value to the true partition size. For instance, setting "length=-16384" means the last 16k of that partition will not be overwritten when that partition is reformatted. This supports features such as encryption of the userdata partition (where encryption metadata is stored at the end of the partition that should not be overwritten).
Note: The device2 and options fields are optional, creating ambiguity in parsing. If the entry in the fourth field on the line begins with a ‘/' character, it is considered a device2 entry; if the entry does not begin with a ‘/' character, it is considered an options field.