rk3399 Android9.0 ota升级失败
问题:在rk3399 Android9.0 项目中需要 ota 功能,user版本编译完ota升级包后,在同版本整包升级时遇到如下问题:
抓到的logcat内容如下:
1044 2343 D RKUpdateService: doesImageMatchProduct(): start verify package , imagePath = /mnt/media_rw/9704-7E5A/update.zip
250 326 D AudioHardwareTiny: do_out_standby,out = 0xee550000,device = 0x2
250 326 D alsa_route: route_set_controls() set route 24
250 326 D AudioHardwareTiny: close device
261 261 E hwc_rk : hwc_get_handle_layername:cann't get value from gralloc
261 261 E hwc_rk : hwc_get_handle_layername:cann't get value from gralloc
261 306 E HWC2On1Adapter: Validate was called more than once!
261 306 E hwc_rk : hwc_get_handle_layername:cann't get value from gralloc
261 306 E hwc_rk : hwc_get_handle_layername:cann't get value from gralloc
261 306 E HWC2On1Adapter: Validate was called more than once!
454 467 E memtrack: Couldn't load memtrack module
454 467 W android.os.Debug: failed to get memory consumption info: -1
454 467 E memtrack: Couldn't load memtrack module
454 467 W android.os.Debug: failed to get memory consumption info: -1
454 467 E memtrack: Couldn't load memtrack module
454 467 W android.os.Debug: failed to get memory consumption info: -1
454 1306 D DhcpClient: Broadcasting DHCPDISCOVER
1044 2343 W VintfObject: VintfObject.verify() returns 1: Runtime info and framework compatibility matrix are incompatible: For config CONFIG_DEVMEM, value = y but required n
1044 2343 D RKUpdateService: doesImageMatchProduct(): verifaPackage faild!
1044 2343 D RKUpdateService: java.security.SignatureException: package compatibility verification failed
269 291 D SurfaceFlinger: duplicate layer name: changing android.rockchip.update.service/android.rockchip.update.service.UpdateAndRebootActivity to android.rockchip.update.service/android.rockchip.update.service.UpdateAndRebootActivity#1
261 306 E hwc_rk : hwc_get_handle_layername:cann't get value from gralloc
问题分析:
1.通过logcat可以看到
RKUpdateService: doesImageMatchProduct(): verifaPackage faild!
排查思路:
①先看下是否由于签名问题引起的?
②RKUpdateService.apk有更改过,将apk回退到原来的状态是否可以?
③找到RKUpdateService.apk的源码,看下 doesImageMatchProduct() 这个信息报错时,apk对固件包进行了那些信息的比较操作,关注下这些信息是否有更改?
2.通过logcat 可以看到
W VintfObject: VintfObject.verify() returns 1: Runtime info and framework compatibility matrix are incompatible: For config CONFIG_DEVMEM, value = y but required n
排查思路:
1.通过上边log可以看到 CONFIG_DEVMEM 宏的值是y,但是要求应该是n,将kernel/.config中的宏关闭看下?
思路验证:
1.1是否由签名问题引起:
1.经验证 vendor/rockchip/common/apps/RKUpdateService/Android.mk中的 LOCAL_CERTIFICATE = platform ,说明 RKUpdateService.apk使用的是系统签名,就算系统签名更换过也没有关系,在编译的时候,RKUpdateService.apk依旧会使用系统签名重新签一次,以保证签名正确。
排查完后确定不是签名的问题。
注意:在rk3288 7.1 项目中有试过,如果 RKUpdateService.apk 的签名有问题的话,那么在插入U盘后,根本就不会弹出ota升级的窗口。
1.2怀疑 RKUpdateService.apk 更改过导致升级失败:
将 vendor/rockchip/common/apps/RKUpdateService/RKUpdateService.apk 修改回退,重新编译,然后ota升级,发现依旧不行,说明与 RKUpdateService.apk 的更改没有影响。
1.3根据 RKUpdateService.apk 源码确定问题点:
发现 RKUpdateService: doesImageMatchProduct(): verifaPackage faild! 这个报错发生在如下内容中:
public boolean doesOtaPackageMatchProduct(String imagePath) {
LOG("doesImageMatchProduct(): start verify package , imagePath = " + imagePath);
try{
RKRecoverySystem.verifyPackage(new File(imagePath), null, null);
}catch(GeneralSecurityException e){
LOG("doesImageMatchProduct(): verifaPackage faild!\n" + e.toString());
return false;
}catch(Exception e) {
LOG("doesImageMatchProduct(): verifaPackage faild!\n" + e.toString());
return false;
}
return true;
}
由于对java程序不是很了解,只是在网上搜到了 RKRecoverySystem.verifyPackage 这一步只是校验升级包是否合法,不知道具体是校验那些信息,请教了上层同事,给到的反馈是:RKRecoverySystem.verifyPackage 这个是校验升级包签名的。
但是根据1.1点已经可以确定不是签名的问题引起的,所以此条信息无效。
2.1 kernel中宏的确定
通过log看到 kernel/.config 文件中的 CONFIG_DEVMEM=y,但是应该要求应该是 CONFIG_DEVMEM=n。
将如上宏进行修改,重新编译后,使用ota升级,发现有如下报错:
07-25 08:20:39.427 1292 2302 W VintfObject: VintfObject.verify() returns 1: Runtime info and framework compatibility matrix are incompatible: AVB version 1.1 does not match framework matrix 0.0
07-25 08:20:39.427 1292 2302 D RKUpdateService: doesImageMatchProduct(): verifaPackage faild!
如上问题没有遇到过不清楚如何处理,最终在 rk的readme 中搜索到与现在情况一样的报错内容,进行如下修改后 ota升级方可成功:
方法一:
将 device/rockchip/下的 BOARD_AVB_ENABLE 的 flase 更改为 true
device/rockchip/rk3399/BoardConfig.mk:37:BOARD_AVB_ENABLE := true
方法二:
关闭 arch/arm64/boot/dts/rockchip/rk3399-tvi3337a-avb.dts 中 avb
详细参考下面内容。
总结:
rk3399 Android9.0 user版本ota无法升级问题的处理方法如下:
方法一:(只有需要过gms的时候才会选择这个方案)
kernel/
diff --git a/.config b/.config
index 15bbe7994706..2758cf6e2272 100644
--- a/.config
+++ b/.config
@@ -1920,7 +1920,7 @@ CONFIG_UNIX98_PTYS=y
# CONFIG_NOZOMI is not set
# CONFIG_N_GSM is not set
# CONFIG_TRACE_SINK is not set
-CONFIG_DEVMEM=y
+# CONFIG_DEVMEM is not set
# CONFIG_DEVKMEM is not set
device/rockchip/rk3399/
diff --git a/BoardConfig.mk b/BoardConfig.mk
index 8e60bef..f478b14 100755
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -34,7 +34,7 @@ TARGET_2ND_CPU_VARIANT := cortex-a15
TARGET_PREBUILT_KERNEL := kernel/arch/arm64/boot/Image
PRODUCT_PACKAGE_OVERLAYS += device/rockchip/rk3399/overlay
-BOARD_AVB_ENABLE := false
+BOARD_AVB_ENABLE := true #AVB 为false的时候,过不了gms
# Disable emulator for "make dist" until there is a 64-bit qemu kernel
BUILD_EMULATOR := false
方法二:(一般采用这个方法实现)
kernel/
diff --git a/.config b/.config
index 15bbe7994706..2758cf6e2272 100644
--- a/.config
+++ b/.config
@@ -1920,7 +1920,7 @@ CONFIG_UNIX98_PTYS=y
# CONFIG_NOZOMI is not set
# CONFIG_N_GSM is not set
# CONFIG_TRACE_SINK is not set
-CONFIG_DEVMEM=y
+# CONFIG_DEVMEM is not set
# CONFIG_DEVKMEM is not set
diff --git a/arch/arm64/boot/dts/rockchip/rk3399-tvi3337a-avb.dts b/arch/arm64/boot/dts/rockchip/rk3399-tvi3337a-avb.dts
index c32cd07082b0..68f9056e35d2 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399-tvi3337a-avb.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3399-tvi3337a-avb.dts
@@ -19,10 +19,6 @@
compatible = "android,firmware";
boot_devices = "fe330000.sdhci";
- vbmeta {
- compatible = "android,vbmeta";
- parts = "vbmeta,boot,system,vendor,dtbo";
- };
fstab {
compatible = "android,fstab";
@@ -31,7 +27,7 @@
dev = "/dev/block/by-name/vendor";
type = "ext4";
mnt_flags = "ro,barrier=1,inode_readahead_blks=8";
- fsmgr_flags = "wait,avb";
+ fsmgr_flags = "wait";
};
};
};