关于BOARD_SYSTEMIMAGE_PARTITION_SIZE【转】
本文转载自:https://blog.csdn.net/ttxgz/article/details/7542380
1. 系统需要,把需要预置在系统的所有apk放在目录 device/softwinner/crane-gm-g9/pre/下,在编译android源码时,出现下面错误:
1 make_ext4fs -l 268435456 -a system out/target/product/Mary/system.img.ext4 out/target/product/Mary/system
2 Creating filesystem with parameters:
3 Size: 167772160
4 Block size: 4096
5 Blocks per group: 32768
6 Inodes per group: 5120
7 Inode size: 256
8 Journal blocks: 1024
9 Label:
10 Blocks: 40960
11 Block groups: 2
12 Reserved block group size: 15
13 error: do_inode_allocate_extents: Failed to allocate 119 blocks
14
15 make: *** [out/target/product/Mary/obj/PACKAGING/systemimage_intermediates/system.img] 错误 4
16 make: *** 正在删除文件“out/target/product/Mary/obj/PACKAGING/systemimage_intermediates/system.img”
这个错误是由于增加了预置apk,导致system.img超过了分配的空间大小导致的。
修改device/softwinner/crane-gm-g9/BoardConfig.mk里BOARD_SYSTEMIMAGE_PARTITION_SIZE的大小为536870912,即把.img的文件大小从256M扩展为512M。在我们系统里,除了要修改此处,还要修改打包配置文件:lichee3.0/tools/pack/chips/sun4i/configs/crane/gm-g9/sys_config.fex把partition user/data的空间缩小,把system的空间开大(打包系统以后再记录)。
2. 为什么把apk放在目录device/softwinner/crane-gm-g9/pre/下就能把apk预置到系统呢?
首先看一下device/softwinner/crane-gm-g9/下面的几个mk文件:
AndroidBoard.mk
只定义了LOCAL_PATH, 为当前目录 device/softwinner/crane-gm-g9
crane-gm-g9.mk
定义宏PRODUCT_COPY_FILES, 加上了很多idc, rle, fstab,xml,init.rc等文件,也包含了当前目录下的所有apk;
-> 调用 find-copy-subdir-files(), 生成copy file的语义,而查看build/core/product_config.mk, 宏的定义如下:
find $(2) -name "$(1)" | $(SED_EXTENDED) "s:($(2)/?(.*)):\\1\\:$(3)/\\2:" | sed "s://:/:g"
举个例子,例如:
PRODUCT_COPY_FILES += $(call find-copy-subdir-files, *.apk, *(LOCAL_PATH)/pre, system/preinstall)
如果device/softwinner/crane-gm-g9/pre下有a.apk,b.apk,那么上述调用等价于:
PRODUCT_COPY_FILES += device/softwinner/crane-gm-g9/a.apk:system/preinstall/a.apk \
device/softwinner/crane-gm-g9/b.apk:system/preinstall/b.apk
所以,PRODUCT_COPY_FILES是定义了所有需要copy到生成系统时需要copy的文件。把预置的apk放在device/softwinner/crane-gm-g9/pre/,相当于把apk放在生成系统的system/preinstall下。
定义宏PRODUCT_PROPERTY_OVERRIDES, 定义了语言,区域等persist的内容
BoardConfig.mk
硬件和kernel相关的宏,例如CMDLINE,SYSTEMIMAGE_PARTITION_SIZE, sensor, wifi, gps, kernel base等设置
AndroidProducts.mk
定义宏 PRODUCT_MAKEFILES为crane_gm_g9.mk
3.BOARD_SYSTEMIMAGE_PARTITION_SIZE在哪里起作用呢?
在 build/core/Makefile里有下面一段:
ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
## generate an ext image
# $(1): output file
define build-systemimage-target
@echo "Target system fs image: $(1)"
$(call build-userimage-ext-target,$(TARGET_OUT),$(1),system,$(INTERNAL_USERIMAGES_EXT_VARIANT),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
endef
else # INTERNAL_USERIMAGES_USE_EXT != true
## generate a yaffs2 image
# $(1): output file
define build-systemimage-target
@echo "Target system fs image: $(1)"
@mkdir -p $(dir $(1))
$(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT) $(1)
endef
endif # INTERNAL_USERIMAGES_USE_EXT
$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
$(call build-systemimage-target,$@)
INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
由上面代码可知,当需要生成ext格式的img时,会读入这个宏变量来生成system.img,否则生成yaffs2文件。