summaryrefslogtreecommitdiff
path: root/futility
Commit message (Collapse)AuthorAgeFilesLines
* futility: updater: Revise getopt_long and use enum instead of charsstabilize-flapjack-12109.Bstabilize-flapjack-12105.Bstabilize-12121.Bstabilize-12105.75.Brelease-quickfix-R75-12105.76.BHung-Te Lin2019-04-181-66/+90
| | | | | | | | | | | | | | | | | For options only available in long-form (--something), we should encode using enum OPT_SOMETHING instead of random characters. Also added dummy --update_ec, --update_pd, and --check_keys because getopt* needs to have them explicitly defined (while the original shflags will generate both --cmd and --nocmd automatically). BUG=chromium:943262 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I701d88f6f5c346581651ed4f8bf004203672e209 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1569145
* futility: updater: Add '--ccd' for programming with closed case debuggingHung-Te Lin2019-04-181-0/+9
| | | | | | | | | | | | | | | | CCD via Servo v4 or SuzyQ-like cables is becoming more popular so more developers want to flash firmware with that, and it seems better to have one short cut '--ccd' instead of always typing '--wp=0 --force --fast -p raiden_debug_spi'. BUG=None TEST=make futil; build/futility/futility update --ccd -i image.bin -v BRANCH=None Change-Id: I0ca8c49a46cc5f8f87fb4dc1936ac9eb0a889baa Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1564235 Reviewed-by: Julius Werner <jwerner@chromium.org>
* futility: updater: report flashrom error codeHung-Te Lin2019-04-101-0/+2
| | | | | | | | | | | | | | | | | | When flashrom execution failed, it is not very easy to debug what went wrong especially when loading system active firmware (-r). The log may say SUCCEED (or no obvious error) and updater simply reports failure. Reporting the returned termination status should help. BUG=chromium:943262 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I4ea09b3d62ebf77eda98084accac582f841e7f7a Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1545590 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@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: Allow single model devices with broken mosys to updateHung-Te Lin2019-03-121-5/+9
| | | | | | | | | | | | | | | | | | | | | | We are recently seeing more and more issues that mosys on early build of devices can't report model properly and caused recovery to fail. For single-model manifest, the updater used to double check if "mosys platform name" matches the single model name for unibuild devices (non-empty signature_id); however this is not really necessary since we have other platform checks and key checks. Remove the check and always return the single model to simplify development in early stage. BUG=None TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I1bb901dc9661623cd1161dde6ee4573c5da958a7 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1513997 Reviewed-by: Joel Kitching <kitching@chromium.org>
* vboot: move general constants to a separate headerJoel Kitching2019-03-115-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | coreboot uses the C preprocessor on its linker scripts to allow evaluation of macros when defining memory layout. Move constants from 2api.h to an independent file in order to allow for coreboot to use these constants in its memlayout file, without needing to include the entire vboot API. Note this commit creates two new header files: - firmware/2lib/include/2constants.h: contains the constants - firmware/include/vb2_constants.h: externally importable header Also, rename VB2_WORKBUF_RECOMMENDED_SIZE to VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE for clarity. BUG=b:124141368, b:124192753 TEST=Build locally TEST=/work/vboot/src/repohooks/pre-upload.py TEST=make clean && make runtests TEST=make clean && COV=1 make coverage && make coverage_html BRANCH=none Change-Id: Id17c6955b67e51cb048b10b4be0901c0e9110a1f Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/1504490 Commit-Ready: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Julius Werner <jwerner@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-30/+51
| | | | | | | | | | | | | | | 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: Merge Debug() into VB2_DEBUG()Julius Werner2019-03-069-136/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Futility has two debug facilities: the Debug() function that can be enabled by passing --debug on the command line, and the VB2_DEBUG() macro (mostly in common code from the firmware/ directory that it includes) which can only be enabled by passing DEBUG=1 at build time. This is confusing and inconvenient, since you don't always want to rebuild futility whenever you need that extra debug output and it's not very obvious that you can get even more debugging beyond just passing --debug. This patch resolves the inconsistency by merging both facilities together into a single VB2_DEBUG() that is output when passing --debug. In order to make this work, we'll have to move the VBOOT_DEBUG #define so that it only affects the stub implementation of vb2ex_printf(), and any caller overriding the stub is in charge of their own destiny. This should be okay since callers can still individually implement debugging policy in their versions of vb2ex_printf() if they want to. (This may have been useful to cut down the binary space for debugging strings, but our firmware has always been unconditionally enabling VBOOT_DEBUG in the past years, so that doesn't seem to be very important in practice.) BRANCH=None BUG=None TEST=Ran futility --debug show, noticed I got all the extra keyblock verification debug output I always wanted. Change-Id: I9a5c205fc3673941b50f03f2a967b1be110a1555 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1504140 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: updater: Preserve all sections with FMAP_AREA_PRESERVE setHung-Te Lin2019-03-052-32/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many projects started their initial builds without knowing that some sections must be preserved when being updated. This may be solved by adding section name to 'preserved' list in firmware updater (for instance, CL:1239797), or include that section as sub area of {RO,RW}_PRESERVE. However, there are problems in both solutions. For example, installing an older image will run old updater, which will not preserve the new names. Also, if there are multiple sections must be preserved (and not contiguous - see CL:1493629) there will be problems. Additionally, changing FMAP layout usually causes more problems. As a result, adding the description in FMAP area would be the better idea. A new FMAP_AREA_PRESERVE suggests firmware updater to preserve a section if possible. In Coreboot, this can be easily set in *.fmd using flag (PRESERVE). See https://review.coreboot.org/31709 for example. BUG=chromium:936768 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: Ie56f65dd418faa97ffb78b1acff613e7d7e268b8 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1495054 Reviewed-by: Julius Werner <jwerner@chromium.org>
* futility: updater: Check if target image is properly signedHung-Te Lin2019-03-021-1/+10
| | | | | | | | | | | | | | | | | | | In RO+RW update mode, we only check if the system will be doing re-key. However, as Unibuild and White-label are becoming more popular today, this may not be true when signer config has something wrong, or if the patching of rootkey/vblock is broken. As a result we should also check if the target image is looking good before proceed to update in recovery mode. BUG=b:126931606 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=none Change-Id: I16c2f9b4fd886e15414de8fda7bd41813f3f8d83 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1496678 Reviewed-by: Julius Werner <jwerner@chromium.org>
* updater: Preserve SI_GBE and SI_PDR if presentDuncan Laurie2019-03-011-0/+6
| | | | | | | | | | | | | | | | | On a full firmware update we need to preserve these regions: SI_GBE contains the unique MAC address for the system SI_PDR contains data from the factory and diagnostics BUG=b:126637087 BRANCH=none TEST=futility update image-sarien.bin Change-Id: I2981c8cc478617029934ef3fbdb1c446c858fad8 Signed-off-by: Duncan Laurie <dlaurie@google.com> Reviewed-on: https://chromium-review.googlesource.com/1493629 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Hung-Te Lin <hungte@chromium.org>
* futility: updater: Improve error message when key conflictsHung-Te Lin2019-02-131-15/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-163-13/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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: updater: Add '--fast' for quick developmentstabilize-11554.BHung-Te Lin2019-01-033-7/+36
| | | | | | | | | | | | | | | | | When using 'futility update' with Servo Micro or CCD, the programmer is pretty slow that every invocation of flashrom would take a very long time, so re-reading firmware contents when writing (flashrom -w) seems redundant. For such usage, a '--fast' would be helpful that - Uses the last read image (image_current) as --diff - Add --noverify BUG=None TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I1ad57185160a082ea6b5c94b837a4d3ba708b587 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1375495
* futility: updater: quirks: Support special released SNOW ROstabilize-atlas-11512.Bstabilize-atlas-11512.6.BHung-Te Lin2018-12-283-1/+6
| | | | | | | | | | | | | | | | A special Snow RO firmware had been released and would break existing platform check: 'Google_Snow_Rev4.2695.128.0'. As a result, we want to bypass platform check in quirk 'daisy_snow_dual_model'. BUG=chromium:917581 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I10b0e4c2b8a11faff979b4add368f342a72a6cec Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1390083 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Joel Kitching <kitching@chromium.org>
* futility: updater: Correct output version for Snowstabilize-atlas.11448.BHung-Te Lin2018-12-191-0/+2
| | | | | | | | | | | | | | | In quirk daisy_snow_dual_model, after RO is preserved the actual RO version should be updated as well from current image. Without this, reported version may look weird as RO=132, RW=117. BRANCH=None BUG=chromium:915013 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility Change-Id: I1bc6c47a8bd548265fd654dae6ab2a5971d59a1c Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1383631 Reviewed-by: Duncan Laurie <dlaurie@google.com>
* futility: updater: Add 'image.bin' as host image name in archiveHung-Te Lin2018-12-112-3/+13
| | | | | | | | | | | | | | | | | | 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: update smm store filename to use an underscoreJoel Kitching2018-12-031-3/+3
| | | | | | | | | | | | | | | Rename "smm store" to "smm_store". Depends on CL:1351857. BUG=b:120060878 TEST=None Change-Id: Iae511ecdc6d918d06218de1b651b1e5e3821d2f1 Reviewed-on: https://chromium-review.googlesource.com/1351178 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org>
* futility: updater: Skip applying white label for local buildHung-Te Lin2018-12-011-1/+8
| | | | | | | | | | | | | | | | | | | | | | For developers running a local build on white label models, currently the chromeos-firmwareupdate will always fail if VPD `whitelabel_tag` is set because the `keyset/` folder does not exist (which was created by signer bot). Developers in this case usually don't really care about which key to use and will be happy with the default (DEV signed) keys, also the key compatibility will be still checked later, so we can skip the white label patching if no keyset folder, which would allow developers getting same experience on WL and non-WL devices. BUG=b:120268135 TEST=TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I3992301ff4c406096e11e1ae8129f2f68b2319b5 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1356688 Reviewed-by: C Shapiro <shapiroc@chromium.org>
* futility: updater: quirks: Fix firmware names for Veyron familyHung-Te Lin2018-12-011-3/+3
| | | | | | | | | | | | | | The firmware name for Veyron devices are Google_Veyron_XXX and we have to correct the names in quirks database. BUG=chromium:910085 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I3bf3bbb32fe90ebf370c1bc51c54d0280ddb7e98 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1354147 Reviewed-by: Youcheng Syu <youcheng@chromium.org>
* futility: updater: Revise error message when model is not defined in manifeststabilize-11306.BHung-Te Lin2018-11-271-2/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | "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: Revise output messages for debug logsHung-Te Lin2018-11-245-51/+54
| | | | | | | | | | | | | | | | | | | | | | | | In auto update and recovery, the firmware updater was executed with both stdout and stderr logged. However, the logs usually comes with all stderr first then all stdout. This makes it harder to debug because the messages logged in out of order. TO solve that, few macros are introduced: INFO: for useful information. STATUS: the most common information, usually comes with a prefix code. And all messages should now go to stderr except the final execution result (and those output commands, for example --manifest). BUG=chromium:875551 TEST=TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility CQ-DEPEND=CL:1345250 BRANCH=None Change-Id: Ie0dc6594ece10e7e15caf9c36353e2b3ec8754c5 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1345611 Reviewed-by: Youcheng Syu <youcheng@chromium.org>
* futility: updater: Add new quirk 'allow_empty_wltag'Hung-Te Lin2018-11-243-6/+29
| | | | | | | | | | | | | | | 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: updater: Load quirks immediately after host image is loadedHung-Te Lin2018-11-241-13/+32
| | | | | | | | | | | | | | | There may be quirks needed during image archive setup (for example loading white label tags) so we have to move quirks setup to some earlier place. BUG=chromium:906962 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I1f6eddb0119c64098df75bad72809ba8366625c7 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1345609 Reviewed-by: Youcheng Syu <youcheng@chromium.org>
* futility: updater: Need --force when re-keying to DEV keysHung-Te Lin2018-11-191-13/+47
| | | | | | | | | | | | | | | | | | | For dogfood devices, we usually will only re-key from DEV to PreMP, and then PreMP to MP. It was found that for retail devices, if WP was disabled (unintended), user may accidentally re-key to DEV keys if they (1) recover with a DEV-signed image, or (2) received an AU that didn't have right signing keys. As a result, we want to make it harder when recovering to DEV keys. BUG=chromium:894324 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: Id3f7788e6c86d12b6e37b77818a1b4c2ceda1e2f Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1312596 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* futility: updater: Check EC/PD WP state again before updatingHung-Te Lin2018-11-141-6/+25
| | | | | | | | | | | | | | | | | | | | | | | There are devices, especially during or after RMA, may have WP states not synced; for example HW = 1 SW (AP) = 0 SW (EC) = 1 In this case, we can still update host firmware but not EC. This happens more often on EC that needs an extra reboot to change WP states. As a result, we do want to check real programmer again before updating optional images. BUG=chromium:902546 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I9a526cde19a1ab3c41afecb4f7247bd941edc3f4 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1322295 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: update: Strip \xFF from version stringHung-Te Lin2018-11-071-6/+17
| | | | | | | | | | | | | | | If some system that firmware RW sections were damaged, the firmware string may become '\xFF' (flash erased content). We do not want to see that as version string, and this will help FAFT testing. BUG=chromium:899901 TEST=TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I947ec3c8286a022163abf01ae1d8ab5747aacf08 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1317050 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: updater: Add more legacy optionsHung-Te Lin2018-11-041-0/+10
| | | | | | | | | | | | | | | | | | To simplify the migration plan, we want to support the legacy arguments used by FAFT: --noupdate_ec => --host_only --noupdate_pd => --host_only --nocheck_keys => --force --update_main => ignore BUG=chromium:882445,b:118509893 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I31652806085937fe5ca2f2facc7321021977cbb7 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1310253 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: updater: Fix model detection errorHung-Te Lin2018-10-291-1/+1
| | | | | | | | | | | | | | | In mosys, $(mosys platform name) currently returns the board (family) name while the real model name needs $(mosys platform model). BUG=chromium:875551 TEST=TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: Ie3355ca94d577e88a2140567b9284da40c0b39c5 Reviewed-on: https://chromium-review.googlesource.com/1301013 Commit-Ready: Hung-Te Lin <hungte@chromium.org> Tested-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: updater: Support --repack and --unpackHung-Te Lin2018-10-244-16/+182
| | | | | | | | | | | | | | | | In order to make the firmware updater package more consistent file contents (for example, we don't want time stamps, and better if the files are always physically located in same order) we want to create and manipulate the ZIP based package directly using updater. BUG=chromium:875551 TEST=TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: Ie4c5aafe51f633729de2879c73bf7074a695151f Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1286173 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
* futility: Preserve programmer in free_firmware_imageHung-Te Lin2018-10-232-3/+9
| | | | | | | | | | | | | | | | | The `programmer` cannot be decided in `load_firmware_image` and is always specified (and managed) by an outer context, and should be preserved even when we call `free_firmware_image`. This helps reloading or removing loaded images at runtime. BUG=chromium:875551 TEST=TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I22f698d4a7118197379e11556b18f70ecd023ca2 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1295209 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: update: Add `--host_only` argumentHung-Te Lin2018-10-233-4/+12
| | | | | | | | | | | | | | | | | | | | | | | 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-223-0/+42
| | | | | | | | | | | | | | 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-224-10/+164
| | | | | | | | | | | | | | | | | | | | 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-224-27/+148
| | | | | | | | | | | | | | | | | 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-182-10/+14
| | | | | | | | | | | | | | | | | 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: Change default model name to FWID platform nameHung-Te Lin2018-10-181-1/+28
| | | | | | | | | | | | | | | | | | | | | For devices not using Unified Build, the firmware updater may contain a single set of firmware images. To make the manifest more consistent for both cases (Unified Build or not), we want to change to model name to be the platform name from FWID if available. This does not make sense because for these devices, usually platform = board = model, and it helps to make sure programs parsing manifest won't try to use the hard coded name 'default' (which does not always work in Unified Build). BUG=chromium:875551 TEST=TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I6d56336f3b30981e3e936fa63dec7dd45d74b31a Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1278418 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: updater: Allow patching rootkey and vblock filesHung-Te Lin2018-10-153-10/+206
| | | | | | | | | | | | | | | | | | | | | For white label projects, the firmware updater has to select correct root key and corresponding vblock files per different LOEM. In Unified build, multiple models may share same firmware base image, with different key files (per OEM). As a result, we have to apply the key files before using the firmware image files. This change adds the "patch" information when building manifest, and prints the correct key hash in `--manifest` mode. BUG=chromium:875551 TEST=TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: Ib5e31af5262a0989a5a474d0683c83121f24cc78 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1270323 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: updater: Add --manifest to scan and print archive infoHung-Te Lin2018-10-134-5/+336
| | | | | | | | | | | | | | | | | | | | | | | 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: Refactor how arguments were configuredHung-Te Lin2018-10-133-125/+118
| | | | | | | | | | | | | | | | | | We are going to have more command line arguments that must be passed to updater_setup_config, and it is better to manage so many variables in a struct. Also, revised the order or argument processing so that simple settings are now processed first, then complicated ones or those with dependency. BUG=chromium:875551 TEST=TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I03ac036d26e49cdf924c03d6e86a272ce89fc2aa Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1265575 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: updater: Add '--archive' to read from an archive or directoryHung-Te Lin2018-10-135-18/+398
| | | | | | | | | | | | | | | | | | | | | | 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: Refactor function namesHung-Te Lin2018-10-133-36/+37
| | | | | | | | | | | | | | | | | | | | | | | No real function changes. For incoming changes, we want to rename the shared functions to make it more clear (and more consistent) in hot it was used, including: - load_image: should be load_firmware_image(image, filename) - free_image: should be free_firmware_image - reload_image: should be reload_firmware_image - load_system_image: should be load_system_firmware - create_temp_file: should be updater_create_temp_file to make it more clear it is created for updater (and deleted when updater has finished) BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I120e30b5a4c40ccce03e5f361734f2583476703a Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1270322 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: updater: Add ASPRINTF macroHung-Te Lin2018-10-133-30/+18
| | | | | | | | | | | | | | | | | | | | When calling `asprintf`, if the return value is negative value then the strp parameter is not allocated. Updater will need to call asprintf very often in future, and we should abort immediately if asprintf can't allocate buffer, since that implies either we are running out of memory, or the system has gone very wrong. Instead of writing if (asprintf(...) < 0) { ERROR(); return...} everywhere, it seems easier to just add a macro and abort as exit(1). BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I8ea5f6c22dcc8225bc53fbd54b4b41a928f84910 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1260803 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: updater: Revise verbosity and error messagesHung-Te Lin2018-10-024-19/+44
| | | | | | | | | | | | | | | | | | | | | | `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-1/+30
| | | | | | | | | | | | | | | | | | "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-023-0/+92
| | | | | | | | | | | | | | | | | 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: updater: Add quirk 'daisy_snow_dual_model' for daisy_snowHung-Te Lin2018-10-023-7/+117
| | | | | | | | | | | | | | | | | | | | | | The target AUE for daisy_snow is 74 or even longer, so we need to get a better solution to get rid of script based updater customization (and the painful EXTRA list in updater configuration). The new quirk 'daisy_snow_dual_model' is assuming the input firmware image has both daisy_snow x8 and x16 firmware packed into a single image (because in vboot1, RW_A is identical to RW_B), and will modify A/B contents according to target system. BRANCH=None BUG=chromium:881034 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility # Provide a fake mosys and output both MP / MPx16 to: futility update -i bios-snow-2695.132.117-rw.bin \ --quirks daisy_snow_dual_model --emu emu.bin --sys_props 0,0x0000,0 Change-Id: I8af1b6c3117a703aed4da59902aaecb1009101f2 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1239798
* futility: updater: Add default quirksHung-Te Lin2018-10-023-2/+64
| | | | | | | | | | | | | | | | | | For people running updater directly without the packaged firmware updater (chromeos-firmwareupdate), it is easier if we identify the quirks inside updater itself instead of the wrapper script. This change enables getting "default quirks" by target image RO version so we won't need to pack firmware images first. BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I179227f7a829577dc9fe5deb085fdee1a738c070 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1245663 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* futility: updater: Refactor: move quirks to 'updater_quirks.c'Hung-Te Lin2018-10-023-202/+274
| | | | | | | | | | | | | There will be more and more board-specific quirks in future and we want to put them together into a special module. BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I4fd2ff5e2b2e891cbd3da8c9393c6fbdf7024c75 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1245645
* futility: updater: Refactor: localize temp files managementHung-Te Lin2018-10-023-20/+16
| | | | | | | | | | | | | | | The creation and deletion of temp files can be managed in same context where updater config lives. BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: Ic1745d27a071047d4882b21905bd11e15b5632cd Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1245644 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>