summaryrefslogtreecommitdiff
path: root/futility/updater_utils.c
Commit message (Collapse)AuthorAgeFilesLines
* futility/updater_utils.c: Inline {read,write}_flash()Edward O'Callaghan2023-05-171-22/+11
| | | | | | | | | | | | | | | Avoid indirection. BUG=b:282585789 BRANCH=none TEST=`cros_run_unit_tests --host --packages vboot_reference`. Change-Id: I2ad99a61b801b856f53743c0ed4e00289ede5deb Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4541780 Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
* futility/updater_utils.c: Drop useless func operandEdward O'Callaghan2023-05-161-6/+4
| | | | | | | | | | | | | | | Unused param. BUG=b:282585789 BRANCH=none TEST=none Change-Id: I57f4a2f30965b078ab1482dd8eb31ddc29a1a5f4 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4532322 Reviewed-by: Nikolai Artemiev <nartemiev@google.com> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org>
* futility: updater: Add --unlock_me optionReka Norman2023-03-291-0/+93
| | | | | | | | | | | | | | | | | | | | 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-261-57/+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: 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-091-10/+3
| | | | | | | | | | | | | | | | | | | 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: updater: refactor DUT system info retrievalHung-Te Lin2023-02-121-63/+2
| | | | | | | | | | | | | | | | | | | | | | | 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>
* 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: add new quirk 'clear_mrc_data'Hung-Te Lin2023-01-191-0/+17
| | | | | | | | | | | | | | | | | | | | | 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>
* futility: cmd_read: Do not error on bad firmware formatEvan Benn2023-01-131-4/+4
| | | | | | | | | | | | | | | | 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: Move prepare_servo_control to updater_utils.cEvan Benn2022-12-141-0/+11
| | | | | | | | | | | | | 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>
* 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>
* Revert "crossystem: Add board_id property"stabilize-15251.BBrian Norris2022-11-191-1/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit db1b34f559fdbf5584b57007da43e4dddda43c6a. Reason for revert: seems to break scarlet - b/259702907 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, b:259702907 Change-Id: Ibdc2525d6f395e2ef63354d36ca02b71543e8079 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4038443 Commit-Queue: Jack Rosenthal <jrosenth@chromium.org> Tested-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Brian Norris <briannorris@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Owners-Override: Jack Rosenthal <jrosenth@chromium.org>
* crossystem: Add board_id propertyJack Rosenthal2022-11-171-23/+1
| | | | | | | | | | | | | | | | | | 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>
* host/lib: Add flashrom_read_region() to read just the requested regionSam McNally2022-11-171-1/+1
| | | | | | | | | | | | | | | | | | | | The region parameter to flashrom_read_image() is essentially unusable in isolation since it reads just the requested region into a buffer sized to the entire flash, at the offset of the region within the flash. Remove its unused region parameter and split the functionality of requesting a region into flashrom_read_region() which stores just the requested region into a buffer sized to the region. BUG=b:253966060 TEST=futility update --detect-model -a <archive> works as expected BRANCH=None Signed-off-by: Sam McNally <sammc@chromium.org> Change-Id: Ibf6c152dd42fbc99c1742fb077bc6aa35feeed08 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3965583 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility: updater: Use flashrom dummy programmer to implement --emulateSam McNally2022-11-171-58/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | futility update --emulate and flashrom's dummy programmer serve similar purposes - both provide support for using a file instead of a real ROM. The current --emulate implementation involves special-casing before interacting with flashrom and pre-filling in the current image contents; an appropriately-configured dummy programmer and unmodified flashrom interactions could accomplish the same outcome with a more centralised handling of --emulate. Other --emulate interactions mock out non-flashrom interactions, so need to continue handling --emulate specially for now. Switch --emulate to use the dummy programmer. Add an extra field to store the original programmer option for deciding on whether the apply the preserve_me quirk. BUG=b:253966060 TEST=unit tests BRANCH=None Signed-off-by: Sam McNally <sammc@chromium.org> Change-Id: I687749523f54edcb9dd41cfc85614949b9d6607a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3965582 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* futility: updater: change default servo programmer to raiden_debug_spiHung-Te Lin2022-10-281-9/+12
| | | | | | | | | | | | | | | Servo v2 is deprecated, so we should change the default servo programmer to the servo micro/C2D2 programmer (raiden_debug_spi). BUG=b:256007307,b:256048551 TEST=make; run tests BRANCH=None Change-Id: Ie42d79ed2b7bd664dfdf01f4631665bac23040f2 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3989704 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility: Use ccd update mode for suzyq ti50Evan Benn2022-10-101-1/+2
| | | | | | | | | | | | | | | | | | | A ti50 TPM works with a servov4 as it reports 'ccd_gsc'. With suzyq 'ccd_ti50' is reported. Special case that string in the same way as cr50. BUG=b:251281342 BRANCH=None TEST=sudo futility update -a ./chromeos-firmwareupdate -m factory \ --servo --servo_port=9994 -d before: Selected Servo V2. after: Selected CCD. Change-Id: I1333fac24a023c1c88e708d69196f8da89777ef9 Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3929938 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-by: Sam McNally <sammc@chromium.org>
* treewide: Fix license headers to conform with linterJakub Czapiga2022-10-041-1/+1
| | | | | | | | | | | | | BRANCH=none BUG=none TEST=cros lint Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I7710c43c8c70cf257a898f22c42ecbf350e125a2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3925702 Commit-Queue: Jakub Czapiga <czapiga@google.com> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Tested-by: Jakub Czapiga <czapiga@google.com>
* vboot_reference: make flashrom_get_wp() use libflashromNikolai Artemiev2022-08-181-1/+1
| | | | | | | | | | | | | | | | | | | | This makes flashrom_get_wp() use the new libflashrom WP interface that was recently added to flashrom and moves it to host/lib/flashrom_drv.c with the other libflashrom wrapper functions. BUG=b:223291615 BRANCH=none TEST=flashrom --wp-disable; futility update -i image.bin \ futility prints: `Write protection: 0 (disabled; HW=0, SW=0).` TEST=flashrom --wp-enable; futility update -i image.bin \ futility prints: `Write protection: 0 (disabled; HW=0, SW=1).` Change-Id: Ib13eeb2f1f718443271b074969ff69e66149f401 Signed-off-by: Nikolai Artemiev <nartemiev@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3540785 Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org>
* futility: updater: refactor 'archive' structure nameHung-Te Lin2022-05-151-1/+1
| | | | | | | | | | | | | | Rename 'struct archive' to 'struct u_archive' as 'updater archive' so in future we can support libarchive (which needs 'struct archive'). BUG=None TEST=make; run test BRANCH=None Change-Id: Id4e5b425044b6f1e64f504373c264dba05da62f4 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3644539 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* updater_utils: fix implicit conversion to enum wp_stateNikolai Artemiev2022-05-061-1/+1
| | | | | | | | | | | | | | | | | | The getter for HWWP implicitly converted the integer returned by crossystem to an `enum wp_state`. This only worked because of the particular values assigned to the enum values, so explicitly convert instead. BUG=b:223291615 BRANCH=none TEST=builds Change-Id: Ib572733f8b05a5a992f09ba98050a7eab5e3bcce Signed-off-by: Nikolai Artemiev <nartemiev@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3540784 Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org>
* futility: updater: Support new servo control 'ccd_cpu_fw_spi'stabilize-quickfix-14695.187.Bstabilize-quickfix-14695.124.Bstabilize-14695.85.Bstabilize-14695.107.Brelease-R102-14695.BHung-Te Lin2022-04-131-7/+12
| | | | | | | | | | | | | | | | | | | Some newer devices need extra preparation steps even when using CCD via servo, so a new 'ccd_cpu_fw_spi' is added to hdctools. The firmware updater should use it in servo+ccd modes. Also, the custom_rst is now moved to detect_servo so the --servo_noreset option is removed. BUG=b:216832684 TEST=make; run test BRANCH=None Change-Id: I6af0f03d5b0b1bb473ecb29680b253a5b71c7465 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3577658 Reviewed-by: Wai-Hong Tam <waihong@google.com> Tested-by: Wai-Hong Tam <waihong@google.com>
* futility: updater: add new quirk 'external_flashrom'stabilize-voshyr-14637.Bstabilize-14633.Bstabilize-14616.Bfactory-guybrush-14600.BHung-Te Lin2022-03-181-4/+2
| | | | | | | | | | | | | | | The new quirk will allow the updater to easily switch the underlying flash driver between the libflashrom and the external flashrom. BUG=None TEST=build and run test BRANCH=None Change-Id: I5b9da373b1e22a948e04d844973a5683adffe63c Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3534489 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Yu-Ping Wu <yupingso@chromium.org>
* futility: updater: support external flashromHung-Te Lin2022-03-181-22/+156
| | | | | | | | | | | | | | | | | | | The libflashrom is still different from the real flashrom program. To easily debug and compare the execution results (especially for devices under development), we want to allow the updater to switch between the libflashrom and the external flashrom. The real switch (either a quirk or a command line argument) will be added in a follow up change. BUG=None TEST=build and run test BRANCH=None Change-Id: I3f3226fd555dc9e7c40838cd1474e0d018b27ccc Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3500339 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Yu-Ping Wu <yupingso@chromium.org>
* futility: updater: refactor {write,load}_system_firmwareHung-Te Lin2022-03-181-44/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | The 'write_system_firmware' and 'load_system_firmware' have too many parameters that are already contained in the updater_config. To simplify the interfaces, we should just pass the updater_config to {write,load}_system_firmware, and merge the write_firmware_sections (only handling emulation and deciding the diff image) to the write_system_firmware. Also moved the utility functions only used by *_system_firmware (for example is_the_same_programmer and emulate_write_firmware) to the updater_utils.c. The emulate_write_firmware is also revised to handle a list of sections directly (so we don't need to handle that in write_system_firmware). BUG=None TEST=make; build and run test. BRANCH=None Change-Id: I4d123d12e8057da82d6c301899472e3773f3266e Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3508121 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Yu-Ping Wu <yupingso@chromium.org>
* futility: correct typo of "flashrom"stabilize-14589.Bstabilize-14588.98.Bstabilize-14588.14.Bstabilize-14588.123.Brelease-R101-14588.BPeter Marheine2022-03-161-1/+1
| | | | | | | | | | | BUG=none TEST=still builds BRANCH=none Change-Id: I3b244461b86c8aeec4f33ad7205157c709e0d695 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3524288 Reviewed-by: Reka Norman <rekanorman@chromium.org>
* futility: Support C2D2 with futility update --servo.Sam McNally2022-03-031-0/+7
| | | | | | | | | | | | | | | C2D2 is used similarly to servo micro. Mirror the servo micro logic accordingly. BUG=b:220992685 TEST=futility update --servo over C2D2 with and with servo v4 BRANCH=None Cq-Depend: chromium:3470605 Change-Id: I298fe5847abba0957fa5c2da4e1981a7da9e0428 Signed-off-by: Sam McNally <sammc@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3469746 Reviewed-by: Reka Norman <rekanorman@chromium.org>
* futility: updater: increase verbosity on retriesHung-Te Lin2022-03-021-2/+2
| | | | | | | | | | | | | | To get more message for debugging, we want to increase the verbosity on each retry. BUG=None TEST=build and run tests BRANCH=None Signed-off-by: Hung-Te Lin <hungte@chromium.org> Change-Id: I85e0fc518113a18bb1aaa39db3f58329d94b5ecb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3500326 Reviewed-by: Subrata Banik <subratabanik@chromium.org>
* futility: flashrom_drv: support partial write for multiple regionsHung-Te Lin2022-03-011-9/+27
| | | | | | | | | | | | | | | | | | | | | | | When we have multiple regions to update, invoking flashrom_write_image multiple times will take much longer because for each write it has to read the whole flash, write and then verify whole flash (also timer calibration and programmer init/shutdown every time). As a result, we want to support writing multiple regions - just like that flashrom can take arbitrary numbers of "-i REGION". This change only extended flashrom_write_image, and the firmware updater is calling flashrom_drv multiple times. That will be addressed in the follow up changes. BUG=b:221137867 TEST=build; and run test BRANCH=None Signed-off-by: Hung-Te Lin <hungte@chromium.org> Change-Id: Id335cc9f816f1384f1886422efa97fe2c7b81aec Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3490388 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* futility: updater: improve updater console outputHung-Te Lin2022-02-251-0/+17
| | | | | | | | | | | | | | | | | | | To help debugging: - Print equivalent flashrom commands when reading and writing. - Print <sys-flash> instead of <none> in 'Current system:' message. - Always print the detected model from libcrosid. - After writing to flash, print a new line. BUG=None TEST=make; build and run test BRANCH=None Change-Id: I34a73ec1c968a98a9fca649c65863aa43ca39ca8 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3461090 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Yu-Ping Wu <yupingso@chromium.org>
* futility: updater: add new quirk 'extra_retries'Hung-Te Lin2022-02-141-6/+18
| | | | | | | | | | | | | | | | | In early bring up, some devices may have problem when flashrom is reading or writing to the system flash. To unblock dogfood process, we want to have a special quirk to retry flashing. BUG=b:213706510 TEST=make; build and run test BRANCH=None Change-Id: I58788f620fb32f7c886d1e5638f4a3605ea77953 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3452846 Reviewed-by: YH Lin <yueherngl@chromium.org> Commit-Queue: YH Lin <yueherngl@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility: updater: split 'fast update' into 'diff image' and 'no verify'Hung-Te Lin2022-01-251-2/+3
| | | | | | | | | | | | | | | | | | Some special quirks (for example preserving ME) may want to use diff image but still do verification, so we want to change 'fast_update' config into two flags: 'do_verify' and 'use_diff_image'. BUG=b:213706510 TEST=build BRANCH=None Change-Id: Ia0160918ac58110850dd7f622610398ebfb92b47 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3404061 Reviewed-by: YH Lin <yueherngl@chromium.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* vboot_reference/futility: Pass through SERVOD_NAME.Sam McNally2022-01-071-2/+4
| | | | | | | | | | | | | | | SERVOD_PORT and SERVOD_NAME environment variables are both used by dut-control to identify the servod instance to use. If SERVOD_NAME is set, query the servo serial number just like when SERVOD_PORT is set. BUG=None TEST=futility --servo -i with SERVOD_NAME set BRANCH=None Change-Id: I0c656e25d4f5da67570e3ff7d6cf28fdca5ec1cf Signed-off-by: Sam McNally <sammc@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3367518 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* vboot_reference/futility: Support "ccd_gsc" as a servo type fragment.Sam McNally2022-01-071-2/+3
| | | | | | | | | | | | | | For DT, servo_type reports ccd_gsc instead of ccd_cr50. Treat ccd_gsc the same as ccd_cr50. BUG=None TEST=futility update --servo -i BRANCH=None Change-Id: I27f5ea7ccc70fd1a247b844a9929aed7a133ebb3 Signed-off-by: Sam McNally <sammc@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3367517 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* vboot_reference: Allow flashrom_read_image() reading per-regionstabilize-14438.BEdward O'Callaghan2022-01-041-1/+1
| | | | | | | | | | | | | | BUG=b:207808292 BRANCH=none TEST=`make` Signed-off-by: Edward O'Callaghan <quasisec@google.com> Change-Id: I98f1a2566ef50b2c7b1376141bb2f1c096b710a6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3358664 Tested-by: Edward O'Callaghan <quasisec@chromium.org> Auto-Submit: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Nikolai Artemiev <nartemiev@google.com> Commit-Queue: Nikolai Artemiev <nartemiev@google.com>
* vboot_ref/futility: Extract out flashrom call logicEdward O'Callaghan2021-12-241-188/+9
| | | | | | | | | | | | | | | | | | Separate out all the flashrom worker code used in futility to allow for later building a futility without flashrom support. BUG=b:203715651,b:209702505 BRANCH=none TEST=builds Signed-off-by: Edward O'Callaghan <quasisec@google.com> Change-Id: I938141056424f8f93a598bbb288ee7c8770edc95 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3350298 Tested-by: Edward O'Callaghan <quasisec@chromium.org> Auto-Submit: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org>
* vboot_reference/futility: Inline get_host_wp()Edward O'Callaghan2021-11-261-89/+26
| | | | | | | | | | | | | | | | | | | | | writeprotect still requires sub-processing flashrom as libflashrom currently lacks a API to perform this task. Therefore simplify the remaining sub-process logic for just this purpose. BUG=b:203715651 BRANCH=none TEST=cros deploy to nocturne and ran: `/usr/sbin/chromeos-firmwareupdate --mode=recovery --wp=1`. && `$ cros_run_unit_tests --board nocturne --packages vboot_reference`. Signed-off-by: Edward O'Callaghan <quasisec@google.com> Change-Id: I11c0f89997e3f47e97444cc8186823fa536b8d5d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3233704 Tested-by: Edward O'Callaghan <quasisec@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Nikolai Artemiev <nartemiev@google.com> Reviewed-by: Sam McNally <sammc@chromium.org>
* vboot_reference/futility: pipe log level thoughEdward O'Callaghan2021-11-251-12/+8
| | | | | | | | | | | | | | | | | Also drop colour support at reviewers request. BUG=b:203715651 BRANCH=none TEST=cros deploy to nocturne and ran: `/usr/sbin/chromeos-firmwareupdate --mode=recovery --wp=1`. && `$ cros_run_unit_tests --board nocturne --packages vboot_reference`. Signed-off-by: Edward O'Callaghan <quasisec@google.com> Change-Id: Ie1d1b1e8e304d21ac1df741a3b789cb49ede3556 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3244680 Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Sam McNally <sammc@chromium.org>
* vboot_reference/futility: Port R path to using libflashromEdward O'Callaghan2021-11-251-24/+33
| | | | | | | | | | | | | | | | | | | | | | Use libflashrom API over sub-processing the flashrom CLI. Squash in, Use buffer instead of temp file in load_system_firmware(). BUG=b:203715651 BRANCH=none TEST=cros deploy to nocturne and ran: `/usr/sbin/chromeos-firmwareupdate --mode=recovery --wp=1`. && `$ cros_run_unit_tests --board nocturne --packages vboot_reference`. Cq-Depend: chromium:3295109 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Change-Id: Ib78f7aa6606adb8d5ce72282c55b8e3b9e3b3cde Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3247853 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: Sam McNally <sammc@chromium.org>
* vboot_reference/futility: set layout when using regionNikolai Artemiev2021-11-241-0/+1
| | | | | | | | | | | | | | | Possible fix for flashrom trying to write whole flash. BUG=b:207359246 BRANCH=none TEST=builds Signed-off-by: Nikolai Artemiev <nartemiev@google.com> Change-Id: I69f40a46d3004a2cb4c675ff79854287f7f50766 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3295638 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org>
* vboot_reference/futility: Port W path to using libflashromEdward O'Callaghan2021-11-181-29/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | Use libflashrom API over sub-processing the flashrom CLI. Squash in, vboot_reference/futility: Use image layout as fallback Use the layout encoding within the image as the fallback if we cannot read it from ROM. Also cleanup error paths while here. BUG=b:203715651 BRANCH=none TEST=cros deploy to nocturne and ran: `/usr/sbin/chromeos-firmwareupdate --mode=recovery --wp=1`. && `$ cros_run_unit_tests --board nocturne --packages vboot_reference`. Cq-Depend: chromium:3249690, chromium:3281062, chromium:3288610 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Change-Id: I892aec510d8023abd42a07cbb036be79bc8b4498 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3247852 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: Sam McNally <sammc@chromium.org>
* vboot_reference/futility: Split load_firmware_image() fnstabilize-14312.BEdward O'Callaghan2021-10-281-29/+36
| | | | | | | | | | | | | | | | | | | | | This is in prep for removing the need for temp files. V.2: Move validation into parse_firmware_image() BUG=b:203715651 BRANCH=none TEST=cros deploy to nocturne and ran: `/usr/sbin/chromeos-firmware --mode=recovery`. Signed-off-by: Edward O'Callaghan <quasisec@google.com> Change-Id: Id61fcb0f53546a78085e0a367c21780c5885bc51 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3244679 Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Commit-Queue: Sam McNally <sammc@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org> Auto-Submit: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Sam McNally <sammc@chromium.org>
* portability fixes: support building vboot on OpenBSDstabilize-13983.Bstabilize-13982.88.Bstabilize-13982.82.Bstabilize-13982.70.Bstabilize-13982.69.Bstabilize-13982.60.Bstabilize-13982.51.Brelease-R92-13982.BIdwer Vollering2021-05-201-1/+1
| | | | | | | | | | | This was done on OpenBSD 6.8. Required packages are: e2fsprogs and gcc. Change-Id: I86ec080e1ddb90053d81f1edd17d3406e7e737c6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2903352 Reviewed-by: Patrick Georgi <pgeorgi@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org> Commit-Queue: Patrick Georgi <pgeorgi@chromium.org>
* vboot_reference: migrate out of flashrom deprecated optionsDaniel Campello2021-04-281-1/+1
| | | | | | | | | | | | | | This change replaces --diff and --fast-verify for the supported equivalent flashrom options BRANCH=none BUG=b:186479007 TEST=tryjobs Change-Id: I614ba71c606dbe4e3a1b4988df845bcbbd61dd01 Signed-off-by: Daniel Campello <campello@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2853623 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* futility: updater: print flashrom execution logs on read failurestabilize-13505.1.BHung-Te Lin2020-09-261-0/+11
| | | | | | | | | | | | | | | | | | To prevent flooding AU logs, we don't want flashrom to print verbose logs especially when reading system SPI flash. However, if anything goes wrong it will be very helpful to have all the messages logged. With this patch, we will try reading system flash again with max verbosity. BUG=chromium:943262,b:169026171 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I5469182f2628855e65546bef3abf8791261aabca Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1545598 Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* portability fixes: support building vboot on FreeBSDIdwer Vollering2020-09-111-0/+3
| | | | | | | | | | | Built on FreeBSD 12.1-RELEASE, 13-CURRENT, using gcc9 installed from packages. Change-Id: Ifa8bb343c7e916c1b545cf6c1e4bd0a18ea391cd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2382790 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Julius Werner <jwerner@chromium.org>
* flashrom: set umask before creating temporary filesJack Rosenthal2020-07-201-0/+6
| | | | | | | | | | | | | | | Good security practice. Set to 077; resultant file permissions are: -rw------- BUG=b:160717634 BRANCH=none TEST=unit tests Change-Id: Ib3b853c824be4c98e7b9ddd31797104ec4ab67a9 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2302962 Reviewed-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org>
* futility: updater: Add '--servo_port' to select from multiple servodsHung-Te Lin2020-06-061-8/+35
| | | | | | | | | | | | | | | | | | | | | | | When multiple servo boards are connected to the host, we usually want to select the right servo by specifying its port, get the servo serial number, and pass that to flashrom programmer. The new --servo_port (or environment variable SERVOD_PORT) now allows developers to flash firmware via specific servod using futility updater easily: futility update --servo_port 9998 -i PATH_TO/image.bin BRANCH=None BUG=None TEST=make runtest; sudo futility update --servo_port 9998 -i image.bin Change-Id: Ic302f841abf745801995ff233fc209726ed039c8 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2228258 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Douglas Anderson <dianders@chromium.org>
* updater: Replace servo-v2 with google-servo-v2Nicolas Boichat2020-05-181-1/+1
| | | | | | | | | | | | | | servo-v2 will eventually be deprecated. BRANCH=none BUG=b:145175076 TEST=Flash with servo v2, no more "Warning: Use 'google-servo-v2' instead!" Change-Id: Ie7ae9e173a7cbe0fcd37d1c88b5746fb89cc8e22 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2206094 Reviewed-by: Hung-Te Lin <hungte@chromium.org>