AMLOGIC 8726 升级相关介绍.doc_第1页
AMLOGIC 8726 升级相关介绍.doc_第2页
AMLOGIC 8726 升级相关介绍.doc_第3页
AMLOGIC 8726 升级相关介绍.doc_第4页
AMLOGIC 8726 升级相关介绍.doc_第5页
已阅读5页,还剩8页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

此文档收集于网络,如有侵权,请联系网站删除Amlogic 8726升级相关介绍一 Amlogic uboot启动命令执行顺序:正常启动下:reboot_mode=charging1. preboot=get_rebootmode; clear_rebootmode; echo reboot_mode=$reboot_mode; if test $reboot_mode = usb_burning; then tiny_usbtool 20000; fi; run upgrade_check; run switch_bootmode2. bootcmd=run nandboot3. nandboot=echo Booting from nand .;runvdacswitchconfig;runnandargs;nand read boot $loadaddr 0 600000;hdcp prefetch nand;bootm;run recoveryvdacswitchconfig=if test $cvbsenable = true; then setenv vdacswitchmode cvbs;else if test $cvbsenable = false;then setenv vdacswitchmode component;fi;finandargs=runcvbscheck; nand read logo 0x83000000 0 800000;unpackimg 0x83000000; cp $bootup_offset 0x84100000 $bootup_size; setenv bootargs root=/dev/cardblksd2 rw rootfstype=ext3 rootwait init=/init console=ttyS0,115200n8 logo=osd1,0x84100000,$outputtemp,full androidboot.resolution=$outputmode nohlt vmalloc=256m mem=1024m a9_clk_max=1512000000 vdachwswitch=$vdacswitchmodecvbscheck=setenv outputtemp $outputmode;if test $outputmode = 480i; then if test $cvbsenable = true; then setenv outputtemp 480cvbs;fi;fi; if test $outputmode = 576i; then if test $cvbsenable = true; then setenv outputtemp 576cvbs;fi;fi升级模式下:reboot_mode=update1. preboot=get_rebootmode; clear_rebootmode; echo reboot_mode=$reboot_mode; if test $reboot_mode = usb_burning; then tiny_usbtool 20000; fi; run upgrade_check; run updatekey_or_not; run switch_bootmode2. upgrade_check=if itest $upgrade_step = 1; then defenv_without reboot_mode;setenv upgrade_step 2; save; fi3. updatekey_or_not=saradc open 4;if saradc get_in_range 0x0 0x50 ;then msleep 500;if saradc get_in_range 0x0 0x50; then runupdate; fi; fiupdate=if mmcinfo; then if fatload mmc 0 $loadaddr aml_autoscript; then autoscr $loadaddr; fi;fi;if usb start; then if fatload usb 0 $loadaddr aml_autoscript; then autoscr $loadaddr; fi;fi;runrecovery4. switch_bootmode=if test $reboot_mode = factory_reset; then run recovery;else if test $reboot_mode = update; then runrecovery;fi;fi5.recovery=echo enter recovery;runnandargs;if mmcinfo; then if fatload mmc 0 $loadaddr recovery.img; then bootm;fi;fi;if usb start; then if fatload usb 0 $loadaddr recovery.img; then bootm;fi;fi; nand read recovery $loadaddr 0 600000; bootmnandargs=runcvbscheck; nand read logo 0x83000000 0 800000;unpackimg 0x83000000; cp $bootup_offset 0x84100000 $bootup_size; setenv bootargs root=/dev/cardblksd2 rw rootfstype=ext3 rootwait init=/init console=ttyS0,115200n8 logo=osd1,0x84100000,$outputtemp,full androidboot.resolution=$outputmode nohlt vmalloc=256m mem=1024m a9_clk_max=1512000000 vdachwswitch=$vdacswitchmodecvbscheck=setenv outputtemp $outputmode;if test $outputmode = 480i; then if test $cvbsenable = true; then setenv outputtemp 480cvbs;fi;fi; if test $outputmode = 576i; then if test $cvbsenable = true; then setenv outputtemp 576cvbs;fi;fi串口调试模式下uboot下用bootm命令升级顺序#tftp 82000000 recovery.img#bootm1. 升级查找factory_update_param.aml文件的顺序:sdcard-udisk 如果在sdcard中找到了文件名为factory_update_param.aml的文件,则使用该文件升级系统,如果factory_update_param.aml文件中的命令行有错,导致无法升级,也不会去再找udisk中的factory_update_param.aml文件 如果在sdcard中没有找到文件名为factory_update_param.aml的文件,就去udisk中找2.如果同时存在两个udisk时,recovery只会挂载第0个udisk(即靠近micro usb口的那个usb口上的udisk),如果udisk0中无factory_update_param.aml文件或factory_update_param.aml文件命令行有误,recovery也不会到udisk1去找factory_update_param.aml文件uboot是通过#define reboot_mode *(volatile unsigned long*)(P_AO_RTI_STATUS_REG1)此寄存器的值来判断是加载recovery分区还是加载boot分区(正常kernel)的U盘升级脚本factory_update_param.aml如下:-update_package=/udisk/g18ref-ota-20130716.zip-wipe_data-wipe_cachesd卡升级脚本factory_update_param.aml如下:-update_package=/sdcard/g18ref-ota-20130716.zip-wipe_data-wipe_cache二 Amlogic升级模式系统更新update.zip包的两种方式:1. Android在升级系统时获得update.zip包的方式有两种。一种是离线升级,即手动拷贝升级包到SD卡(或NAND)中,通过System Update-选择从SD卡升级。另一种是在线升级,即OTA Install(over the air)。用户通过在线下载升级包到本地,然后更新。这种方式下的update.zip包一般被下载到系统的/CACHE分区下。 2. 无论将升级包放在什么位置,在使用update.zip更新时都会重启并进入Recovery模式,然后启动recovery服务(/sbin/recovery)来安装我们的update.zip包。业界通用的升级模式如下:在CACHE分区中的建三个文件:/cache/recovery/command:这个文件保存着Main system传给Recovery的命令行,每一行就是一条命令,支持一下几种的组合。-update_package=root:path /verify install an OTA package file Main system将这条命令写入时,代表系统需要升级,在进入Recovery模式后,将该文件中的命令读取并写入BCB中,然后进行相应的更新update.zip包的操作。-wipe_data /erase user data(and cache),then reboot。擦除用户数据。擦除data分区时必须要擦除cache分区。-wipe_cache /wipe cache(but not user data),then reboot。擦除cache分区。Amlogic的command文件如下:-update_package=/sdcard/g18ref-ota-20130711.zip-locale=en_US/cache/recovery/log:Recovery模式在工作中的log打印。在recovery服务运行过程中,stdout以及stderr会重定位到/tmp/recovery.log在recovery退出之前会将其转存到/cache/recovery/log中,供查看。/cache/recovery/intent:Recovery传递给Main system的信息,作用不详。Amlogic的cache/recovey/目录下会存在4个文件:last_install、last_locale、last_log、commandBCB(Bootloader Control Block)在MISC分区:BCB是bootloader与Recovery的通信接口,也是Bootloader与Main system之间的通信接口。存储在flash中的MISC分区,占用三个page,其本身就是一个结构体,具体成员以及各成员含义如下: struct bootloader_message char command32; char status32; char recovery1024; ;command成员:当我们想要在重启进入Recovery模式时,会更新这个成员的值。另外在成功更新后结束Recovery时,会清除这个成员的值,防止重启时再次进入Recovery模式。 command=boot-recovery时,系统会进入Recovery模式。Recovery服务会具体根据/cache/recovery/command中的命令执行相应的操作(例如,升级update.zip或擦除cache,data等)。command=update-radia或update-hboot时,系统会进入更新firmware(更新bootloader),具体由bootloader完成。command为空时,即没有任何命令,系统会进入正常的启动,最后进入主系统(main system)。这种是最通常的启动流程。status:在完成相应的更新后,Bootloader会将执行结果写入到这个字段。recovery:可被Main System写入,也可被Recovery服务程序写入。该文件的内容格式为: “recoveryn n ”该文件存储的就是一个字符串,必须以recoveryn开头,否则这个字段的所有内容域会被忽略。“recoveryn”之后的部分,是/cache/recovery/command支持的命令。可以将其理解为Recovery操作过程中对命令操作的备份。Recovery对其操作的过程为:先读取BCB然后读取/cache/recovery/command,然后将二者重新写回BCB,这样在进入Main system之前,确保操作被执行。在操作之后进入Main system之前,Recovery又会清空BCB的command域和recovery域,这样确保重启后不再进入Recovery模式。Main System向BCB command写入boot-recovery,向/cache/recovery/command写入-update_package=root:path命令,重启。Bootloader读取BCB command来决定是运行recovery还是运行Main SystemRecovery读取BCB command、/cache/recovery/command文件来升级系统,升级完成清除BCB command、/cache/recovery/command文件,或升级失败重新写BCB command三 Amlogic recovery在uboot下用bootm命令升级顺序1. 升级找factory_update_param.aml文件的顺序:sdcard-udisk 如果在sdcard中找到了文件名为factory_update_param.aml的文件,则使用该文件升级系统,如果factory_update_param.aml文件中的命令行有错,导致无法升级,也不会去再找udisk中的factory_update_param.aml文件 如果在sdcard中没有找到文件名为factory_update_param.aml的文件,就去udisk中找2.如果同时存在两个udisk时,recovery只会挂载第0个udisk(即靠近micro usb口的那个usb口上的udisk),如果udisk0中无factory_update_param.aml文件或factory_update_param.aml文件命令行有误,recovery也不会到udisk1去找factory_update_param.aml文件U盘升级脚本factory_update_param.aml如下:-update_package=/udisk/g18ref-ota-20130716.zip-wipe_data-wipe_cachesd卡升级脚本factory_update_param.aml如下:-update_package=/sdcard/g18ref-ota-20130716.zip-wipe_data-wipe_cache四 Amlogic升级过程源码浅析1. ./packages/amlogic/Upgrade/src/com/example/Upgrade/UpgradeActivity.java:139 40 public class UpgradeActivity extends Activity . 89 public void onCreate(Bundle savedInstanceState) 90 super.onCreate(savedInstanceState); 91 setContentView(R.layout.main); 92 mFileUtils = new FileUtils(); 93 mUpdateHttpClient = new UpdateHttpClient(); 94 95 mTextBottom = (TextView) findViewById(R.id.text_bottom); 96 mListCenter = (ListView) findViewById(R.id.list_center); 97 mListCenter.setAdapter(newListAdapter(LIST_MAIN); 98 99 mListCenter.setOnItemClickListener(new OnItemClickListener() 100 public void onItemClick(AdapterView arg0, View arg1, int arg2,101 long arg3) 102 / TODO Auto-generated method stub103 Map item = (Map)arg0.getItemAtPosition(arg2);104 105 if (mListType = LIST_MAIN) 106 if(DEBUG) Log.d(TAG,onItemClick mListType = LIST_MAIN!);107 String item_type = (String) item.get(item_type);108 if (item_type.equals(local)109 mListCenter.setAdapter(newListAdapter(LIST_LOCAL);110 / FIXME: TODO OTA upgrade 111 else if (item_type.equals(net)112 113 ConnectServer();/ mListCenter.setAdapter(newListAdapter(LIST_NET); 114 115 116 else if (mListType = LIST_LOCAL) 117 if (item.get(item_icon).equals(R.drawable.item_icon_back) 118 mListCenter.setAdapter(newListAdapter(LIST_MAIN);119 else 120 mRecoveryPath = (String) item.get(item_recovery_path);121 if(DEBUG) Log.d(TAG,mRecoveryPath=+mRecoveryPath);122 mListCenter.setAdapter(newListAdapter(LIST_CONFIRM);123 124 else if (mListType = LIST_NET) 125 if(DEBUG) Log.d(TAG,onItemClick mListType = LIST_NET!);126 if (item.get(item_icon).equals(R.drawable.item_icon_back) 127 mListCenter.setAdapter(newListAdapter(LIST_MAIN);128 else 129 /mRecoveryPath = (String) item.get(item_recovery_path);130 if(DEBUG) Log.d(TAG,onItemClick net update CONFIRM!);131 CheckFreeSpace();132 133 134 else if (mListType = LIST_CONFIRM) 135 if (item.get(item_icon).equals(R.drawable.item_icon_back) 136 mListCenter.setAdapter(newListAdapter(LIST_LOCAL);137 else 138 if(DEBUG) Log.d(TAG,mRecoveryPath=+mRecoveryPath);139 RebootUtils.rebootInstallPackage(UpgradeActivity.this, new File(mRecoveryPath);140 141 142 143 );144 2. ./packages/amlogic/Upgrade/src/com/example/Upgrade/RebootUtils.java:23 11 public class RebootUtils 12 private final static String TAG = Upgrade.RebootUtils; 13 14 public static void rebootInstallPackage(final Context context, final File packageFile) 15 Log.w(TAG, ! REBOOT INSTALL PACKAGE !); 16 17 Log.d(TAG, file path is + packageFile.getPath(); 18 / The reboot call is blocking, so we need to do it on another thread. 19 Thread thr = new Thread(Reboot) 20 Override 21 public void run() 22 try 23 RecoverySystem.installPackage(context, packageFile); 24 catch (IOException e) 25 Log.e(TAG, Cant perform rebootInstallPackage, e); 26 27 28 ; 29 thr.start(); 30 3. ./frameworks/base/core/java/android/os/RecoverySystem.java:340 60 public class RecoverySystem .328 public static void installPackage(Context context, File packageFile)329 throws IOException 330 String filename = packageFile.getCanonicalPath();331 String strExt2Path =Environment.getExternalStorage2Directory().toString();332 if(filename.startsWith(strExt2Path)333 334 if(Environment.isExternalStorageBeSdcard()335 336 String newpath = filename.substring(4);337 Log.w(TAG, ! REBOOTING TO INSTALL 1 + newpath + !);338 String arg = -update_package= + newpath;339 arg += n-locale= + Locale.getDefault().toString();340 bootCommand(context, arg, true);341 342 else343 344 String newpath =new String(/sdcard)+filename.substring(strExt2Path.length();345 Log.w(TAG, ! REBOOTING TO INSTALL 2 + newpath + !);346 String arg = -update_package= + newpath;347 arg += n-locale= + Locale.getDefault().toString();348 bootCommand(context, arg, true);349 350 351 352 else if(filename.startsWith(Environment.getExternalStorageDirectory().toString()353 354 if(Environment.isExternalStorageBeSdcard()355 356 String absPath = packageFile.getAbsolutePath();357 if(SystemProperties.getInt(vold.fakesdcard.enable,0)=1 & absPath.startsWith(/mnt/sda1/)358 359 String newpath =new String(/udisk/)+absPath.substring(10);360 Log.w(TAG, ! REBOOTING TO INSTALL 3-1 + newpath + !);361 String arg = -update_package= + newpath;362 arg += n-locale= + Locale.getDefault().toString();363 bootCommand(context, arg, true);364 365 else4. ./frameworks/base/core/java/android/os/RecoverySystem.java:452 60 public class RecoverySystem .452 private static void bootCommand(Context context, String arg, Boolean update) throws IOException 453 RECOVERY_DIR.mkdirs(); / In case we need it454 COMMAND_FILE.delete(); / In case its not writable455 LOG_FILE.delete();456 457 FileWriter command = new FileWriter(COMMAND_FILE);458 try 459 command.write(arg);460 command.write(n);461 finally 462 command.close();463 464 465 / Having written the command file, go ahead and reboot466 PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);467 if(update)468 pm.reboot(update);469 else470 pm.reboot(recovery);471 472 throw new IOException(Reboot failed (no permissions?);473 5. ./frameworks/base/services/java/com/android/server/power/PowerManagerService.java:364 79 public final class PowerManagerService extends IPowerManager.Stub 80 implements Watchdog.Monitor . 364 private static native void nativeReboot(String reason) throws IOException;6. ./frameworks/base/services/jni/com_android_server_power_PowerManagerService.cpp:277277 static void nativeReboot(JNIEnv *env, jclass clazz, jstring reason) 278 if (!closeCPU1()279 return;280 if (reason = NULL) 281 android_reboot(ANDROID_RB_RESTART, 0, 0);282 else 283 const char *chars = env-GetStringUTFChars(reason, NULL);284 android_reboot(ANDROID_RB_RESTART2, 0, (char *) chars);285 env-ReleaseStringUTFChars(reason, chars); / In case it fails.286 287 jniThrowIOException(env, errno);288 293 static JNINativeMethod gPowerManagerServiceMethods = 294 /* name, signature, funcPtr */295 nativeInit, ()V,296 (void*) nativeInit ,297 nativeSetPowerState, (ZZ)V,298 (void*) nativeSetPowerState ,299 nativeAcquireSuspendBlocker, (Ljava/lang/String;)V,300 (void*) nativeAcquireSuspendBlocker ,301 nativeReleaseSuspendBlocker, (Ljava/lang/String;)V,302 (void*) nativeReleaseSuspendBlocker ,303 nativeSetInteractive, (Z)V,304 (void*) nativeSetInteractive ,305 nativeSetAutoSuspend, (Z)V,306 (void*) nativeSetAutoSuspend ,307 nativeShutdown, ()V,308 (void*) nativeShutdown ,309 nativeReboot, (Ljava/lang/String;)V,310 (void*) nativeReboot ,311 ;7. android层最终调用了_reboot函数,_reboot函数就是上文的系统调用,arg参数升级时为“update”,恢复出厂设置时为“recovery”,在recovery源码中也有android_reboot的调用,如recovery.cpp,usb_burning.cpp104 intandroid_reboot(int cmd, int flags, char *arg)105 106 int ret;107108 if (!(flags & ANDROID_RB_FLAG_NO_SYNC)109 sync();110111 if (!(flags & ANDROID_RB_FLAG_NO_REMOUNT_RO)112 remount_ro();113114 switch (cmd) 115 case ANDROID_RB_RESTART:116 ret = reboot(RB_AUTOBOOT);117 break;118119 case ANDROID_RB_POWEROFF:120 ret = reboot(RB_POWER_OFF);121 break;122123 case ANDROID_RB_RESTART2:124 ret = _reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,125 LINUX_REBOOT_CMD_RESTART2, arg);126 break;127128 default:129 ret = -1;130 131132 return ret;133 8. 实现方法如下:android中的bionic库对每个系统调用都对应一个.S汇编文件,通过软中断实现,如_reboot.S#include #include ENTRY(_reboot) .save r4, r7 stmfd sp!, r4, r7 ldr r7, =_NR_reboot /中断向量表中的中断号 swi #0 ldmfd sp!, r4, r7 movs r0, r0 bxpl lr b _set_syscall_errnoEND(_reboot)9. 入口函数为./common/kernel/sys.c文件中void kernel_restart(char *cmd) log为Restarting system with command update.就是说是通过以下的系统调用来实现reboot的,kernel_restart再往下跟踪代码会有调用arm_machine_restart的地方#define SYSCALL_DEFINE4(name, .) SYSCALL_DEFINEx(4, _#name, _VA_ARGS_)宏展开之后其实就是定义

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论