平台:Freescale / Android 4.2.2
问题描述:
用 df 命令,看到/system分区大小275M。
用 busybox fdisk -l /dev/block/mmcblk0p5,看到 536M。
Freescale的刷机工具是Mfgtool,分区的动作在mksdcard-android.sh里面完成。
SYSTEM_ROM_SIZE=512 dd if=/dev/zero of=${node} bs=1024 count=1 sfdisk --force -uM ${node} << EOF ,${boot_rom_sizeb},83 ,${RECOVERY_ROM_SIZE},83 ,${extend_size},5 ,${data_size},83 ,${SYSTEM_ROM_SIZE},83 ,${CACHE_SIZE},83 ,${VENDER_SIZE},83 ,${MISC_SIZE},83 EOF
注: dd 命令
格式:起始,大小,ID
起始 = 起始柱面(如果不进行指定则为第一可用柱面),大小 = 柱面数量(如果不进行指定则指所有柱面),ID号 = 分区类型(L: Linux, S: Swap, E:扩展分区)
Mfgtool的配置文件是ucl2.xml
其中,刷System.img的命令是:
<CMD state="Updater" type="push" body="pipe dd of=/dev/mmcblk0p5 bs=512" file="files/android/system.img">Sending and writting system.img</CMD>
可以看到,这边使用了 dd 命令,blocksize是512byte,将system.img拷贝到了/dev/mmcblk0p5分区。
但是,dd 命令的会改变分区的大小,改变后的分区大小就是system.img文件的实际大小。
所以,使用 df 命令会看到 275M。
解决方式:
修改 device/fsl/imx6/BoardConfigCommon.mk :
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 524288000
BOARD_SYSTEMIMAGE_PARTITION_SIZE 会在 build/core/Makefile 中使用到:
define build-systemimage-target @echo "Target system fs image: $(1)" @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt $(call generate-userimage-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt) $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH ./build/tools/releasetools/build_image.py $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) endef
generate-userimage-prop-dictionary 方法会对 system_image_info.txt 赋值:
define generate-userimage-prop-dictionary $(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1)) $(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1)) $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1)) $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1)) $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1)) $(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1)) $(if $(mkyaffs2_extra_flags),$(hide) echo "mkyaffs2_extra_flags=$(mkyaffs2_extra_flags)" >> $(1)) $(if $(TARGET_MKUBIFS_ARGS),$(hide) echo "mkfsubifs_flags=$(TARGET_MKUBIFS_ARGS)" >> $(1)) $(if $(filter true, $(strip $(HAVE_SELINUX))), echo "selinux_fc=$(TARGET_ROOT_OUT)/file_contexts" >> $(1)) endef
关键词汇是:system_size
随后调用了./build/tools/releasetools/build_image.py,传入的参数就是system_image_info.txt:
if mount_point == "system": copy_prop("fs_type", "fs_type") copy_prop("system_size", "partition_size") ...... ...... if fs_type.startswith("ext"): build_command = ["mkuserimg.sh"] if "extfs_sparse_flag" in prop_dict: build_command.append(prop_dict["extfs_sparse_flag"]) run_fsck = True build_command.extend([in_dir, out_file, fs_type, prop_dict["mount_point"]]) if "partition_size" in prop_dict: build_command.append(prop_dict["partition_size"]) if "selinux_fc" in prop_dict: build_command.append(prop_dict["selinux_fc"]) exit_code = RunCommand(build_command)
转来转去又调用了 mkuserimg.sh,记住 partition_size 是作为第五个参数传进去的:
OUTPUT_FILE=$2 EXT_VARIANT=$3 MOUNT_POINT=$4 SIZE=$5 FC=$6 MAKE_EXT4FS_CMD="make_ext4fs $ENABLE_SPARSE_IMAGE $FCOPT -l $SIZE -a $MOUNT_POINT $OUTPUT_FILE $SRC_DIR"
终于看到核心了,使用了make_ext4fs来制作img了。
Android System分区大小异常