summaryrefslogtreecommitdiff
path: root/futility
Commit message (Collapse)AuthorAgeFilesLines
* futility: make flash --wp-status subcmd check HW statusstabilize-15432.BNikolai Artemiev2023-04-201-8/+24
| | | | | | | | | | | | | | | | Check HW WP status as well as SW WP status by default. A new `--ignore-hw` flag makes it possible to only check SW WP. BUG=b:268574030 BRANCH=none TEST=todo Change-Id: I4a45499ceda52a1e00e7e33742b0bb48d235550b Signed-off-by: Nikolai Artemiev <nartemiev@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4413354 Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* futility/: host/lib: Add flash chip info subcommand supportEdward O'Callaghan2023-04-131-1/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The AP RO verification tooling requires a understanding of the underlying flashchip information. Provision support in the flash subcommand to report back this data from the flashrom driver. BUG=b:276981092 BRANCH=none TEST=on Nissa ``` localhost ~ # futility flash --flash-i{nfo} Warning: Setting BIOS Control at 0xdc from 0x8b to 0x89 failed. New value is 0x8b. Flash vendor: Winbond Flash name: W25Q256JV_M Flash vid-pid: 0xef00007019 Flash size: 0x02000000 ```. Cq-Depend: chromium:4401775, chromium:4401776 Change-Id: I58e818f06def4904693f61c6967d70b16c62fa37 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4402370 Auto-Submit: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org> Commit-Queue: Jakub Czapiga <czapiga@google.com> Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
* futility: Allow printing manifest for EC onlyYu-Ping Wu2023-04-122-11/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently `futility update --manifest` requires either -i/--image or -a/--archive to be passed. There is no way to show the EC manifest without also passing an AP image. Extend the command by allowing `futility update --manifest -e FILE`. Here are a few examples of valid commands: * futility update --manifest --archive PATH * futility update --manifest --image FILE * futility update --manifest --image FILE --ec_image FILE * futility update --manifest --ec_image FILE BUG=none TEST=make DISABLE_NDEBUG=1 futil -j TEST=sudo emerge vboot_reference TEST=futility update --manifest -e FILE BRANCH=none Change-Id: I267b90a3e5ff2891b519702558d173bb2e970052 Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4413335 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Yidi Lin <yidilin@chromium.org>
* futility/cmd_update: Describe more details in command helpJakub Czapiga2023-04-101-1/+13
| | | | | | | | | | | | | BRANCH=None BUG=None TEST=make runtests Disallow-Recycled-Builds: test-failures Change-Id: I86f0f4ea383b5fff8390a0510bc5c88bda414f2b Signed-off-by: Jakub Czapiga <czapiga@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4370239 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Yu-Ping Wu <yupingso@chromium.org>
* futility/updater: Fix legacy bios image namingstabilize-15415.BEdward O'Callaghan2023-04-065-9/+9
| | | | | | | | | | | | | | | | | | Clean up many other instances of 'bios.bin' littered everywhere over time. BUG=b:65745723 BRANCH=none TEST=`cros_run_unit_tests --host --packages vboot_reference`. Change-Id: Ie5916d003ba0a5873ce04ec96f48cd45c8253aab Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4402371 Tested-by: Edward O'Callaghan <quasisec@chromium.org> Auto-Submit: Edward O'Callaghan <quasisec@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Commit-Queue: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org>
* futility/cmd_*: Cleanups for maintainabilityEdward O'Callaghan2023-04-0310-117/+87
| | | | | | | | | | | | | | | | | Fix many mistyping of indexers and other itermediate variables. BUG=b:268397597 TEST=`emerge-nissa vboot_reference`. TEST=`cros_run_unit_tests --host --packages vboot_reference`. TEST=`cros_run_unit_tests --board nissa --packages vboot_reference`. Change-Id: I49cc0e1a3e5d455c7f473e31cba528e8f227dfb6 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4349562 Reviewed-by: Sam McNally <sammc@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org> Commit-Queue: Sam McNally <sammc@chromium.org> Auto-Submit: Edward O'Callaghan <quasisec@chromium.org>
* futility/cmd_gbb_utility.c: Remove globalEdward O'Callaghan2023-03-311-14/+2
| | | | | | | | | | | | | | | | BUG=b:268397597 TEST=`emerge-nissa vboot_reference`. TEST=`cros_run_unit_tests --host --packages vboot_reference`. TEST=`cros_run_unit_tests --board nissa --packages vboot_reference`. Change-Id: I3effc8651511a5b51f0948ba213bb5a00c49f55e Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4349561 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Auto-Submit: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Sam McNally <sammc@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org>
* futility/cmd_*.c: Use ERROR() macro consistentlyEdward O'Callaghan2023-03-3113-266/+198
| | | | | | | | | | | | | | | | | | Fix grammatical issues in ERROR() usage and over usage of contractions. Now errors shall now be prefixed with "ERROR:" and the function name. BUG=b:268397597 TEST=`emerge-nissa vboot_reference`. TEST=`cros_run_unit_tests --host --packages vboot_reference`. TEST=`cros_run_unit_tests --board nissa --packages vboot_reference`. Change-Id: Ieac1f312c2e02133228ba4560197d009aed0324c Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4349560 Reviewed-by: Sam McNally <sammc@chromium.org> Auto-Submit: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org>
* futility: updater: Add --unlock_me optionReka Norman2023-03-296-24/+128
| | | | | | | | | | | | | | | | | | | | Add a --unlock_me option which unlocks the Intel ME before flashing by: - Unlocking the FLMSTR values in the descriptor. - Disabling GPR0 in the descriptor. This will be used in factory to support Flexible EOM. BRANCH=None BUG=b:273168873 TEST=Flash locked yaviks firmware with --unlock_me. Read firmware back and check that FLMSTR values are unlocked and GPR0 is disabled. Change-Id: Ie29f3c997c82a1bc58fe62f568f257e9dc375d94 Signed-off-by: Reka Norman <rekanorman@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4374965 Tested-by: Reka Norman <rekanorman@chromium.org> Reviewed-by: Sam McNally <sammc@chromium.org> Commit-Queue: Reka Norman <rekanorman@chromium.org>
* futility: Drop external flashrom quarkEdward O'Callaghan2023-03-263-63/+1
| | | | | | | | | | | | | | | | | This prevents architectural changes required to make futility to make it fast and robust while providing limited to no tangible value. BUG=b:226477133 BRANCH=none TEST=none Signed-off-by: Edward O'Callaghan <quasisec@google.com> Change-Id: Ie0ea715fcf60cfb5b2b25037f4421c2dc70c0e5b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4147407 Reviewed-by: Sam McNally <sammc@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org>
* futility/file_type_*: Use ERROR() macro consistentlyEdward O'Callaghan2023-03-254-47/+40
| | | | | | | | | | | | | | | | | | Fix grammatical issues in ERROR() usage and over usage of contractions. Now errors shall now be prefixed with "ERROR:" and the function name. BUG=b:268397597 TEST=`emerge-nissa vboot_reference`. TEST=`cros_run_unit_tests --host --packages vboot_reference`. TEST=`cros_run_unit_tests --board nissa --packages vboot_reference`. Change-Id: Iba811c4d4714b9af1a3982613b74ca43958d7934 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4349559 Auto-Submit: Edward O'Callaghan <quasisec@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility/file_type*: Minor cleanups for maintainabilityEdward O'Callaghan2023-03-256-129/+87
| | | | | | | | | | | | | | | | | | | | Use C99 features to scope indexer to loop constructs and local itermediates within more constrained lexical scopes. Be canonical in predicates of branch conditions. Use const correctness. Apply clang-format where reasonable BUG=b:268397597 TEST=`emerge-nissa vboot_reference`. TEST=`cros_run_unit_tests --host --packages vboot_reference`. TEST=`cros_run_unit_tests --board nissa --packages vboot_reference`. Change-Id: I8ce232f791a95a668ab5017cff628c199c36e917 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4349558 Tested-by: Edward O'Callaghan <quasisec@chromium.org> Auto-Submit: Edward O'Callaghan <quasisec@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org>
* futility: Add `flash` subcommandstabilize-15393.48.Brelease-R113-15393.Bfirmware-skyrim-15390.BNikolai Artemiev2023-03-162-1/+262
| | | | | | | | | | | | | | | | | | | | | | | | | Add a new subcommand for getting/setting flash properties such as the flash size and writeprotect configuration. The operations provided by `futility flash` require less information from the user and are less error prone than the equivalents provided by `flashrom`. For example, --wp-enable automatically choses the protection range based on the firmware image and --wp-status gives a warning if the protection range does not match the RO firmware region. BUG=b:268574030 BRANCH=none TEST=`futility flash --{flash-size,wp-enable,wp-disable,wp-status}` Co-authored-by: Edward O'Callaghan <quasisec@google.com> Signed-off-by: Edward O'Callaghan <quasisec@google.com> Signed-off-by: Nikolai Artemiev <nartemiev@google.com> Change-Id: I36d7468616a5bcdf3c4542d48652bd24c3377a61 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4279661 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org>
* futility/: Replace futil_copy_file_or_die() implfactory-skyrim-15384.BEdward O'Callaghan2023-03-155-52/+39
| | | | | | | | | | | | | | | | | | | | | | | Replace shell-script C with actual library calls to copy file content. Don't die, dying is bad. Use '0660' as the default dest file perm mask over the default system umask inherited form the environment applied to the source file permissions. Add error handling so we have a idea what happened. BUG=b:268397597 TEST=`emerge-nissa vboot_reference`. TEST=`cros_run_unit_tests --host --packages vboot_reference`. TEST=`cros_run_unit_tests --board nissa --packages vboot_reference`. Change-Id: Ibe4745dbad20504a1ff7e39e10cbf18ed1831354 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4313546 Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Auto-Submit: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org> Commit-Queue: Hung-Te Lin <hungte@chromium.org>
* futility: Prefer debug header servo over CCD when both are available.Matthew Blecker2023-03-091-7/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | BRANCH=none BUG=b:270287312 TEST=With atlas DUT + servo_v4p1 + cr50_ccd + servo_micro: $ dut-control -o servo_type # servo_v4p1_with_servo_micro_and_ccd_cr50 $ dut-control cpu_fw_spi # unknown value but control does exist $ dut-control ccd_cpu_fw_spi # error from control not existing $ futility read --servo -v ap-fw.bin # succeeds With atlas DUT + servo_micro: $ dut-control -o servo_type # servo_micro $ dut-control cpu_fw_spi # unknown value but control does exist $ dut-control ccd_cpu_fw_spi # error from control not existing $ futility read --servo -v ap-fw.bin # succeeds With atlas DUT + servo_v4p1 + cr50_ccd: $ dut-control -o servo_type # servo_v4p1_with_ccd_cr50 $ dut-control ccd_cpu_fw_spi # off $ futility read --servo -v ap-fw.bin # succeeds Change-Id: I18e890aaa6c3fa63f2108840b8c344a6adc5a561 Signed-off-by: Matthew Blecker <matthewb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4315198 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* vboot_reference: Change flashrom_get_wp signatureNikolai Artemiev2023-03-094-16/+13
| | | | | | | | | | | | | | | | | | | Expose more information about WP state from the flashrom_drv WP status function. The more detailed WP information is required to properly validate the system WP configuration. BUG=b:268574030 TEST=futility update Signed-off-by: Nikolai Artemiev <nartemiev@google.com> Change-Id: If79b7d8cc68a0583cbf1f7049ac7a2dec088fdd0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4301750 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org>
* futility/cmd_gbb_utility.c: Check wp status before flash write()Edward O'Callaghan2023-03-061-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | Check write-protect status before attempting to write to SPI flash. BUG=b:238694831,b:260531154 BRANCH=none TEST=``` [..] SPI Configuration is locked down. FREG0: Flash Descriptor region (0x00000000-0x00000fff) is read-write. FREG1: BIOS region (0x003a0000-0x01ffffff) is read-write. FREG2: Management Engine region (0x00001000-0x0039ffff) is read-write. OK. Found Winbond flash chip "W25Q256JV_M" (32768 kB, Programmer-specific) on host. ERROR: write_to_flash: You must disable write protection before setting flags. ``` Cq-Depend: chromium:4303349 Change-Id: I46d72a8867292599bf1a7287d63c62999df41c8e Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4161094 Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Auto-Submit: Edward O'Callaghan <quasisec@chromium.org> Commit-Queue: Yu-Ping Wu <yupingso@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility: updater: revise DUT type detectionHung-Te Lin2023-03-021-6/+5
| | | | | | | | | | | | | | | | | | | | | Some commands like 'cros ap flash' may pass '-p host' to the futility updater, making the updater consider itself running in the remote DUT mode. Other futility commands sharing the flash arguments (e.g., handle_flash_argument) work on files by default and only do flashing if '-p' is specified, but that is not the case for the updater. So we should double check the programmer before deciding the DUT type. BUG=b:271115449 TEST=FEATURES=test emerge vboot_reference BRANCH=None Change-Id: I5be6e4382acffced0ef9cd94f6ede9e9d3fe2efa Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4300000 Commit-Queue: Yu-Ping Wu <yupingso@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility: updater: Fix platform_ver property on errorfirmware-skyrim-15369.BHung-Te Lin2023-03-011-1/+8
| | | | | | | | | | | | | | | | | The platform_ver property was expected to be within 0..INT_MAX before the implementation changed from mosys to crossystem (CL:4029537). So we should return 0 instead of -1 on error. BUG=b:271115449 TEST=make; run test BRANCH=None Change-Id: I772ff53a4a13e17e6cfe8099768dba64b8736ec5 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4297882 Commit-Queue: Yu-Ping Wu <yupingso@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility/cmd_gbb_utility.c: Allow OR'ing new GBB flagsstabilize-15361.Bstabilize-15359.BEdward O'Callaghan2023-02-231-9/+32
| | | | | | | | | | | | | | | | | | | | | | | It maybe the case that the caller wishes to not clobber the current flags set and merely just OR on the new bits. BUG=b:270074866 TEST=``` # futility gbb --flash --get --flags # futility gbb --flash --set --flags=(+|-)0x1 # futility gbb --flash --get --flags as expected. ``` Change-Id: Ibd56dff986d2075b7b220c531e66b224d488b6e6 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4273505 Auto-Submit: Edward O'Callaghan <quasisec@chromium.org> Commit-Queue: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Sam McNally <sammc@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org>
* futility: gbb: Avoid unnecessary search of FMAPYu-Ping Wu2023-02-162-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For commands such as `futility gbb --set --flags=0x140`, futility first reads the GBB section from the flash, modifies the section, and then writes back the section to the flash. The write, however, requires another search of the FMAP section, in order to locate the GBB section in the flash. This unnecessary search can be avoided by reading the FMAP section together with the GBB section. The FMAP data will be stored in the image buffer, so that the FMAP layout can be retrieved directly from the buffer for subsequent writes. This will also prevent the misleading warnings from showing up: Failed to read fmap from buffer. WARNING: flashrom_write_image: could not read fmap from image, r=1, falling back to read from rom BUG=b:260531154 TEST=emerge-corsola vboot_reference TEST=make runtests TEST=No warnings and errors were shown with `futility gbb --set --flash --flags=0x140` BRANCH=none Change-Id: I50029ae5d9c5ecb347f47e980e7c3b772ecc0f18 Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4251504 Reviewed-by: Hung-Te Lin <hungte@chromium.org>
* futility: flashrom_drv: Support partial read for multiple regionsYu-Ping Wu2023-02-161-2/+3
| | | | | | | | | | | | | Similar to CL:3490388, support flashrom read for multiple regions. BUG=b:260531154 TEST=emerge-corsola vboot_reference BRANCH=none Change-Id: I1f75832f882004e879bc299be6862db089c2b71d Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4251503 Reviewed-by: Hung-Te Lin <hungte@chromium.org>
* futility: updater: detect DUT typeHung-Te Lin2023-02-134-3/+34
| | | | | | | | | | | | | | | | | | | Detect if we are going to update a remote DUT (by checking if the flash parameter has been changed), and ignore all the local system properties if needed. This should help 'updating a Chromebook from a Chromebox via servo' to behave the same as updating from a non-ChromeOS Linux desktop. BUG=b:247428499,b:255617349 TEST=make; run test BRANCH=None Change-Id: I4aa0e98efa21179708d8b593fc619b7f7b65f418 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4181582 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Jeffrey Kardatzke <jkardatzke@google.com>
* futility: updater: refactor: always pass updater config to DUT APIsHung-Te Lin2023-02-126-26/+36
| | | | | | | | | | | | | | | | | | | | To support local and remote DUTs, we need to always pass the updater configuration (including flash programmer information) for DUT related calls. No functional changes but this is required for DUT detection in the future. BUG=b:247428499,b:255617349 TEST=make; run test BRANCH=None Change-Id: I91bdc95f3073d1e94030246790db83645fbd63ac Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4235306 Auto-Submit: Hung-Te Lin <hungte@chromium.org> Commit-Queue: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Tested-by: Hung-Te Lin <hungte@chromium.org>
* futility: updater: remove quirks for AUE boardsHung-Te Lin2023-02-121-18/+4
| | | | | | | | | | | | | | Remove quirks defined for boards derived from rambi, storm, strago, and veyron. Also updated reference design names for the derived platforms. BUG=None TEST=make; run test BRANCH=None Change-Id: I71f391cc7ef7ceff8ae6a93be599390910aba20c Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4235305 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility: updater: drop vboot1 supportHung-Te Lin2023-02-123-37/+15
| | | | | | | | | | | | | | As CL:4211436 mentioned, all vboot1 boards are now AUE and it is time to drop vboot1 logic to simplify the updater. BUG=b:124141368,b:172342538 TEST=make; run test BRANCH=None Change-Id: Ice445158abd2b6465dad7cade10ce88b46d3c981 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4235302 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility: updater: support getting WPSW from any DUTsHung-Te Lin2023-02-121-1/+2
| | | | | | | | | | | | | | | | From b:255617349#comment133, the --wp-* commands should work with any servo, including servo-micro; so we should pass the right DUT programmer (e.g., cfg->image.programmer) instead of PROG_HOST when retrieving software write protection status (WPSW). BUG=b:255617349 TEST=make; run test BRANCH=None Change-Id: Iff5a105da8bed06bbd714a72a7d06d2b64b3dcd4 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4235303 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility: updater: refactor DUT system info retrievalHung-Te Lin2023-02-127-171/+206
| | | | | | | | | | | | | | | | | | | | | | | When developers (or the lab) runs 'futility update' on a Chromebox to update a remote DUT connected via servo, the updater will incorrectly recognize the Chromebox as the 'host' = 'system' = 'DUT', selecting wrong config and setting wrong cookies. To fix that, we want to isolate and refactor how we identify and access 'host' and 'DUT'. The first step is to rename and move the 'system property' related functions to 'dut properties' in the `updater_dut.c`. No functional changes in this patch. Only renamed functions and moved the implementation to different places. BUG=b:247428499,b:255617349 TEST=make; run test BRANCH=None Change-Id: I5c1f9bb67a14fbcdd80958597290a2789f4c2dac Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4181581 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility: gbb: Read only the GBB region from flashstabilize-15335.BEvan Benn2023-01-271-1/+2
| | | | | | | | | | | | | | | | BUG=b:265861606 BRANCH=None TEST=futility gbb --get --flash --flags --hwid --digest --rootkey=/tmp/rootkey --bmpfv=/tmp/bmpfv --recoverykey=/tmp/recoverykey TEST=futility gbb --get --flags --hwid --digest --rootkey=/tmp/rootkey2 --bmpfv=/tmp/bmpfv2 --recoverykey=/tmp/recoverykey2 /tmp/bios TEST=diff the above TEST=confirm that it is quicker (3s vs 26s on one dut) Change-Id: I398e40a1cc50a6921e0385277fc03d0b7fa7c9b8 Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4170147 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* host: Add region parameter to flashrom_read_imageEvan Benn2023-01-271-1/+1
| | | | | | | | | | | | | | | Allow flashrom_read_image to take a parameter to read only a region. BUG=b:265861606 BRANCH=None TEST=unit Change-Id: I835ca341c00b21286721f65c3e009a76753b6628 Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4170146 Tested-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* futility: updater: Pass bus=prog for dummy programmer for --emulateSam McNally2023-01-271-1/+1
| | | | | | | | | | | | | | | | Probing all buses adds 200ms per flashrom interaction in tests using the dummy programmer. BUG=b:266014935 TEST=unit tests BRANCH=None Change-Id: I83c0c995bfdf057849c2d1f5cc76fa36fdc31407 Signed-off-by: Sam McNally <sammc@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4193608 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org>
* futility/cmd_read.c: Add region supportEdward O'Callaghan2023-01-211-1/+22
| | | | | | | | | | | | | | | | | | | Allow user to read a specific region from flash via the read subcommand. BUG=b:264974346 BRANCH=none TEST=`futility read /tmp/bios` TEST=`futility read --region=GBB /tmp/gbb` Change-Id: Ibd75f8e67d31bab910a61fb5453ca6e90d41fac3 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4151009 Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org> Auto-Submit: Edward O'Callaghan <quasisec@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org>
* futility: updater: add new quirk 'clear_mrc_data'Hung-Te Lin2023-01-195-17/+77
| | | | | | | | | | | | | | | | | | | | | For devices with some memory training data that is not compatible with the new flashed firmware (and can't be automatically detected by the new firmware), we need a way to easily wipe out the existing memory training data to enforce a retraining at the next boot. This usually happens when repairing a device (with non-qualified firmware) and should never happen in the OTA. BUG=b:255617349 TEST=make; run test BRANCH=None Signed-off-by: Hung-Te Lin <hungte@chromium.org> Change-Id: I92befefa6be59da10ca7572e7849ef905f184a5f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4018593 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Tested-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Yu-Ping Wu <yupingso@chromium.org>
* 2lib: Add vb2_get_gbb_flag_descriptionfirmware-ti50-prepvt-15315.BEvan Benn2023-01-131-2/+41
| | | | | | | | | | | | | | | | | Add a function to convert a gbb flag to the name and description of that flag. Use this function in cmd_gbb to format a help page and implement --explicit. BUG=b:260531154 BRANCH=None TEST=futility gbb --get /dev/bios -e TEST=futility gbb --help Change-Id: I884b6e0e7322128409f8d62d76824d8e6e6ca330 Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4161092 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* futility: cmd_read: Do not error on bad firmware formatEvan Benn2023-01-133-6/+12
| | | | | | | | | | | | | | | | Write the read firmware whether or not it can be parsed as a cros firmware. BUG=b:264810939 BRANCH=None TEST=futility read /dev/null Change-Id: Ia0fe2a6b9d9250dd05485d2f48c74a33a048ab21 Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4158631 Reviewed-by: Hsuan Ting Chen <roccochen@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* futility: Add read commandEvan Benn2023-01-061-0/+134
| | | | | | | | | | | | | | | | | | Add a command that reads AP firmware to a specified file path. BUG=b:260531154 BRANCH=None TEST=FEATURES=test emerge-grunt vboot_reference TEST=futility read /tmp/bios TEST=futility read /tmp/bios -p ec TEST=env SERVOD_NAME=grunt futility read /tmp/bios --servo Change-Id: I82fe0381b6f61ca4d67a9f5c27353e18ed4abe39 Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4075310 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org>
* futility: Add read/write flash capability to gbb commandEvan Benn2023-01-063-55/+214
| | | | | | | | | | | | | | | | | | | | | gbb command can read and modify flash in addition to acting on firmware files. BUG=b:260531154 BRANCH=None TEST=FEATURES=test emerge-grunt vboot_reference TEST=futility gbb -s --flags 0x0 /tmp/bios /tmp/bios2 TEST=futility gbb -g --flash TEST=futility gbb --set --flash --flags=0x40b9 --flash TEST=env SERVOD_NAME=grunt futility gbb --get --servo TEST=env SERVOD_NAME=grunt futility gbb --set --servo --flags=0 Change-Id: I66b008ed7325d125eb305e84185e53eccd243898 Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4075311 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* futility: Move some argument handling to shared fileEvan Benn2023-01-063-48/+87
| | | | | | | | | | | | | | | | | Updater arguments dealing with flash and servo control will be common with other commands. Move those to a shared file. BUG=b:260531154 BRANCH=None TEST=FEATURES=test emerge-grunt vboot_reference TEST=futility gbb -s --flags 0x0 /tmp/bios /tmp/bios2 Change-Id: I0a6c992425cf7ca529b3857cfabc654ae2b1be81 Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4075308 Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility: gbb: Handle errors in reading filesEvan Benn2022-12-141-9/+18
| | | | | | | | | | | | | | | | Detect errors and exit on errors from read_from_file. BUG=b:260531154 BRANCH=None TEST=FEATURES=test emerge-grunt vboot_reference TEST=futility gbb -s --flags 0x0 /tmp/bios /tmp/bios2 --bmp_fv /dev/null TEST=futility gbb -g /tmp/bios Change-Id: I1e24342642bcc276c6fb195ebfc95a1393100147 Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4099828 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility: gbb: Make error handling consistent in main()Evan Benn2022-12-141-15/+40
| | | | | | | | | | | | | | | | | | Make the error handling logically and visually consistent in the main switch statement. This makes the cleanup code run in all cases. futility will also return an error in some error cases that were not handled. BUG=b:260531154 BRANCH=None TEST=FEATURES=test emerge-grunt vboot_reference TEST=futility gbb -s --flags 0x0 /tmp/bios /tmp/bios2 TEST=futility gbb -g /tmp/bios Change-Id: I28c956959022cd3cb68aa476b81c0851d76c8739 Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4099827 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility: Move prepare_servo_control to updater_utils.cEvan Benn2022-12-143-11/+18
| | | | | | | | | | | | | BUG=b:260531154 BRANCH=None TEST=FEATURES=test emerge-grunt vboot_reference TEST=futility gbb -s --flags 0x0 /tmp/bios /tmp/bios2 Change-Id: Ib3bd54c81a66da8839bd46b7b4cd57277af4d0f9 Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4075309 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility: Move write_to_file to misc.cEvan Benn2022-12-143-35/+44
| | | | | | | | | | | | BUG=b:260531154 BRANCH=None TEST=FEATURES=test emerge-grunt vboot_reference TEST=futility gbb -s --flags 0x0 /tmp/bios /tmp/bios2 Change-Id: I92dc87acdd7f0efcb034ee1151fcae0651e80f6f Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4075307 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility: updater: Detect the model via FRID for non-host programmersSam McNally2022-12-124-1/+91
| | | | | | | | | | | | | | | | | | | | | | | When updating with --archive and a non-host programmer (and thus no reliable crosid to discover the appropriate firmware manifest key), and no explicit --model parameter is passed, try to detect the model by matching the FRID of the current firmware with one of the host firmware images in the archive. Add a --detect-model-only flag to perform the same matching, but report the detected model name and exit. This can be used in combination with the manifest to automatically select an appropriate EC image to pass to flash_ec. BUG=b:253966060 TEST=futility update -a firmware.tar.bz2 --servo BRANCH=None Signed-off-by: Sam McNally <sammc@chromium.org> Change-Id: I25fa0f109d0d8052179b220251d4720438b93bc4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3965584 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility: gbb: Move errorcnt from function to mainEvan Benn2022-12-111-18/+21
| | | | | | | | | | | | | | | | | | Move the error recording from a global to checking the function return code. The function can then be moved to another translation unit. BUG=b:260531154 BRANCH=None TEST=FEATURES=test emerge-grunt vboot_reference TEST=futility gbb -s --flags 0x0 /tmp/bios /tmp/bios2 Change-Id: I7a2d35471f55d557e707568d0981b1d8cbbc6a19 Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4082790 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org>
* futility: Store errno before printing strerrorEvan Benn2022-12-111-19/+23
| | | | | | | | | | | | | | | | | | errno was being printed and then errno was returned from the function. This can be incorrect if the print function changes errno. Instead store errno, print and return the same value. BUG=b:260531154 BRANCH=None TEST=FEATURES=test emerge-grunt vboot_reference TEST=futility gbb -s --flags 0x0 /tmp/bios /tmp/bios2 Change-Id: I5016ac31e56c4a0f16f89a2a52087ba64833d28a Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4075306 Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility: Return -1 from read_from_fileEvan Benn2022-12-111-1/+1
| | | | | | | | | | | | | | | | | | Returning errno when there was no libc error was wrong. Return -1. No one checks the error from this function anyway. BUG=b:260531154 BRANCH=None TEST=FEATURES=test emerge-grunt vboot_reference TEST=futility gbb -s --flags 0x0 /tmp/bios /tmp/bios2 Change-Id: Ib91e0917fc1e33a4a95b3874639c3e2fcc5dd1df Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4075305 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility: updater: Skip loading non-host images with --emulation passedSam McNally2022-12-071-1/+1
| | | | | | | | | | | | | | | | | | | When using --emulation with a bundled updater, the presence of EC or PD firmware images causes the check_single_image condition to fail, since EC and PD programmers are not supported by --emulation. Treat --emulation the same as --host_only for deciding what images to load. BUG=b:259347347 TEST=firmware_UpdaterModes on xivu BRANCH=None Change-Id: I07549e01107edff26b66d5afe5c0e5b325ff996f Signed-off-by: Sam McNally <sammc@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4066244 Tested-by: Frank Wu <frank_wu@compal.corp-partner.google.com> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Frank Wu <frank_wu@compal.corp-partner.google.com> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility: try ignoring GBB flags when validating GSCVDVadim Bendebury2022-12-011-11/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | GBB flags contents are ignored when AP RO ranges hash is calculated. The embedded verification will succeed only if the flags are cleared, but the command line tool should not fail because of nonzero GBB flags. This patch adds add additional pass when validating to see if validation succeeds with GBB flags zeroed. Also adding a debug printout to allow the user to see ranges covered by the signature when validating an image and modifying the tests to accommodate passing when GBB flags are non-zero. BRANCH=none BUG=none TEST=successfully validated AP RO signature with the same image with and without cleared gbb flags. When checking the image with nonzero flags the 'Ranges digest matches with zeroed GBB flags' warning message is printed. invoking 'make runtests' succeeds. Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: I3e38924f14697a3efd058286f9579d89e5161910 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4049934 Commit-Queue: Yu-Ping Wu <yupingso@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility: updater: Only apply the preserve_me quirk for autoupdates.Sam McNally2022-12-013-20/+16
| | | | | | | | | | | | | | | | | | | | | | The preserve_me applies for all non-factory updates for firmware with the quirk enabled. It was only really intended to apply to firmware updates during autoupdates, that is --mode=autoupdate. Instead, we checked for an archive, which is always set, possibly a fallback directory archive rather than an archive file, resulting in it being used except for --mode=factory. Switch the condition to TRY_UPDATE_AUTO instead so only --mode=autoupdate enables the preserve_me quirk. BUG=b:255447297 TEST=futility update -i /tmp/image.bin doesn't apply the quirk futility update -i /tmp/image.bin -m autoupdate applies the quirk BRANCH=None Change-Id: I7459f027a918dc70cbde1bfc6f5da2b549bcc513 Signed-off-by: Sam McNally <sammc@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4050014 Reviewed-by: Karthikeyan Ramasubramanian <kramasub@google.com> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* Reland "crossystem: Add board_id property"Jack Rosenthal2022-11-231-23/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 87663c3bef0f6b198945cf3eb83632f461a5d6f8. The parent CL to this commit should be sufficient to resolve the failure that prevented "crossystem board_id" on ARM from working. Original change's description: > crossystem: Add board_id property > > futility is one of a few places in ChromeOS that uses "mosys platform > version". The goal is to remove this command from mosys. > > This commit adds a new property to crossystem, "board_id", which > reads the board revision from SMBIOS/FDT, and replaces the call in > futility with the appropriate VbGetSystemPropertyInt. > > BUG=b:187790074 > BRANCH=none > TEST="crossystem board_id" on hana and brya > > Change-Id: Id69c8e309c0e509a165aa6da2778573ac7de3455 > Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4029537 > Reviewed-by: Julius Werner <jwerner@chromium.org> BUG=b:187790074 BRANCH=none TEST="crossystem board_id" on hana and brya Change-Id: I37b4c622e3c1d294b5be8e0d98ef14175902acc3 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4045047 Reviewed-by: Julius Werner <jwerner@chromium.org>