MTK8.0 9.0 驱动部分升级解析

1、涉及文件

2、流程解析

3、问题所在

4、问题优化

 

1、编译涉及主要文件:

2、流程解析

MTK驱动部分分区的升级在编译阶段只由两个文件执行并完成

build/make/core/Makefile  

在make otapackage 生成中间包时执行mt_ota_preprocess.py文件

mt_ota_preprocess.py
1、生成ota_update_list.txt文件
2、将out下在list中的文件拷贝到obj/PACKAGING/
target_files_intermediates/full_k63v2_64_bsp-target_files-1536389495/IMAGES/
以用作整包和差分包生成时使用

mt_ota_preprocess.py具体流程,首先main方法,最主要的两个步骤
执行generate_updatelist 生成update_list列表,注意传入的参数是scatter_file,也就是我们刷机用的分区表

执行copy_files方法将img文件拷贝到对应的路径,而拷贝的规则是这些文件必须是在partition{} 这个集合中

流程解析generate_updatelist方法

先介绍几个文件中的参数
//包含在列表中的
upgrade_list_include = ["tee1","tee2"]
//不包含在列表中的,这部分是会进行差分的文件
upgrade_list_exclude = ["boot","system","android","recovery","bootimg"]
//特殊文件 preloader,只有preloader 一个挂载点
upgrade_list_specific_sequence = {"preloader", "preloader2"}
//分区中存在两个,在生成差分包的时候会在update-scrypt中进行switch选择升级
upgrade_list_mount_map = {"lk" : "bootloader", "lk2" : "bootloader2", "uboot" : "bootloader", "uboot
//全局变量,partition集合
partition_map = {}

def generate_updatelist(scatter_file, update_list):  大致方法

1、从scatter_file中检索出需要的字段,也就是分区表中的参数,这部分的输出可以在make otapackage的 编译log中查询到

2、通过字段进行判断,是否会走到addPartMap方法中,也就是添加到partition_map集合中,

3、根据partition_map集合生成update_list列表

 走到这里我们可以看出来,首先是在分区表中检索到了,该文件需要升级,会放在list中,然后才会   根据生成的集合进行了拷贝,所以如果有文件没有加在list中,问题的关键是在分区表和判断条件中

3、问题所在

编译软件后发现,lk,preloder都在list中,但是logo并没有

按上述分析,如果有驱动文件,会走进for循环,按分区表和判断条件,加入list 分区表

文件partition_table_MT6763.xls     MT6763_Android_scatter.txt 

可以看出logo 的OTA_Update 是 N,最后体现在scatter文件中is_upgradable: false
所以在之前的判断条件中if is_update.group(1) == "true" 判断不做升级
这样看似很合理,但是重新再看之前的判断条件
判断is_update 是不是为空,如果为空,走到else方法,我们把logo加到 upgrade_list_include 集合中即可,但是测试后发现并未生效,因为else的打印没有出现,这是为什么呢
if is_update is not None:
if is_update.group(1) == "true" and not part_name.lower() in upgrade_list_exclude and file_name != "NONE":
if fs_type != "EXT4_IMG" and fs_type != "UBI_IMG":
print("===========not in upgrade_list_exclude:==========")
#print("is_update" + str(is_update))
print("part_name=" + part_name)
print("file_name=" + file_name)
print("storage_type=" + storage_type)
print("fs_type=" + fs_type)
#print("===========not in upgrade_list_exclude:==========")
addPartMap(partition_map, part_name, file_name, storage_type)
else:
print "[OTA Preprocess] %s is an %s, can not be upgraded by this method" % (part_name, fs_type)
else:
if part_name.lower() in upgrade_list_include and file_name != "NONE":
print("===========in upgrade_list_include:==========")
先看下is_update的取值
is_update = re.search(r'is_upgradable: (.*?)\n', item) 这样按正则着表达式取到的其实并不是 true 或者 false ,相当于取到的是 is_upgradable: false,这个字段不可能为空
所以无论我们怎么修改都不会走到else方法中,而isupdate.group(1)才是取到的才是Boolean值

4、问题优化

按上述分析我们修改方法一如下:

isupdate.group(1) 以该值作为判断条件,也就是 is_upgradable 的取值
分区表中OTA_Update 是 Y,直接进入if ,OTA_Update 为N进入else
我们把logo放在upgrade_list_include,upgrade_list_include = ["logo"] 这样验证问题解决
编译后验证,logo加入列表,IMAGES/ 也可以打包,整包中也可以加入升级的脚本
ui_print("start to update general image");
package_extract_file("logo.bin", "/dev/block/platform/bootdevice/by-name/logo");

修改方法二,如果我们想更为严谨一些,

修改方法三,如果我们像更为简单一些,

在update-scrypt 脚本中加入 package_extract_file("logo.bin", "/dev/block/platform/bootdevice/by-name/logo");

差分包中放入logo.bin文件,

并对差分包进行重新签名 

java -Djava.library.path=out/host/linux-x86/lib64 -jar  ./out/host/linux-x86/framework/signapk.jar  -w build/target/product/security/testkey.x509.pem  build/target/product/security/testkey.pk8  update.zip update_sign.zip 

注意: /dev/block/platform/bootdevice/by-name/logo 这一句来自于fstb文件 out/target/product/k63v2_64_bsp/recovery/root/etc/recovery.fstab 或者FOTA包中 ota_target_file.zip//RECOVERY/RAMDISK/etc/recovery.fstab

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值