Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/bin/sh | 1 #!/bin/sh |
| 2 # | 2 # |
| 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 # | 6 # |
| 7 # For factory and auto update, after shell-ball self-extracts, this script is | 7 # For factory and auto update, after shell-ball self-extracts, this script is |
| 8 # called to update BIOS and EC firmware as per how many files are extracted. | 8 # called to update BIOS and EC firmware as per how many files are extracted. |
| 9 # To simply design, THIS SCRIPT MUST BE EXECUTED IN A R/W EXCLUSIVE TEMP FOLDER. | 9 # To simply design, THIS SCRIPT MUST BE EXECUTED IN A R/W EXCLUSIVE TEMP FOLDER. |
| 10 # AND ALL FILENAMES FOR INPUT AND OUTPUT MUST NOT CONTAIN SPACE. | 10 # AND ALL FILENAMES FOR INPUT AND OUTPUT MUST NOT CONTAIN SPACE. |
| 11 # | 11 # |
| 12 # Allowed commands are: | 12 # Allowed commands are: |
| 13 # - standard shell commands | 13 # - standard shell commands |
| 14 # - flashrom | 14 # - flashrom |
| 15 # - gbb_utility | 15 # - gbb_utility |
| 16 # - crossystem | 16 # - crossystem |
| 17 # All other special commands should be defined by a function in crosutil.sh. | 17 # All other special commands should be defined by a function in crosutil.sh. |
| 18 # | |
| 19 # Temporary files should be named as "_*" to prevent confliction | |
| 18 | 20 |
| 19 SCRIPT_BASE="$(dirname "$0")" | 21 SCRIPT_BASE="$(dirname "$0")" |
| 20 . "$SCRIPT_BASE/common.sh" | 22 . "$SCRIPT_BASE/common.sh" |
| 21 | 23 |
| 22 # Use bundled tools with highest priority, to prevent dependency when updating | 24 # Use bundled tools with highest priority, to prevent dependency when updating |
| 23 PATH=".:$PATH"; export PATH | 25 PATH=".:$PATH"; export PATH |
| 24 | 26 |
| 25 # ---------------------------------------------------------------------------- | 27 # ---------------------------------------------------------------------------- |
| 26 # Customization Section | 28 # Customization Section |
| 27 | 29 |
| 28 # Customization script file name - do not change this. | 30 # Customization script file name - do not change this. |
| 29 # You have to create a file with this name to put your customization. | 31 # You have to create a file with this name to put your customization. |
| 30 CUSTOMIZATION_SCRIPT="updater_custom.sh" | 32 CUSTOMIZATION_SCRIPT="updater_custom.sh" |
| 31 | 33 |
| 32 # Customization script main entry - do not change this. | 34 # Customization script main entry - do not change this. |
| 33 # You have to define a function with this name to run your customization. | 35 # You have to define a function with this name to run your customization. |
| 34 CUSTOMIZATION_MAIN="updater_custom_main" | 36 CUSTOMIZATION_MAIN="updater_custom_main" |
| 35 | 37 |
| 38 # Customization script "RW compatible check" function. | |
| 39 # Overrides this with any function names to test if RW firmware in current | |
| 40 # system is compatible with this updater. The function must returns $FLAGS_FALSE | |
| 41 # if RW is not compatible (i.e., need incompatible_update mode) | |
| 42 CUSTOMIZATION_RW_COMPATIBLE_CHECK="" | |
| 43 | |
| 36 # Override this with the name with RO_FWID prefix. | 44 # Override this with the name with RO_FWID prefix. |
| 37 # Updater will stop and give error if the platform does not match. | 45 # Updater will stop and give error if the platform does not match. |
| 38 TARGET_PLATFORM="" | 46 TARGET_PLATFORM="" |
| 39 | 47 |
| 40 # ---------------------------------------------------------------------------- | 48 # ---------------------------------------------------------------------------- |
| 41 # Constants | 49 # Constants |
| 42 | 50 |
| 43 # Slot names defined by ChromeOS Firmware Specification | 51 # Slot names defined by ChromeOS Firmware Specification |
| 44 SLOT_A="RW_SECTION_A" | 52 SLOT_A="RW_SECTION_A" |
| 45 SLOT_B="RW_SECTION_B" | 53 SLOT_B="RW_SECTION_B" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 71 HWID="$(crossystem hwid 2>/dev/null || true)" | 79 HWID="$(crossystem hwid 2>/dev/null || true)" |
| 72 FWID="$(crossystem fwid 2>/dev/null || true)" | 80 FWID="$(crossystem fwid 2>/dev/null || true)" |
| 73 PLATFORM="$(crossystem ro_fwid 2>/dev/null | sed 's/\..*//' || true)" | 81 PLATFORM="$(crossystem ro_fwid 2>/dev/null | sed 's/\..*//' || true)" |
| 74 [ -n "$PLATFORM" ] || PLATFORM="<Unknown>" | 82 [ -n "$PLATFORM" ] || PLATFORM="<Unknown>" |
| 75 | 83 |
| 76 # ---------------------------------------------------------------------------- | 84 # ---------------------------------------------------------------------------- |
| 77 # Parameters | 85 # Parameters |
| 78 | 86 |
| 79 DEFINE_string mode "" \ | 87 DEFINE_string mode "" \ |
| 80 "Updater mode ( startup | bootok | autoupdate | todev | recovery |"\ | 88 "Updater mode ( startup | bootok | autoupdate | todev | recovery |"\ |
| 81 " factory_install | factory_final )" "m" | 89 " factory_install | factory_final | incompatible_update )" "m" |
| 82 DEFINE_boolean debug $FLAGS_FALSE "Enable debug messages." "d" | 90 DEFINE_boolean debug $FLAGS_FALSE "Enable debug messages." "d" |
| 83 DEFINE_boolean verbose $FLAGS_TRUE "Enable verbose messages." "v" | 91 DEFINE_boolean verbose $FLAGS_TRUE "Enable verbose messages." "v" |
| 84 DEFINE_boolean dry_run $FLAGS_FALSE "Enable dry-run mode." "" | 92 DEFINE_boolean dry_run $FLAGS_FALSE "Enable dry-run mode." "" |
| 85 | 93 |
| 86 DEFINE_boolean update_ec $FLAGS_TRUE "Enable updating for Embedded Firmware." "" | 94 DEFINE_boolean update_ec $FLAGS_TRUE "Enable updating for Embedded Firmware." "" |
| 87 DEFINE_boolean update_main $FLAGS_TRUE "Enable updating for Main Firmware." "" | 95 DEFINE_boolean update_main $FLAGS_TRUE "Enable updating for Main Firmware." "" |
| 88 | 96 |
| 89 # RO update flags are usually enabled only in customization. | 97 # RO update flags are usually enabled only in customization. |
| 90 DEFINE_boolean update_ro_main $FLAGS_FALSE \ | 98 DEFINE_boolean update_ro_main $FLAGS_FALSE \ |
| 91 "Allow updating RO section of Main Firmware" | 99 "Allow updating RO section of Main Firmware" |
| 92 DEFINE_boolean update_ro_ec $FLAGS_FALSE \ | 100 DEFINE_boolean update_ro_ec $FLAGS_FALSE \ |
| 93 "Allow updating RO section of EC Firmware" | 101 "Allow updating RO section of EC Firmware" |
| 94 | 102 |
| 95 DEFINE_boolean check_keys $FLAGS_TRUE "Check firmware keys before updating." "" | 103 DEFINE_boolean check_keys $FLAGS_TRUE "Check firmware keys before updating." "" |
| 96 DEFINE_boolean check_wp $FLAGS_TRUE \ | 104 DEFINE_boolean check_wp $FLAGS_TRUE \ |
| 97 "Check if write protection is enabled before updating RO sections" "" | 105 "Check if write protection is enabled before updating RO sections" "" |
| 106 DEFINE_boolean check_rw_compatible $FLAGS_TRUE \ | |
| 107 "Check if RW firmware is compatible with current RO" "" | |
| 98 DEFINE_boolean check_devfw $FLAGS_TRUE \ | 108 DEFINE_boolean check_devfw $FLAGS_TRUE \ |
| 99 "Check if developer firmware is activated and bypass updates" "" | 109 "Bypass firmware updates if active firmware type is developer" "" |
| 100 | |
| 101 # Required for factory compatibility | 110 # Required for factory compatibility |
| 102 DEFINE_boolean factory $FLAGS_FALSE "Equivalent to --mode=factory_install" | 111 DEFINE_boolean factory $FLAGS_FALSE "Equivalent to --mode=factory_install" |
| 103 | 112 |
| 104 # ---------------------------------------------------------------------------- | 113 # ---------------------------------------------------------------------------- |
| 105 # General Updater | 114 # General Updater |
| 106 | 115 |
| 107 # Update Main Firmware (BIOS, SPI) | 116 # Update Main Firmware (BIOS, SPI) |
| 108 update_mainfw() { | 117 update_mainfw() { |
| 109 # Syntax: update_mainfw SLOT FIRMWARE_SOURCE_TYPE | 118 # Syntax: update_mainfw SLOT FIRMWARE_SOURCE_TYPE |
| 110 # Write assigned type (normal/developer) of firmware source into | 119 # Write assigned type (normal/developer) of firmware source into |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 # NOTE: live may not have FMAP if it's not H2C, so backup+restore won't work. | 175 # NOTE: live may not have FMAP if it's not H2C, so backup+restore won't work. |
| 167 alert "Warning: VPD preserving is not implemented yet." | 176 alert "Warning: VPD preserving is not implemented yet." |
| 168 } | 177 } |
| 169 | 178 |
| 170 preserve_hwid() { | 179 preserve_hwid() { |
| 171 [ -s "$IMAGE_MAIN" ] || err_die "preserve_hwid: no main firmware." | 180 [ -s "$IMAGE_MAIN" ] || err_die "preserve_hwid: no main firmware." |
| 172 silent_invoke "gbb_utility -s --hwid='$HWID' $IMAGE_MAIN" | 181 silent_invoke "gbb_utility -s --hwid='$HWID' $IMAGE_MAIN" |
| 173 } | 182 } |
| 174 | 183 |
| 175 obtain_bmpfv() { | 184 obtain_bmpfv() { |
| 176 silent_invoke "flashrom $TARGET_OPT_MAIN -i GBB:gbb.bin -r temp.rom" | 185 silent_invoke "flashrom $TARGET_OPT_MAIN -i GBB:_gbb.bin -r _temp.rom" |
| 177 silent_invoke "gbb_utility -g --bmpfv=bmpfv.bin gbb.bin" | 186 silent_invoke "gbb_utility -g --bmpfv=_bmpfv.bin _gbb.bin" |
| 178 } | 187 } |
| 179 | 188 |
| 180 preserve_bmpfv() { | 189 preserve_bmpfv() { |
| 181 [ -s "$IMAGE_MAIN" ] || err_die "preserve_bmpfv: no main firmware." | 190 [ -s "$IMAGE_MAIN" ] || err_die "preserve_bmpfv: no main firmware." |
| 182 [ -s bmpfv.bin ] || return | 191 [ -s _bmpfv.bin ] || return |
| 183 silent_invoke "gbb_utility -s --bmpfv=bmpfv.bin $IMAGE_MAIN" | 192 silent_invoke "gbb_utility -s --bmpfv=_bmpfv.bin $IMAGE_MAIN" |
| 184 } | 193 } |
| 185 | 194 |
| 186 # Compares two slots from current and target folder. | 195 # Compares two slots from current and target folder. |
| 187 is_equal_slot() { | 196 is_equal_slot() { |
| 188 check_param "is_equal_slot(type, slot)" "$@" | 197 check_param "is_equal_slot(type, slot)" "$@" |
| 189 local type_name="$1" slot_name="$2" | 198 local type_name="$1" slot_name="$2" |
| 190 local current="$DIR_CURRENT/$type_name/$slot_name" | 199 local current="$DIR_CURRENT/$type_name/$slot_name" |
| 191 local target="$DIR_TARGET/$type_name/$slot_name" | 200 local target="$DIR_TARGET/$type_name/$slot_name" |
| 192 cros_compare_file "$current" "$target" | 201 cros_compare_file "$current" "$target" |
| 193 } | 202 } |
| 194 | 203 |
| 195 # Verifies if current system is installed with compatible rootkeys | 204 # Verifies if current system is installed with compatible rootkeys |
| 196 check_compatible_keys() { | 205 check_compatible_keys() { |
| 197 local current_image="$DIR_CURRENT/$IMAGE_MAIN" | 206 local current_image="$DIR_CURRENT/$IMAGE_MAIN" |
| 198 local target_image="$DIR_TARGET/$IMAGE_MAIN" | 207 local target_image="$DIR_TARGET/$IMAGE_MAIN" |
| 199 if [ "${FLAGS_check_keys}" = "${FLAGS_FALSE}" ]; then | 208 if [ "${FLAGS_check_keys}" = "${FLAGS_FALSE}" ]; then |
| 200 debug_msg "check_compatible_keys: ignored." | 209 debug_msg "check_compatible_keys: ignored." |
| 201 return $FLAGS_TRUE | 210 return $FLAGS_TRUE |
| 202 fi | 211 fi |
| 203 if ! cros_check_same_root_keys "$current_image" "$target_image"; then | 212 if ! cros_check_same_root_keys "$current_image" "$target_image"; then |
| 204 err_die "Incompatible firmware image (Root key is different). | 213 err_die " |
| 214 Incompatible firmware image (Root key is different). | |
| 215 | |
| 205 You may need to disable hardware write protection and perform a factory | 216 You may need to disable hardware write protection and perform a factory |
| 206 install by '--mode=factory' or recovery by '--mode=recovery'. | 217 install by '--mode=factory_install' or recovery by '--mode=recovery'. |
| 207 " | 218 " |
| 208 fi | 219 fi |
| 209 } | 220 } |
| 210 | 221 |
| 211 need_update_ro() { | 222 need_update_ro() { |
| 212 # Maybe this needs an override on future systems, so make it an | 223 # Maybe this needs an override on future systems, so make it an |
| 213 # extra function. | 224 # extra function. |
| 214 # For now, just always assume true, and let flashrom figure out | 225 # For now, just always assume true, and let flashrom figure out |
| 215 # whether an update is actually needed | 226 # whether an update is actually needed |
| 216 true | 227 true |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 # decreasing of the "startup_update_tries" should be done inside | 343 # decreasing of the "startup_update_tries" should be done inside |
| 333 # chromeos_startup. | 344 # chromeos_startup. |
| 334 if [ "${FLAGS_update_main}" = ${FLAGS_TRUE} ] && | 345 if [ "${FLAGS_update_main}" = ${FLAGS_TRUE} ] && |
| 335 [ "${FLAGS_update_ro_main}" = "${FLAGS_TRUE}" ]; then | 346 [ "${FLAGS_update_ro_main}" = "${FLAGS_TRUE}" ]; then |
| 336 alert_write_protection | 347 alert_write_protection |
| 337 prepare_main_image | 348 prepare_main_image |
| 338 # We can allow updating multiple sections at once, but that may lead system | 349 # We can allow updating multiple sections at once, but that may lead system |
| 339 # into unknown state if crashed during the large update, so let's update | 350 # into unknown state if crashed during the large update, so let's update |
| 340 # step-by-step. | 351 # step-by-step. |
| 341 update_mainfw "$SLOT_RO" | 352 update_mainfw "$SLOT_RO" |
| 342 update_mainfw "$SLOT_A" | 353 if [ "$(cros_get_prop mainfw_type)" = "developer" ]; then |
| 354 update_mainfw "$SLOT_A" "$FWSRC_DEVELOPER" | |
| 355 else | |
| 356 update_mainfw "$SLOT_A" "$FWSRC_NORMAL" | |
| 357 fi | |
| 343 update_mainfw "$SLOT_B" | 358 update_mainfw "$SLOT_B" |
| 344 update_mainfw "$SLOT_RW_SHARED" | 359 update_mainfw "$SLOT_RW_SHARED" |
| 345 fi | 360 fi |
| 346 | 361 |
| 347 if [ "${FLAGS_update_ec}" = ${FLAGS_TRUE} ]; then | 362 if [ "${FLAGS_update_ec}" = ${FLAGS_TRUE} ]; then |
| 348 prepare_ec_image | 363 prepare_ec_image |
| 349 if [ "${FLAGS_update_ro_ec}" = "${FLAGS_TRUE}" ]; then | 364 if [ "${FLAGS_update_ro_ec}" = "${FLAGS_TRUE}" ]; then |
| 350 alert_write_protection | 365 alert_write_protection |
| 351 update_ecfw "$SLOT_EC_RO" | 366 update_ecfw "$SLOT_EC_RO" |
| 352 fi | 367 fi |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 433 return | 448 return |
| 434 fi | 449 fi |
| 435 } | 450 } |
| 436 | 451 |
| 437 # Transition to Developer Mode | 452 # Transition to Developer Mode |
| 438 mode_todev() { | 453 mode_todev() { |
| 439 if [ "${FLAGS_update_main}" != "${FLAGS_TRUE}" ]; then | 454 if [ "${FLAGS_update_main}" != "${FLAGS_TRUE}" ]; then |
| 440 err_die "Cannot switch to developer mode due to missing main firmware" | 455 err_die "Cannot switch to developer mode due to missing main firmware" |
| 441 fi | 456 fi |
| 442 prepare_main_image | 457 prepare_main_image |
| 443 # TODO(hungte) make sure the keys are compatible. | 458 prepare_main_current_image |
| 459 check_compatible_keys | |
| 444 update_mainfw "$SLOT_A" "$FWSRC_DEVELOPER" | 460 update_mainfw "$SLOT_A" "$FWSRC_DEVELOPER" |
| 445 cros_set_fwb_tries 0 | 461 cros_set_fwb_tries 0 |
| 446 cros_reboot | 462 cros_reboot |
| 447 } | 463 } |
| 448 | 464 |
| 449 # Recovery Installer | 465 # Recovery Installer |
| 450 mode_recovery() { | 466 mode_recovery() { |
| 451 if [ "${FLAGS_update_main}" = "${FLAGS_TRUE}" ]; then | 467 if [ "${FLAGS_update_main}" = "${FLAGS_TRUE}" ]; then |
| 452 prepare_main_image | 468 prepare_main_image |
| 453 debug_msg "mode_recovery: udpate main" | 469 debug_msg "mode_recovery: udpate main" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 513 # TODO(hungte) Write protection is currently made by | 529 # TODO(hungte) Write protection is currently made by |
| 514 # factory_EnableWriteProtect. We may move that into here in the future. | 530 # factory_EnableWriteProtect. We may move that into here in the future. |
| 515 # enable_write_protection | 531 # enable_write_protection |
| 516 # verify_write_protection | 532 # verify_write_protection |
| 517 } | 533 } |
| 518 | 534 |
| 519 drop_lock() { | 535 drop_lock() { |
| 520 rm -f /tmp/chromeos-firmwareupdate-running | 536 rm -f /tmp/chromeos-firmwareupdate-running |
| 521 } | 537 } |
| 522 | 538 |
| 523 # Updates from incompatible firmware versions | 539 # Updates for incompatible RW firmware (need to update RO) |
| 524 mode_incompatible_update() { | 540 mode_incompatible_update() { |
| 525 if is_mainfw_write_protected || is_ecfw_write_protected; then | 541 if is_mainfw_write_protected || is_ecfw_write_protected; then |
| 526 # TODO(hungte) check if we really need to stop user by comparing firmware | 542 # TODO(hungte) check if we really need to stop user by comparing firmware |
| 527 # image, bit-by-bit. | 543 # image, bit-by-bit. |
| 528 err_die "You need to first disable hardware write protection switch." | 544 err_die "You need to first disable hardware write protection switch." |
| 529 fi | 545 fi |
| 530 if [ "${FLAGS_update_main}" = "${FLAGS_TRUE}" ]; then | 546 if [ "${FLAGS_update_main}" = "${FLAGS_TRUE}" ]; then |
| 531 prepare_main_image | 547 prepare_main_image |
| 532 preserve_vpd | 548 preserve_vpd |
| 533 # Preserve BMPFV | 549 # Preserve BMPFV |
| 534 obtain_bmpfv | 550 obtain_bmpfv |
| 535 preserve_bmpfv | 551 preserve_bmpfv |
| 536 update_mainfw | 552 update_mainfw |
| 537 if [ "$(cros_get_prop mainfw_type)" != "developer" ]; then | 553 if [ "$(cros_get_prop mainfw_type)" != "developer" ]; then |
| 538 # and now overwrite slot a firmware with normal | 554 # and now overwrite slot a firmware with normal |
| 539 update_mainfw "$SLOT_A" "$FWSRC_NORMAL" | 555 update_mainfw "$SLOT_A" "$FWSRC_NORMAL" |
| 540 fi | 556 fi |
| 541 fi | 557 fi |
| 542 if [ "${FLAGS_update_ec}" = "${FLAGS_TRUE}" ]; then | 558 if [ "${FLAGS_update_ec}" = "${FLAGS_TRUE}" ]; then |
| 543 update_ecfw | 559 update_ecfw |
| 544 fi | 560 fi |
| 561 | |
| 562 # Clean any further updates | |
| 563 cros_set_fwb_tries 0 | |
| 564 cros_set_startup_update_tries 0 | |
| 565 | |
| 566 # incompatible_update may be redirected from a "startup" update, which expects | |
| 567 # a reboot after update complete. | |
| 568 if [ "${FLAGS_mode}" = "startup" ]; then | |
| 569 cros_reboot | |
| 570 fi | |
| 545 } | 571 } |
| 546 | 572 |
| 547 # ---------------------------------------------------------------------------- | 573 # ---------------------------------------------------------------------------- |
| 548 # Main Entry | 574 # Main Entry |
| 549 | 575 |
| 576 main_check_rw_compatible() { | |
| 577 local try_autoupdate="$1" | |
| 578 if [ "${FLAGS_check_rw_compatible}" = "${FLAGS_FALSE}" ]; then | |
| 579 verbose_msg "Bypassed RW compatbility check. You're on your own." | |
| 580 return $FLAGS_TRUE | |
| 581 fi | |
| 582 | |
| 583 if [ -z "$CUSTOMIZATION_RW_COMPATIBLE_CHECK" ]; then | |
| 584 debug_msg "No compatibility check rules defined in customization." | |
| 585 return $FLAGS_TRUE | |
| 586 fi | |
| 587 | |
| 588 local is_compatible="${FLAGS_TRUE}" | |
| 589 debug_msg "Checking customized RW compatibility..." | |
| 590 "$CUSTOMIZATION_RW_COMPATIBLE_CHECK" || is_compatible="${FLAGS_FALSE}" | |
| 591 if [ "$is_compatible" = "${FLAGS_TRUE}" ]; then | |
| 592 return $FLAGS_TRUE | |
| 593 fi | |
| 594 | |
| 595 verbose_msg "RW firmware update is not compatible with current RO firmware." | |
| 596 verbose_msg "Need to update RO (RW incompatible mode update)." | |
| 597 | |
| 598 if [ "$try_autoupdate" = "$FLAGS_FALSE" ]; then | |
| 599 # No need to print anything in this case. | |
| 600 return $FLAGS_FALSE | |
| 601 fi | |
| 602 | |
| 603 if is_developer_firmware; then | |
| 604 try_autoupdate=$FLAGS_FALSE | |
| 605 verbose_msg "Developer firmware detected - not scheduling auto updates." | |
| 606 else | |
| 607 # Try to schedule an autoupdate. | |
| 608 (cros_set_startup_update_tries 6) || try_autoupdate="${FLAGS_FALSE}" | |
| 609 fi | |
| 610 | |
| 611 alert_incompatible_firmware "$try_autoupdate" | |
| 612 return $FLAGS_FALSE | |
| 613 } | |
| 614 | |
| 550 main() { | 615 main() { |
| 551 if [ -r /tmp/chromeos-firmwareupdate-running ]; then | 616 if [ -r /tmp/chromeos-firmwareupdate-running ]; then |
| 552 err_die "chromeos-firmwareupdate is already running. Please retry later." | 617 err_die "chromeos-firmwareupdate is already running. Please retry later." |
| 553 fi | 618 fi |
| 554 touch /tmp/chromeos-firmwareupdate-running | 619 touch /tmp/chromeos-firmwareupdate-running |
| 555 | 620 |
| 556 # Clean up on regular or error exits. | 621 # Clean up on regular or error exits. |
| 557 trap drop_lock EXIT | 622 trap drop_lock EXIT |
| 558 | 623 |
| 559 # factory compatibility | 624 # factory compatibility |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 588 alert_unknown_platform "$PLATFORM" "$TARGET_PLATFORM" | 653 alert_unknown_platform "$PLATFORM" "$TARGET_PLATFORM" |
| 589 exit 1 | 654 exit 1 |
| 590 fi | 655 fi |
| 591 | 656 |
| 592 # invoke customization | 657 # invoke customization |
| 593 debug_msg "starting customized updater main..." | 658 debug_msg "starting customized updater main..." |
| 594 $CUSTOMIZATION_MAIN | 659 $CUSTOMIZATION_MAIN |
| 595 fi | 660 fi |
| 596 | 661 |
| 597 case "${FLAGS_mode}" in | 662 case "${FLAGS_mode}" in |
| 598 startup | bootok | autoupdate | todev | recovery | \ | 663 # Modes which can attempt to update RO if RO+RW are not compatible. |
| 599 incompatible_update | factory_install | factory_final ) | 664 startup | recovery ) |
| 600 debug_msg "mode: ${FLAGS_mode}" | 665 debug_msg "mode allowing compatibility update: ${FLAGS_mode}" |
| 666 if main_check_rw_compatible $FLAGS_FALSE; then | |
| 667 mode_"${FLAGS_mode}" | |
| 668 else | |
| 669 verbose_msg "Starting a RW incompatible mode update..." | |
| 670 mode_incompatible_update | |
| 671 fi | |
| 672 ;; | |
| 673 | |
| 674 # Modes which update RW firmware only; these need to verify if existing RO | |
| 675 # firmware is compatible. If not, schedule a RO+RW update at next startup. | |
| 676 autoupdate | bootok | todev ) | |
| 677 debug_msg "mode with compatibility check: ${FLAGS_mode}" | |
| 678 if main_check_rw_compatible $FLAGS_TRUE; then | |
| 679 mode_"${FLAGS_mode}" | |
| 680 fi | |
| 681 ;; | |
| 682 | |
| 683 # Modes which don't mix existing RO firmware with new RW firmware from the | |
| 684 # updater. They either copy RW firmware between EEPROM slots, or copy both | |
| 685 # RO+RW from the shellball. Either way, RO+RW compatibility is assured. | |
| 686 factory_install | factory_final | incompatible_update ) | |
| 687 debug_msg "mode without incompatible checks: ${FLAGS_mode}" | |
| 601 mode_"${FLAGS_mode}" | 688 mode_"${FLAGS_mode}" |
| 602 ;; | 689 ;; |
| 690 | |
|
Stefan Reinauer
2011/04/07 16:22:04
drop empty line?
Hung-Te
2011/04/07 16:38:21
Done.
| |
| 603 "" ) | 691 "" ) |
| 604 err_die "Please assign updater mode by --mode option." | 692 err_die "Please assign updater mode by --mode option." |
| 605 ;; | 693 ;; |
| 606 * ) | 694 * ) |
| 607 err_die "Unknown mode: ${FLAGS_mode}" | 695 err_die "Unknown mode: ${FLAGS_mode}" |
| 608 ;; | 696 ;; |
| 609 esac | 697 esac |
| 610 verbose_msg "Firmware update (${FLAGS_mode}) completed." | 698 verbose_msg "Firmware update (${FLAGS_mode}) completed." |
| 611 } | 699 } |
| 612 | 700 |
| 613 # Parse command line | 701 # Parse command line |
| 614 FLAGS "$@" || exit 1 | 702 FLAGS "$@" || exit 1 |
| 615 eval set -- "$FLAGS_ARGV" | 703 eval set -- "$FLAGS_ARGV" |
| 616 | 704 |
| 617 # Exit on error | 705 # Exit on error |
| 618 set -e | 706 set -e |
| 619 | 707 |
| 620 # Main Entry | 708 # Main Entry |
| 621 main | 709 main |
| OLD | NEW |