summaryrefslogtreecommitdiff
path: root/tests/futility/test_update.sh
Commit message (Collapse)AuthorAgeFilesLines
* futility: updater: Unit test for preserving sections using FMAP flagsHung-Te Lin2019-03-121-0/+18
| | | | | | | | | | | | | | | | | | | | | In CL:1495054 the updater has different logic when the firmware image has FMAP_AREA_PRESERVE in FMAP flags. This needs to be verified in unit test. The new test tries to set 010=0x08 (FMAP_AREA_PRESERVE) in RO_VPD area flag but not RW_VPD, with RO and RW VPD both being provisioned in source (from) image. The legacy path would update both while the new path will only update RO, so we can make sure the flag-based preservation is working as expected. BUG=chromium:936768 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I07d232444344397b80344ccc9b56f8af3256e043 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1514452 Reviewed-by: Joel Kitching <kitching@chromium.org>
* futility: updater: Report key hash on TPM failureHung-Te Lin2019-03-121-2/+2
| | | | | | | | | | | | | | | | | | | | | When write protection is not enabled and updater sees TPM Anti-Rollback failure, the log will only report TPM failure (example: crbug.com/937961). This is hard to figure out if the failure was caused by re-key or other reasons. In try-rw and rw update, the updater will always check rootkey compatibility before checking TPM anti-rollback, so we should do the same thing on full update (RO+RW). With this change, the updater will report key mismatch before failing with TPM anti-rollback. BUG=chromium:937961 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I2f035450995387b198f990467e4f416e6c7b746e Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1514007 Reviewed-by: Joel Kitching <kitching@chromium.org>
* futility: updater: Use model name as default whitelabel signaturestabilize-11895.95.Bstabilize-11895.89.Bstabilize-11895.72.Bstabilize-11895.118.Bstabilize-11895.109.Bstabilize-11895.108.Brelease-R74-11895.BHung-Te Lin2019-03-071-0/+13
| | | | | | | | | | | | | | | In Unibuild, the white label models may use (per model) PreMP key for devices without VPD 'whitelabel_tag' - this helps dogfooders and lab machines to run and update properly. BUG=b:126800200 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=none Change-Id: I7249e3fb1a2b7ab8ed281d2aa317aee6cde8f8db Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1501614 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
* futility: updater: Improve error message when key conflictsHung-Te Lin2019-02-131-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many firmware developers will try to flash a local built firmware (i.e, DEV key signed) on a MP device (with write protection enabled). The updater used to provide feedback like: ERROR: verify_keyblock: Failed verifying key block. INFO: Current (RO) firmware image has root key: ade780ffd0...732867181bae WARNING: Target (RW) image is signed by rootkey: b11d74edd2...e1135b49e7f0. ERROR: RW not signed by same RO root key >> FAILED: Firmware updater aborted. This is correctly identifying the root cause, but not helpful for developers to figure out what to do, and may be confused with the DEV re-key safety check (which needs --force). Also, when developers try to do "--mode=factory --force", the message was: updater_setup_config: Factory mode needs WP disabled. Where the 'WP' is again not clear enough. With this change, we're improving the error messages so that: - Being consistent on 'root key' instead of 'rootkey'. - Being consistent for having period for error messages, except those ended with root key hash (for easier copy-paste). - Say 'Write Protection' instead of 'WP'. - When re-keying with WP enabled, print a better hint: "To change keys in RO area, you have to first remove write protection (https://goo.gl/ces83U)." BUG=None TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=none Change-Id: Ia74d7b113766d09428a4d0897918b4f17b4afae7 Reviewed-on: https://chromium-review.googlesource.com/1465709 Commit-Ready: Hung-Te Lin <hungte@chromium.org> Tested-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Matthew Blecker <matthewb@chromium.org>
* futility: updater: Correct HWID digest when preserving HWIDstabilize-11647.70.Bstabilize-11647.104.Brelease-R73-11647.BHung-Te Lin2019-01-161-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | Starting from GBB 1.2, a digest is stored in GBB and must be updated whenever the HWID string is changed. In shell script version of updater, the digest is automatically updated when we do "futility gbb -s --hwid=XXX", but in native updater implementation we only updated the HWID string and left digest unchanged, this leaves devices generating wrong PCR1 values. `cmd_gbb_utility` updates the digest by calling `update_hwid_digest` using vboot1 structure, so we should introduce a new vboot2 friendly function, `vb2_change_hwid`, which changes both HWID string and digest at same time. Note this has no impact for end user's devices with write protection enabled. Only changes dogfood units AU results. BUG=b:122248649 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=none Change-Id: I6ad2754e6df3c9dd66d71c560a2afc26d14eae33 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1411932 Reviewed-by: Joel Kitching <kitching@chromium.org>
* futility: update: Fix 'smm_store' unit testHung-Te Lin2018-12-131-2/+2
| | | | | | | | | | | | | | In CL:1351178 the SMM store file name has been changed to 'smm_store' so we have to also change test script. BUG=b:120060878 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility Change-Id: Idc98517cc46a848bb77335214a11fbc9303590f2 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1375494 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Joel Kitching <kitching@chromium.org>
* futility: updater: Add 'image.bin' as host image name in archiveHung-Te Lin2018-12-111-16/+22
| | | | | | | | | | | | | | | | | | The firmware updater archive is going to rename the prefix of host (AP) firmware image from 'bios' to 'image' (CL:1318712), to be more consistent with firmware package output. We need to include both old and new names in updater manifest construction. For --mode=output, we will produce both 'bios.bin' and 'image.bin'. In future there should be only 'image.bin' after migration is completed. BUG=b:65745723 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I8b7e3bc2953b70525fb14fcf6aadaf6d1e00e4aa Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1327862
* futility: updater: Revise error message when model is not defined in manifeststabilize-11306.BHung-Te Lin2018-11-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | "Model '%s' is not defined in manifest." is not very easy to understand for people who are debugging devices in early stages. We should provide better instructions. For example, running with Coral updater will now show: ERROR: manifest_find_model: Cannot get model name. You are probably running an image for wrong board, or a device in early stage that 'mosys' command is not ready, or image from old (or factory) branches that Unified Build config is not updated yet for 'mosys'. Please check command 'mosys platform model', which should output one of the supported models below: unprovisioned_meep sparky orbatrix unprovisioned_fleex grabbiter bobba unprovisioned_bobba mimrock fleex meep yorp phaser360 sparky360 phaser bobba360 unprovisioned_phaser bip BUG=chromium:875551 TEST=TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: Ib17fcb654d1530b94c44cf21aaa28717841f11ed Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1351171 Reviewed-by: Cheng-Han Yang <chenghan@chromium.org> Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* futility: updater: Add new quirk 'allow_empty_wltag'Hung-Te Lin2018-11-241-0/+4
| | | | | | | | | | | | | | | There were devices shipped as "only device" (no key set) and then became one of the "white label" family. This is now no longer valid on newer devices but we have to support the legacy ones, for example Reks. BUG=chromium:906962 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I437be08726ab2c46229062689bf765ac6837ca5d Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1345610 Reviewed-by: Youcheng Syu <youcheng@chromium.org>
* futility: update: Add `--host_only` argumentHung-Te Lin2018-10-231-0/+5
| | | | | | | | | | | | | | | | | | | | | | | The legacy firmware updater can update explicitly only some type of images by using `--[no]update_main`, `--[no]update_ec`, `--[no]update_pd`. Since software sync is introduced, usually it does not make sense to only update EC or PD; instead the real request is to "ignore provided EC and PD images and update only host". The new `--host_only` argument provides an easy way to ignore images in command line (`--ec_image`, `--pd_image`) and archives (`ec.bin`, `pd.bin`). BUG=chromium:875551 TEST=TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: Idf403680880cd58a00867172ccec97fd60c1b826 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1295210 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: updater: Support --mode=output and --output_dirHung-Te Lin2018-10-221-0/+13
| | | | | | | | | | | | | | For backward compatibility, we need to support the 'output' mode in legacy firmware updater. The output must select right files according to system model, and apply all white label transform if needed. BUG=chromium:875551 TEST=TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: Ib433647317fa97387aa4a7f8f2101b47e6ca2123 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1282084
* futility: updater: Support white label from VPD and --signature_idHung-Te Lin2018-10-221-3/+44
| | | | | | | | | | | | | | | | | | | | For white label devices, we have to select and patch key files (root key and vblock) by VPD (`whitelabel_tag` or `customization_id`). The white label tag VPD will be processed and converted to a "signature ID" for key selection. To support that, updater has to fetch current (system) image if the matched model is following white label (so we can read VPD from it). For developers who want to load and use particular files, they can use --signature_id to override VPD values. BUG=chromium:875551 TEST=TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I3630bae28d1a8493b56d0e5efd29f3c61a470379 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1278420
* futility: updater: Add '--model' and select images by system modelHung-Te Lin2018-10-221-8/+30
| | | | | | | | | | | | | | | | | For devices using Unified Build, we have to select and load images from archive by model configuration (setvars.sh). The system model can be retrieved by $(mosys platform model), but for developers who want to simulate or get images for particular platform, a command line argument --model is needed. BUG=chromium:875551 TEST=TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I8f4a6735b34bc694a05808b001c7309623b2afa3 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1278419 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: updater: Do not preserve GBB flags in --factory mode.Hung-Te Lin2018-10-181-0/+12
| | | | | | | | | | | | | | | | | In RMA or factory reinstall flow, we will want to make sure device will next boot into developer mode, which was usually enforced by GBB flags. In updater4, this is done by updater using flags defined in target image. We should keep same behavior. BUG=b:117866155 TEST=TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: Idb6337d453d606dbf88b2a2b82961f21125b7fef Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1288211 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: updater: Add --manifest to scan and print archive infoHung-Te Lin2018-10-131-0/+4
| | | | | | | | | | | | | | | | | | | | | | | The firmware updater packages used to rely on a pre-generated VERSION file to report what files were included and their image versions. Its format was hard to parse, and may be out-dated if people repack without updating VERSION file. The firmware updater today has the ability to read and parse version, key hash, ... etc everything we need, so it seems more reasonable to just let firmware updater scan updater package and print the information in JSON format, so it will be very easy to fetch latest information. To make sure the output is purely JSON, the start and end messages are now sent to stderr instead of stdout. BUG=chromium:875551 TEST=TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: Ifa468fbb3adf798c7931f015258e6c6ce93de993 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1260804
* futility: updater: Add '--archive' to read from an archive or directoryHung-Te Lin2018-10-131-0/+7
| | | | | | | | | | | | | | | | | | | | | | A firmware update is usually released as a package with multiple images, instructions, signed vblocks and other files. To work with that, a new argument '--archive' is added. The --archive accepts a directory or file, and will determine the correct driver automatically. For resources (for example --image) in relative path, updater should find files from archive. Note in current implementation, only ZIP is supported for file type drivers (and need the system to have libzip already installed). BUG=chromium:875551 TEST=TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I6a91cbe73fb4ee203c5fa4607f6651a39ba854d5 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1253229 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: updater: Revise verbosity and error messagesHung-Te Lin2018-10-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | `futility` used to print debug messages to stdout, but there is a side effect that stdout may be buffered and then flush later than stderr. For example, when calling futility via ssh, we will see flashrom messages before any of futility's own messages. Also, many people want to get flashrom verbose messages (-V). With this change, when calling ERROR and DEBUG, we will always output to stderr. This also enables better parameter type checking. `-d` and `-v` both contribute to verbosity, that will be converted to -V's when calling flashrom. BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I1d22a8054fc43cdc5e6c7415e131cc9826fbff0c Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1251145
* futility: updater: Support reading main image from stdinHung-Te Lin2018-10-021-0/+4
| | | | | | | | | | | | | | | | | | "Can we make futility support stdin like flashrom? I typically flash with: ssh root@DUT flashrom -p host - < foo.bin" Yes we can: ssh root@DUT futility update -i - < foo.bin BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: Ib1ee5d4c882620e3b6f56fd5e4692b4829cf025a Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1251141 Reviewed-by: Raul E Rangel <rrangel@chromium.org>
* futility: updater: Preserve SMMSTORE and add quirk 'eve_smm_store'Hung-Te Lin2018-10-021-0/+15
| | | | | | | | | | | | | | | | | The 'SMM store' must be preserved during firmware update. On newer systems, this can be done by preserving FMAP section 'SMMSTORE' (CL:1221210). For Eve, the SMM store did not have its own FMAP section and needs to be reserved by explicit cbfstool calls. BRANCH=None BUG=b:70682365 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility Change-Id: Ica043f51de0170b5c40f61d059437b9572025e2e Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1250464 Reviewed-by: Joel Kitching <kitching@chromium.org>
* futility: update: Add --programmer to override flashrom programmer for servoHung-Te Lin2018-09-271-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | Many developers need to reflash or update firmware using servo, and the firmware logic has been complicated enough that simply calling 'flashrom -w image.bin -p $SERVO' will usually destroy many important settings, for example HWID, VPD, and other data provisioned in factory. It should be more convenient if we can use 'futility update' against servo. The '--programmer' provides first step - to override the flashrom programmer so we can read and write via special programmer (like servo). With this change, developers can reflash using: futility -p $SERVO -i $IMAGE --force --wp 0 BRANCH=None BUG=b:116326638 TEST=make futil; sudo tests/futility/run_test_scripts.sh $(pwd)/build/futility Change-Id: Iad4819ff8258086e1abb58fefd462d94050754d0 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1239817 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: update: Allow tpm_fwver=0 and allow --force to waive TPM checkHung-Te Lin2018-09-271-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | By b/116298359#comment3, we know the tpm_fwver may be zero if the firmware slot has been just created and no successful boots since last boot. This is very common for factory and recovery so we should consider 0 as "success". There is still possible in early or proto builds, the device may have vboot data structure changed so the updater calling vboot library cannot get tpm_fwver properly. Also for people who wants to re-key their devices with DEV firmware, we should allow waiving all TPM checks by --force. Also, in order to test that correctly, override_properties_from_list should accept negative values to simulate failure in getting tpm_fwver from VbGetSystemPropertyInt. BRANCH=None BUG=b:116298359 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility Change-Id: I09c91af36ceec340e393fb68999bea8d1907267d Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1239814 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: update: Skip TPM check if tpm_fwver is not valid.stabilize-11101.BHung-Te Lin2018-09-211-0/+8
| | | | | | | | | | | | | | | | | | | Ideally we should fail if `tpm_fwver` can't be retrieved, but if an user can run the updater then his system is already up so it's more likely to be a vboot library issue (especially in early proto devices) that the crossystem values were not reported correctly. As a result, it seems more reasonable to skip checking TPM anti-rollback if `tpm_fwver` can't be retrieved. BRANCH=None BUG=b:115764295 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility Change-Id: I7b6bf72531edb334a465c730fe8b3fbafa469b3a Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1238099 Reviewed-by: Joel Kitching <kitching@chromium.org>
* futility: update: Add legacy option '--factory'Hung-Te Lin2018-09-191-2/+10
| | | | | | | | | | | | | | | The '--factory' is an alias to '--mode=factory_install' and was widely used in several documents. Also moved WP check to end of argument parsing so '--mode=factory --wp=0' can set WP correctly. BRANCH=None BUG=b:115764295 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility Change-Id: I7987d77c577414efb03941442e3125f35ac5ad98 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1233373 Reviewed-by: Joel Kitching <kitching@chromium.org>
* futility: update: Fix update failure in factory mode due to wrong WP logicHung-Te Lin2018-09-181-0/+9
| | | | | | | | | | | | | | In --mode=factory, we should fail if write protection is enabled. Also added an unit test for the case. BRANCH=None BUG=b:115764295 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility Change-Id: I6c693e470a034554b1f4a3cb16cfbf974ae6f54b Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1226587 Reviewed-by: Marco Chen <marcochen@chromium.org>
* futility: cmd_update: Add quirk 'min_platform_version'Hung-Te Lin2018-09-101-1/+11
| | | | | | | | | | | | | | | | | | | | Many device may have some minor difference in early builds, for example (board id) rev 0 and rev 1 may have GPIO pins connected to different components. Usually the firmware should read board identifier and do the right mapping, but sometimes the firmware may be totally incompatible and no way to workaround (for example even the CPU may be different). The min_platform_version is introduced so we can prevent updating to incompatible systems, by reading $(mosys platform version). BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I418fee1aad884551b38ac25c340b2797b8503596 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1198815 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: cmd_update: Add quirk 'unlock_me_for_update'Hung-Te Lin2018-09-101-9/+19
| | | | | | | | | | | | | | | | | | | | On recent Intel platforms, flashing to SI_ME may get corrupted due to ME execution in parallel. If we lock SI_ME immediately (by writing the new SI_DESC), the device may fail to boot due to ME execution failure. As a result, a quirk is added so the firmware updater will never lock SI_ME. The Flash Master values are always unlocked when updating SI_ME, and after system reboot, a board-postinst script should check ME status and reflash SI_DESC only if SI_ME looks all good. BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I584aa373797e2b4c2608f07aac21c16cdb34a5c4 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1198807 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: cmd_update: Add quirk 'enlarge_image'Hung-Te Lin2018-09-101-3/+19
| | | | | | | | | | | | | | | | | Some devices may have shipped with a smaller image that the real flash may be larger, especially if the device's original flash has been EOL'ed. The quirk 'enlarge_image' allows changing image size according to current_image size by padding 0xFF (flash default value). BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I84373cfa9bcbd98a2cd96a7dd4bed27a6f724cf3 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1198806 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: cmd_update: Add --quirks for device-specific hacksHung-Te Lin2018-09-101-0/+10
| | | | | | | | | | | | | | | | | | | | | The firmware updater usually needs to apply many special rules for particular device, previously done by the 'updater_custom.sh' script. In futility updater, we want to support that by a 'quirks' system, that the updater package can declare a list of needed quirks and send to updater as `futility update --quirks LIST`. Currently only a dummy "test" quirks is defined. The real quirks will be added in follow up changes. BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: Ic935d69a54473f2347964e7c161ffcdc0af43ec6 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1198804 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: cmd_update: Add new 'legacy' modeHung-Te Lin2018-09-101-0/+8
| | | | | | | | | | | | | | | | | | | | | For devices that do not have update tag provisioned in legacy CBFS, we need a way to push and enforce the updater to complete first migration. The '--mode=legacy' provides a short cut to do "flashrom -p host -w image -i RW_LEGACY" Devices that need newer (or latest) legacy firmware should invoke firmware updater in their initialization or setup process, to enforce updating RW_LEGACY. BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I87db067ad134e82bbbdc937bd2880c6731ec892b Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1198808 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: cmd_update: Check RO and RW signing compatibility before updatingHung-Te Lin2018-09-051-0/+14
| | | | | | | | | | | | | | | | If the RW is not signed by RO root key then verified boot will fail and enter recovery mode. This may happen when user is trying to flash a DEV (or PreMP) signed firmware on a MP-signed device, with write protection enabled. BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I1cee0b5f42f1f403d9baa5f9b2659f75511fbcb8 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1183659 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: cmd_update: Check TPM key versions before updatingHung-Te Lin2018-09-051-11/+40
| | | | | | | | | | | | | | | | | | | In verified boot, the key versions stored in TPM will be checked before being able to load and run a signed RW firmware. This is also known as anti-rollback check. To prevent user installing an incompatible RO (even RW) and then being not able to boot, we should check TPM key versions (by `tpm_fwver` system property) before starting to update. BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I6d50a6e475001d76fbcbe680a3f8b10f62354096 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1189249 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: cmd_update: Check platform compatibility before updatingHung-Te Lin2018-09-051-2/+41
| | | | | | | | | | | | | | | | | | A safety check so people won't accidentally flashed wrong firmware image and then being not able to boot. The platform is decided by extracting the first component (delimited by dot '.') of firmware ID. For example, platform for "Google_Link.123" is "Google_Link". BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I90a1631f6b3e9a675fe1990cf9c204d763faf54c Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1189248 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: cmd_update: Add vboot1 updater logicHung-Te Lin2018-09-051-4/+13
| | | | | | | | | | | | | | | | | | There are still many devices running vboot1 and we need to support them as well. There is no way to determine if a firmware is vboot2 or not, so we can only rely on the system property "fw_vboot2". If fw_vboot2 is 0, then we should always update section B and compare content with section A. BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: Iefdcb81099914c2183c627a33eb73678d1269bc1 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1184952 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: cmd_update: Check contents before starting to updateHung-Te Lin2018-09-051-0/+4
| | | | | | | | | | | | | | | | | | In try-boot updating flow, we have to first check if RO content needs to be changed or not, and do full (ro+ro) update if WP is disabled. Also, before starting to update RW-A or RW-B, we should also check if the active system already has same firmware contents. An --force is also added to allow skipping the check. BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: Ie2f75f9aab4696c75aedafbf45e418ee98a2a4b4 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1183654 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: cmd_update: Preserve image sections before updateHung-Te Lin2018-09-011-0/+6
| | | | | | | | | | | | | | | | | When updating RO (or going to compare with contents), we need to preserve (copy) section data from system active firmware image. The `preserve_images` will try to preserve a list of known sections in full update (`--wp=0`) mode, so we VPD data and HWID won't be lost. BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh BRANCH=None Change-Id: I85c4ba972853dbc0fc101bee269c0effe70988b1 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1183653 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: cmd_update: Implement updater logic "TRY-RW" (--try)Hung-Te Lin2018-08-311-0/+15
| | | | | | | | | | | | | | | | | | | | In vboot2, to try one RW (unused) section on next boot, we have to: - Find mainfw_act - Select and update to the "other" slot - Set system property fw_try_{next,count} values to try in next boot. The new '--try' (-t) option can trigger the mode if available. BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility futility update --emulation FILE -i IMAGE -t --sys_prop 0; # Updates to B. futility update --emulation FILE -i IMAGE -t --sys_prop 1; # Updates to A. BRANCH=None Change-Id: I4b4662616a7181d2f37307238b7b80ae82369768 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1188017 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: cmd_update: Add 'mainfw_act' system propertyHung-Te Lin2018-08-311-0/+2
| | | | | | | | | | | | | | | | | | | Add the system property 'mainfw_act'. In both vboot1 and vboot2, the try-rw update process will need to figure out what is current (active) firmware slot, which is the "mainfw_act" system property. BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility futility --debug update -i IMAGE --sys_prop 0; futility --debug update -i IMAGE --sys_prop 1; BRANCH=None Change-Id: Ie745726107bff416549ba095a3defdd4cc98d32d Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1183652 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: cmd_update: Implement updater logic "RW UPDATE".Hung-Te Lin2018-08-311-1/+24
| | | | | | | | | | | | | | | | | | The logic is same as --mode=recovery,--wp=1 in legacy firmware updater. An debugging option '--wp' is introduced so user can easily switch between FULL UPDATE (--wp=0) or RW UPDATE (--wp=1). BUG=chromium:875551 TEST=make futil; futility update -i IMAGE --wp=0; futility update -i IMAGE --wp=1; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: Ic7d8aa8b327296988ebf80a8e737e8893b7870ea Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1188016 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: cmd_update: Add "system property" and '--sys_props' to overrideHung-Te Lin2018-08-311-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When updating firmware, we may need to get some system environment status, like which firmware slot was selected and boot (active), or setting cookies so the next boot will be using right (updated) slot. In verified boot, these status are manipulated by "system property" using API Vb{Get,Set}SystemProperty{String,Int}. The user land tool is `crossystem`. In order to run the firmware updater for testing and debugging, we need an easy way to toggle getting real system status, or fetch from predefined values. A new 'system_property' structure is introduced and included as part of `updater_config`. Each property can be access by `get_system_property(property_type)` function. If the value was not fetched yet, the function will call corresponding 'getter' function defined in property and then cache it. A new parameter '--sys_props` is also introduced so we can easily override them from command line so the updater will not get status from running system. The --sys_props takes a list of integers, eliminated by space or comma. For example, "1,2,3" => overrides [0]=1, [1]=2, [2]=3. "1 2,3" => overrides [0]=1, [1]=2, [2]=3. "1, ,3" => overrides [0]=1, [2]=3. BUG=chromium:875551 TEST=make futil; futility update -i IMAGE tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: Ia2e06a953da1480da9a94f7f397802caa7468efa Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1188015
* futility: cmd_update: Implement updater logic "FULL UPDATE".stabilize-atlas-11022.BHung-Te Lin2018-08-311-13/+25
| | | | | | | | | | | | | | | The logic is same as --mode=factory or --mode=recovery,--wp=0 in legacy firmware updater. BUG=chromium:875551 TEST=make futil; futility update -i IMAGE tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: Ifbfc4fb76f954483e779c8b508377d07561b67da Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1183651 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: cmd_update: Add '--emulate' optionHung-Te Lin2018-08-311-4/+13
| | | | | | | | | | | | | | | | | | To help debugging and testing, we may want to run updater against an image file instead of modifying real system firmware. The --emulate allows running with all checks and reading, and outputs to given file. BUG=chromium:875551 TEST=make futil; futility update -i IMAGE --emulate IMAGE2 tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: Ic52fe60a1468f29245cade70f859513d8d117c9c Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1184953 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: cmd_update: Access system firmware using external flashromHung-Te Lin2018-08-311-3/+3
| | | | | | | | | | | | | | | | | | | | | To manipulate the firmware contents on device, we need to access the flash chipset (usually via SPI) on system. The `host_flashrom` provides a way to call external program "flashrom" for reading and writing firmware. So the `update_firmware` can now load "system current firmware" using flashrom. Note in the future we may want to statically link the flashrom as library so there won't be external dependency. BUG=chromium:875551 TEST=make futil; futility update -i IMAGE tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I52f2d4fe4fe4dd660f762a5a75e3367820717e19 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1183650 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: cmd_update: Process FMAP and parse image versionHung-Te Lin2018-08-311-1/+3
| | | | | | | | | | | | | | | | | Add `find_firmware_section` and `firmware_section_exists` utility functions to manipulate FMAP based sections easily. It is used by parsing of image version strings, which helps indicating the firmware versions going to be updated. BUG=chromium:875551 TEST=make futil; futility update -i /build/eve/firmware/image.bin tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I458fa8c31c45dbbd29614c3d6ccd586e46a3ed0b Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1183649 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: cmd_update: Support loading image files by -i, -e, --pd_imageHung-Te Lin2018-08-311-0/+6
| | | | | | | | | | | | | | | | | | | To specify images, we want to read them from files specified from command line: -i: AP (host) firmware image. -e: EC firmware image. --pd_image: PD firmware image (deprecated). BUG=chromium:875551 TEST=make futil; futility update -i /build/eve/firmware/image.bin tests/futility/run_test_script.sh $(pwd)/build/futility BRANCH=None Change-Id: I3c2dbe3d3ce4619aa7e044a154be3aba7ab9181c Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1183648 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: Add 'update' command for updating firmwareHung-Te Lin2018-08-311-0/+13
A reference firmware updater for all systems running vboot using FMAP for layout. The updater is currently a dummy implementation and will be completed with incoming changes. BUG=chromium:875551 TEST=make futil; build/futility/futility update; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I57bec91c178749b79a19789f9599f5f9048fced8 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1182701 Reviewed-by: Randall Spangler <rspangler@chromium.org>