AndroidQ动态分区super.img相关初步整理
Android 10上刷机使⽤了super.img,差分包多了dynamic_partitions_op_list,⼤致查询了下是新增了动态分区,从编译到⽣成差分包都做了⼀些修改,本次先整理⼤致分析,对这个更新点有初步的认识
⼀、编译⽅⾯
1.super.img的⽣成
通过编译的log可以看到,super.img的⽣成
make
build/make/core/Makefile
# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
# virtual devices.
ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
$(call pretty,"Target super fs image for debug: $@")
$(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
$(call intermediates-dir-for,PACKAGING,superimage_debug)/)
编译log
[100% 1686/1686] Target super fs image for debug: out/target/product/k61v1_64_bsp/super.img
2020-01-06 16:14:22 - build_super_image.py - INFO : Building super image from
2020-01-06 16:14:22 - sparse_img.py - INFO : Total of 370303 4096-byte output blocks in 21 input chunks.
2020-01-06 16:14:22 - sparse_img.py - INFO : Total of 383438 4096-byte output blocks in 19 input chunks.
2020-01-06 16:14:22 - sparse_img.py - INFO : Total of 83534 4096-byte output blocks in 11 input chunks.
2020-01-06 16:14:22 - common.py - INFO : Running: "lpmake --metadata-size 65536 --super-name super --metadata-slots 2 --device super:4294967296 --group main:4292870144 --partition product:readonly:1516761088:main --image product=out/target/product/k61v1_64_bsp/product.img --partition system:readonly:1570562048:main --image
system=out/target/product/k61v1_64_bsp/system.img --partition vendor:readonly:342155264:main --image
vendor=out/target/product/k61v1_64_bsp/vendor.img --sparse --output out/target/product/k61v1_64_bsp/super.img" 2020-01-06 16:15:34 - common.py - INFO : lpmake I 01-06 16:14:22 697 697 builder.cpp:937] [liblp]Partition
product will resize from 0 bytes to 1516761088 bytes
lpmake I 01-06 16:14:22 697 697 builder.cpp:937] [liblp]Partition system will resize from 0 bytes to 1570562048 bytes lpmake I 01-06 16:14:22 697 697 builder.cpp:937] [liblp]Partition vendor will resi
ze from 0 bytes to 342155264 bytes 2020-01-06 16:15:34 - build_super_image.py - INFO : Done writing image out/target/product/k61v1_64_bsp/super.img
make otapackage
build/make/core/Makefile
ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
$(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
$(call intermediates-dir-for,PACKAGING,superimage_debug)/)
endif
endif
endif
build/make/core/Makefile
# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
# $(1): built image path
# $(2): path; its contents should match expectation of build_super_image.py
define build-superimage-target
mkdir -p $(dir $(2))
rm -rf $(2)
$(call dump-super-image-info,$(2))
$(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
mkdir -p $(dir $(1))
PATH=$(dir $(LPMAKE)):$$PATH \
$(BUILD_SUPER_IMAGE) -v $(2) $(1)
endef
编译log
2020-01-06 10:53:23 - build_super_image.py - INFO : Building super image from
2020-01-06 10:53:23 - sparse_img.py - INFO : Total of 370303 4096-byte output blocks in 21 input chunks.
2020-01-06 10:53:23 - sparse_img.py - INFO : Total of 385033 4096-byte output blocks in 19 input chunks.
2020-01-06 10:53:23 - sparse_img.py - INFO : Total of 83534 4096-byte output blocks in 11 input chunks.
2020-01-06 10:53:23 - common.py - INFO : Running: "lpmake --metadata-size 65536 --super-nam
e super --metadata-slots 2 --device super:4294967296 --group main:4292870144 --partition product:readonly:1516761088:main --image product=out/target/product/k61v1_64_bsp/product.img --partition system:readonly:1577095168:main --image
system=out/target/product/k61v1_64_bsp/system.img --partition vendor:readonly:342155264:main --image
vendor=out/target/product/k61v1_64_bsp/vendor.img --sparse --output out/target/product/k61v1_64_bsp/super.img" 2020-01-06 10:54:27 - common.py - INFO : lpmake I 01-06 10:53:23 4178 4178 builder.cpp:937] [liblp]Partition product will resize from 0 bytes to 1516761088 bytes
lpmake I 01-06 10:53:23 4178 4178 builder.cpp:937] [liblp]Partition system will resize from 0 bytes to 1577095168 bytes
lpmake I 01-06 10:53:23 4178 4178 builder.cpp:937] [liblp]Partition vendor will resize from 0 bytes to 342155264 bytes 2020-01-06 10:54:27 - build_super_image.py - INFO : Done writing image out/target/product/k61v1_64_bsp/super.img [100% 1019/1019] Package OTA: out/target/product/k61v1_64_bsp/full_k61v1_64_bsp-ota-mp1V6.zip
可以看出super.img的⽣成是使⽤build_super_image.py,传⼊了参数信息⽂件
out/target/product/k61v1_64_bsp/obj/PACKAGING/superimage_debug_intermediates
use_dynamic_partitions=true
lpmake=lpmake
build_super_partition=true
super_metadata_device=super
super_block_devices=super
super_super_device_size=4294967296
dynamic_partition_list= product system vendor
super_partition_groups=main
super_main_group_size=4292870144
super_main_partition_list=product system vendor
super_image_in_update_package=true
product_image=out/target/product/k61v1_64_bsp/product.img
system_image=out/target/product/k61v1_64_bsp/system.img
vendor_image=out/target/product/k61v1_64_bsp/vendor.img
通过这⾥的参数可以了解到⼤概的信息
lpmake=lpmake
编译super.img可执⾏⽂件 ⽬录host
dynamic_partition_list= product system vendor
super包含了product system vendor三个分区
那在super.img是怎么放的呢,解开看看就知道了
2.super.img的解包
super的解包需要⼯具lpunpack,但是默认没有编译,源码⽬录位于:system/extras/partition_tools/
直接 make lpunpack 之后会⽣成out/host/linux-86/lpunpack
⾸先我编译出super.img ⾸先确认是什么格式的 根据其他问题刷机的格式,我觉得这个是sparse格式
执⾏ file super.img 后还真是,所以。。。
第⼀步格式转换,转化为ext4
simg2img super.img super_ext4.img
第⼆步
创建⽬录super_ext4/ 存放解包后的⽂件
第三步
执⾏解包 out/host/linux-86/lpunpack super_ext4.img super_ext4/
解包后在super_ext4/存放着是哪个完整的system.img vendor.img product.img 是ext4格式的,也可以通过mount挂载为⽂件⽬录
simg2img super.img super_ext4.img
mkdir super_ext4
./lpunpack super_ext4.img super_ext4/
mkdir super_ext4/system/
./ext2rd super_ext4/system.img ./:super_ext4/system/
⼆、差分⽅⾯
1、整包
这⾥⾸先对于dynamic_partitions_op_list的⽣成进⾏确认
build/make/toos/releasetools/common.py
def _Compute(self):
self._op_list = list()
def append(line):
self._op_list.append(line)
def comment(line):
self._op_list.append("# %s" % line)
if self._remove_all_before_apply:
comment('Remove all existing dynamic partitions and groups before '
'applying full OTA')
append('remove_all_groups')
for p, u in self._partition_updates.items():
if u.src_group and _group:
append('remove %s' % p)
for p, u in self._partition_updates.items():
if u.src_group _group and u.src_group != u.tgt_group:
comment('Move partition %s from %s to default' % (p, u.src_group))
append('move %s default' % p)
for p, u in self._partition_updates.items():
if u.src_size _size and u.src_size > u.tgt_size:
comment('Shrink partition %s from %d to %d' %
(p, u.src_size, u.tgt_size))
append('resize %s %s' % (p, u.tgt_size))
for g, u in self._group_updates.items():
if u.src_size is not None _size is None:
append('remove_group %s' % g)
if (u.src_size is not None _size is not None and
u.src_size > u.tgt_size):
comment('Shrink group %s from %d to %d' % (g, u.src_size, u.tgt_size)) append('resize_group %s %d' % (g, u.tgt_size))
for g, u in self._group_updates.items():
if u.src_size is None _size is not None:
comment('Add group %s with maximum size %d' % (g, u.tgt_size))
append('add_group %s %d' % (g, u.tgt_size))
if (u.src_size is not None _size is not None and
u.src_size < u.tgt_size):
comment('Grow group %s from %d to %d' % (g, u.src_size, u.tgt_size))
append('resize_group %s %d' % (g, u.tgt_size))
android retrofitfor p, u in self._partition_updates.items():
_group and not u.src_group:
comment('Add partition %s to group %s' % (p, u.tgt_group))
append('add %s %s' % (p, u.tgt_group))
for p, u in self._partition_updates.items():
_size and u.src_size < u.tgt_size:
comment('Grow partition %s from %d to %d' % (p, u.src_size, u.tgt_size)) append('resize %s %d' % (p, u.tgt_size))
for p, u in self._partition_updates.items():
if u.src_group _group and u.src_group != u.tgt_group:
comment('Move partition %s from default to %s' %
(p, u.tgt_group))
append('move %s %s' % (p, u.tgt_group))
对⽐整包中的dynamic_partitions_op_list
# Update dynamic partition metadata
assert(update_dynamic_partitions(package_extract_file("dynamic_partitions_op_list")));
# Remove all existing dynamic partitions and groups before applying full OTA
remove_all_groups
# Add group main with maximum size 4292870144
add_group main 4292870144
# Add partition product to group main
add product main
# Add partition vendor to group main
add vendor main
# Add partition system to group main
add system main
# Grow partition product from 0 to 1516761088
resize product 1516761088
# Grow partition vendor from 0 to 342155264
resize vendor 342155264
# Grow partition system from 0 to 1158651904
resize system 1158651904
可以看出执⾏该⽂件在整包中的⼤致顺序:
1、移除所有的组,清空super
2、添加组
3、添加system product vendor组
4、添加分区并给到⼤⼩
那么通过整包中的语句,我们可以⼤致推出差分包执⾏流程,我做了⼏个包进⾏了验证
2、差分包
更新较少,只修改版本号
dynamic_partitions_op_list为空
新增⼤⽂件 对system分区重新划分⼤⼩
# Grow partition system from 1158651904 to 1577095168
resize system 1577095168
去除⼤⽂件 对system分区重新划分⼤⼩
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论