recoveryアップグレードで発生した問題とそのプロセスの簡単な分析

14276 ワード

ここ数日、RK 3288プラットフォームのrecoveryアップグレード機能をテストし、生成されたupdateをパッケージ化することをテストした.imgはミラーをアップグレードします.何度もテストした結果、kernel部分のロゴが更新されていないことがわかりました.一般的に元工場のrecoveryのアップグレードは正常ですが、問題をよりよく解決するためにも、この機会にrecoveryの下の流れを理解するためにも.

recovery関連部分のコードパス

${code_root}/bootable/recovery
${code_root}/bootable/recovery/recovery.cpp
${code_root}/bootable/recovery/rkimage.cpp
${code_root}/frameworks/base/core/java/android/os/RecoverySystem.java

シリアル・ポートによるアップグレード・プロセスの追跡


ここには私がシリアルポートから取り外したいくつかのキーログ印刷が貼られています.


I/ [File] : bootable/recovery/recovery.cpp; [Line] : 1408; [Func] : SetSdcardRootPath; InternalSD_ROOT: /mnt/internal_sd
I/ [File] : bootable/recovery/recovery.cpp; [Line] : 1410; [Func] : SetSdcardRootPath; ExternalSD_ROOT: /mnt/external_sd
failed to create /cache dir,err=File exists!
D/ [File] : bootable/recovery/recovery.cpp; [Line] : 2265; [Func] : main; to dump args befor get_args() : 
         1 argument(s) : 
         /sbin/recovery 
D/ [File] : bootable/recovery/recovery.cpp; [Line] : 604; [Func] : get_args; to dump 'boot' : 
         command :  
         status :  
         recovery :  
         stage :  
I/ [File] : bootable/recovery/recovery.cpp; [Line] : 655; [Func] : get_args; Got arguments from /cache/recovery/command
D/ [File] : bootable/recovery/recovery.cpp; [Line] : 2282; [Func] : main; to dump args after get_args() : 
         3 argument(s) : 
         /sbin/recovery 
         --update_rkimage=/mnt/usb_storage/USB_DISK2/udisk0/update.img 
         --locale=zh_CN 
locale is [zh_CN]
stage is []
reason is [(null)]

Recovery system v5.0 

I/ [File] : bootable/recovery/recovery.cpp; [Line] : 2379; [Func] : main; Recovery system v5.0, built at '15:49:43', on 'May 17 2016'.
failed to create /mnt/external_sd dir,err=File exists!
W/ [File] : bootable/recovery/roots.cpp; [Line] : 145; [Func] : ensure_path_mounted; trying mount /dev/block/mmcblk1p1 to ntfs
W/ [File] : bootable/recovery/roots.cpp; [Line] : 161; [Func] : ensure_path_mounted; trying mount /dev/block/mmcblk1 to ntfs
E:failed to mount /mnt/external_sd (No such device)
E/ [File] : bootable/recovery/roots.cpp; [Line] : 167; [Func] : ensure_path_mounted; failed to mount /mnt/external_sd (No such device)
delay 2sec
failed to create /mnt/external_sd dir,err=File exists!
W/ [File] : bootable/recovery/roots.cpp; [Line] : 145; [Func] : ensure_path_mounted; trying mount /dev/block/mmcblk1p1 to ntfs
W/ [File] : bootable/recovery/roots.cpp; [Line] : 161; [Func] : ensure_path_mounted; trying mount /dev/block/mmcblk1 to ntfs
E:failed to mount /mnt/external_sd (No such device)
E/ [File] : bootable/recovery/roots.cpp; [Line] : 167; [Func] : ensure_path_mounted; failed to mount /mnt/external_sd (No such device)
delay 2sec

read cmdline
Not enter sdboot!
failed to create /mnt/external_sd dir,err=File exists!
W/ [File] : bootable/recovery/roots.cpp; [Line] : 145; [Func] : ensure_path_mounted; trying mount /dev/block/mmcblk1p1 to ntfs
W/ [File] : bootable/recovery/roots.cpp; [Line] : 161; [Func] : ensure_path_mounted; trying mount /dev/block/mmcblk1 to ntfs
E:failed to mount /mnt/external_sd (No such device)
E/ [File] : bootable/recovery/roots.cpp; [Line] : 167; [Func] : ensure_path_mounted; failed to mount /mnt/external_sd (No such device)
failed to create /metadata dir,err=File exists!
[   10.900450] EXT4-fs (mmcblk0p12): mounted filesbotem with ordc ed dmta mo e. Opts: 
very" "--update_rkimage=/mnt/usb_storage/USB_DISK2/udisk0/update.img" "--locale=zh_CN"

findPackageAndMountUsbDevice : searchFile = /mnt/usb_storage/update.img
/dev/block/.
/dev/block/..
/dev/block/sda1
try to mount usb device at /dev/block/sda1 by vfat[   10.934452] FAT-fs (sda1): Volume was not properly unmounted. Some uab updateepackage.. 

I/ [File] : bootable/recovery/recovery.cpp; [Line] : 2517; [Func] : main; to install rk_img : /mnt/usb_storage/update.img.
Finding update package...
=== UPDATE RKIMAGE===
Find and check firmware...
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 1286; [Func] : find_update_img; Update location: /mnt/usb_storage/update.img
the path is already mounted!
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 1293; [Func] : find_update_img; Update file path: /mnt/usb_storage/update.img
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 514; [Func] : CheckImageFile; Local model: rk3288_box
Update model: rk3288_box
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 521; [Func] : CheckImageFile; Checking...
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 361; [Func] : check_image_crc; Check crc okay.
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 1924; [Func] : install_rkimage; g_package_target=/mnt/usb_storage/update.img
!!! Please KEEP your USB cable or DC-in connected !!!
E:unknown volume for path [RU_PARTITION_MOUNT_PATH]
E/ [File] : bootable/recovery/roots.cpp; [Line] : 93; [Func] : ensure_path_mounted; unknown volume for path [RU_PARTITION_MOUNT_PATH]
E:unknown volume for path [SYSTEM_PARTITION_MOUNT_PATH]
E/ [File] : bootable/recovery/roots.cpp; [Line] : 93; [Func] : ensure_path_mounted; unknown volume for path [SYSTEM_PARTITION_MOUNT_PATH]
Update boot.img...
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 812; [Func] : write_image; src=boot  dest=/boot  offset=0
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 839; [Func] : write_image; dest isFile: 0
Check boot.img...
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 1086; [Func] : image_compare; src=boot  dest=/boot  offset=0
Update resource.img...
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 812; [Func] : write_image; src=resource  dest=/resource  offset=0
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 839; [Func] : write_image; dest isFile: 0
Check resource.img...
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 1086; [Func] : image_compare; src=resource  dest=/resource  offset=0
Update uboot.img...
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 812; [Func] : write_image; src=uboot  dest=/uboot  offset=0
E:Can't find uboot 
E/ [File] : bootable/recovery/rkimage.cpp; [Line] : 819; [Func] : write_image; Can't find uboot 
no uboot.img so ignore
Update trust.img...
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 812; [Func] : write_image; src=trust  dest=/trust  offset=0
E:Can't find trust 
E/ [File] : bootable/recovery/rkimage.cpp; [Line] : 819; [Func] : write_image; Can't find trust 
no trust.img so ignore
Update system...
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 812; [Func] : write_image; src=system  dest=/system  offset=0
E:Can't find system 
E/ [File] : bootable/recovery/rkimage.cpp; [Line] : 819; [Func] : write_image; Can't find system 
no boot.img so ignore
Update backup...
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 812; [Func] : write_image; src=backup  dest=/backup  offset=0
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 839; [Func] : write_image; dest isFile: 0
Check backup...
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 1086; [Func] : image_compare; src=backup  dest=/backup  offset=0
Update recovery.img...
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 812; [Func] : write_image; src=recovery  dest=/recovery  offset=0
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 839; [Func] : write_image; dest isFile: 0
Check recovery...
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 1086; [Func] : image_compare; src=recovery  dest=/recovery  offset=0
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 1496; [Func] : handle_update_script; Read script
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 1512; [Func] : handle_update_script; Parse the script
line 3 col 58: syntax error, unexpected STRING, expecting $end
E:1 parse errors
E/ [File] : bootable/recovery/rkimage.cpp; [Line] : 1519; [Func] : handle_update_script; 1 parse errors
handle script error! ignore...
copy Bootloader...
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 612; [Func] : write_loader; src=bootloader  dest=/misc  offset=49152
I/ [File] : bootable/recovery/rkimage.cpp; [Line] : 662; [Func] : write_loader; dest isFile: 0
Installation complete.
I/ [File] : bootable/recovery/recovery.cpp; [Line] : 2522; [Func] : main; to wipe /data.
Formatting /data...
Creating filesystem with parameters:
    Size: 1073741824
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 8192
    Inode size: 256
    Journal blocks: 4096
    Label: 
    Blocks: 262144
    Block groups: 8
    Reserved block group size: 63
Created filesystem with 11/65536 inodes and 8536/262144 blocks
I/ [File] : bootable/recovery/recovery.cpp; [Line] : 821; [Func] : finish_recovery; Saving locale "zh_CN"
Rebooting...
[   16.647164] SysRq : Emergency Remount R/O
[   16.649590] EXT4-fs (mmcblk0p12): re-mounted. Opts: (null)
[   16.651388] Emergency Remount complete
[   16.747856] cpufreq: cpufreq: reboot set core rate=1200000000, volt=1100000
[   16.748050] mmcblk mmc0:0001: Unbalanced pm_runtime_enable!
[   17.358818] dwc_otg_driver_shutdown: disconnect USB device mode
[   17.366720] Restarting system with command ''.
DDR Version 1.00 20150318

ログ出力によって、Recoveryのアップグレードプロセスを大体理解することができます.update.imgのアップグレードは主にrecoveryに関連しています.cppとrkimage.cpp,recovery.cppはrecoveryアップグレード呼び出しに入る入り口、rkimageです.cppはupdate.imgはパケットを分解してアップグレードします.ここで説明したいのは、ログはプロセスと問題を分析するのに役立つツールであり、ログを分析して問題を解決することが多いということです.

アプリケーション上層部がrecoveryアップグレードに入る方法を簡単に分析


recoveryを動作させるには、「/cache/recovery/command」というノードにコマンドを書く必要があります.Logでは、アップグレードパッケージのパスとローカル言語を含むパラメータを見つけることができます.
I/ [File] : bootable/recovery/recovery.cpp; [Line] : 655; [Func] : get_args; Got arguments from /cache/recovery/command
D/ [File] : bootable/recovery/recovery.cpp; [Line] : 2282; [Func] : main; to dump args after get_args() : 
         3 argument(s) : 
         /sbin/recovery 
         --update_rkimage=/mnt/usb_storage/USB_DISK2/udisk0/update.img 
         --locale=zh_CN 
locale is [zh_CN]
stage is []
reason is [(null)]

これらのパラメータは、androidを参照することができる/cache/recovery/commandノードにどのように上位アプリケーションで書くか.os.RecoverySystemというクラスの関連方法.では、recoveryにはどのような操作可能なパラメータがありますか.関連するコマンドはrecoveryにあります.cppで宣言が見つかりました.
static const struct option OPTIONS[] = {
  { "factory_mode", required_argument, NULL, 'f' },
  { "send_intent", required_argument, NULL, 's' },
  { "update_package", required_argument, NULL, 'u' },
  { "update_rkimage", required_argument, NULL, 'k' },   // support rkimage to update
  { "radical_update_package", required_argument, NULL, 'z' },   // to support ru_pkg to update
  { "wipe_data", no_argument, NULL, 'w' },
  { "wipe_cache", no_argument, NULL, 'c' },
  { "show_text", no_argument, NULL, 't' },
  { "wipe_all", no_argument, NULL, 'w'+'a' },
  { "just_exit", no_argument, NULL, 'x' },
  { "locale", required_argument, NULL, 'l' },
  { "stages", required_argument, NULL, 'g' },
  { "shutdown_after", no_argument, NULL, 'p' },
  { "fw_update", required_argument, NULL, 'f'+'w' },
  { "demo_copy", required_argument, NULL, 'd' },
  { "reason", required_argument, NULL, 'r' },
  { NULL, 0, NULL, 0 },
};

変換の過程は読者がrecoveryを見ることができる.cppのmainメソッドは、ここではコードを貼らず、パラメータを入力することでrecoveryが選択し、今回はアップグレードするか復元するか、パーティションを消去するかなどします.これでrecoveryに上層部が適用されるプロセスは基本的に整理されます.

ロゴをアップグレードできない問題の解決


RK 3288プラットフォームの起動ロゴはresourceにパッケージされています.imgでは、ミラーを生成するときにresourceが生成されます.imgはbootにパッケージされます.imgでは、コードの中でbootが正しい.imgでアップグレードしました.では、問題はどこにあるのでしょうか.アップグレードしたのに効果がない.このとき、印刷データが次のように表示されていることに気づきました.
bootmode = emmc 
recovery filesystem table
=========================
  0 /mnt/internal_sd vfat /dev/block/platform/ff0f0000.rksdmmc/by-name/user 0
  1 /mnt/external_sd vfat /dev/block/mmcblk1p1 0
  2 /system ext4 /dev/block/platform/ff0f0000.rksdmmc/by-name/system 0
  3 /cache ext4 /dev/block/platform/ff0f0000.rksdmmc/by-name/cache 0
  4 /metadata ext4 /dev/block/platform/ff0f0000.rksdmmc/by-name/metadata 0
  5 /data ext4 /dev/block/platform/ff0f0000.rksdmmc/by-name/userdata 0
  6 /cust ext4 /dev/block/platform/ff0f0000.rksdmmc/by-name/cust 0
  7 /custom ext4 /dev/block/platform/ff0f0000.rksdmmc/by-name/custom 0
  8 /radical_update ext4 /dev/block/platform/ff0f0000.rksdmmc/by-name/radical_update 0
  9 /misc emmc /dev/block/platform/ff0f0000.rksdmmc/by-name/misc 0
  10 /uboot emmc /dev/block/platform/ff0f0000.rksdmmc/by-name/uboot 0
  11 /charge emmc /dev/block/platform/ff0f0000.rksdmmc/by-name/charge 0
  12 /resource emmc /dev/block/platform/ff0f0000.rksdmmc/by-name/resource 0
  13 /parameter emmc /dev/block/platform/ff0f0000.rksdmmc/by-name/parameter 0
  14 /boot emmc /dev/block/platform/ff0f0000.rksdmmc/by-name/boot 0
  15 /recovery emmc /dev/block/platform/ff0f0000.rksdmmc/by-name/recovery 0
  16 /backup emmc /dev/block/platform/ff0f0000.rksdmmc/by-name/backup 0
  17 /tmp ramdisk ramdisk 0

resourceにもパーティションがあります.resourceですか.imgも単独でアップグレードする必要がありますか?こんな疑問を持って、rkimageで実験をしました.cppのinstall_rkimageメソッドはアップグレードresourceを追加します.imgの処理(以下)では,電源ロゴを更新できることが実験的に結論された.
    
    ui->Print("Update resource.img...
"); result = write_image("resource", "/resource", 0); if(result == -4) { //some times, we not want to boot every time; ui->Print("no resource.img so ignore
"); }else if(result == 0) { ui->Print("Check resource.img...
"); result = image_compare("resource", "/resource", 0); if(result) { ui->Print("Failed(%d)
", result); goto update_error; } }else { ui->Print("Failed(%d)
", result); goto update_error; }

問題原因と結論:工場のアップグレード時にresource.imgはパーティションとしてボードカードにアップグレードされ、その後、起動ロゴを更新するにはパーティションを更新する必要があります.他の解決策はresourceですimgパーティションは1つのパーティションとしてボードカードに更新されず、boot.imgパーティションを一緒にパッケージすればいいです.私のホームページへようこそ、ありがとうございました!