summaryrefslogtreecommitdiff
path: root/futility
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* 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-173-67/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | 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: Update comment textJack Rosenthal2022-11-021-3/+3
| | | | | | | | | | | | | | | This doesn't use "mosys platform model" anymore, update the comment text. BUG=b:187790074 BRANCH=none TEST=none Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I8ee427a0f26f386d319bb12a9f64be70ecbb9761 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3995400 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Commit-Queue: Hung-Te Lin <hungte@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/cmd_show: set uninitialized variablefactory-trogdor-15210.BSelma Bensaid2022-10-241-1/+1
| | | | | | | | | | | | | | Fix coreboot standalone build by initializing body_c in show_fw_preamble_buf. BUG=b:254014539 Signed-off-by: Selma Bensaid <selma.bensaid@intel.com> Change-Id: I963a1e8556b36302d455710d4561fc8460c44405 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3961988 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-by: Jakub Czapiga <czapiga@google.com> Tested-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Yu-Ping Wu <yupingso@chromium.org>
* gscvd: presume GBB flags are zero when hashing the RO space contentsstabilize-15208.Bstabilize-15207.BVadim Bendebury2022-10-221-7/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | It is still being debated who is supposed to make sure that the GBB flags are set to zero before the root of trust validation is granted to the AP firmware image, but as of today the approach is that the GBB flags must be zero at AP RO validation time. The problem is that when AP RO space signature is created GBB flags can be set to a non-zero value. With this patch when AP RO areas contents is hashed, in case GBB flags are included in one of the ranges, the flags are not read from the flash, and substituted with zero. During validation the real flags value is used. A unit test is added to verify various futility gscvd GBB related situations, the blobs for the unit test were extracted from a Nivviks firmware image. BRANCH=none BUG=b:245799496, b:253540670 TEST='./tests/futility/test_gscvd.sh' and 'make runfutiltests' succeed Change-Id: I2f047b990cf71ea24d191fc690da08e25ebb10cc Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3958581 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* gscvd: refactor discovering GBB in the imageVadim Bendebury2022-10-221-29/+52
| | | | | | | | | | | | | | | | | | | | | | Separate GBB discovery into a function and cache GBB information in the ap_firmware_file structure for future use. BRANCH=none BUG=b:245799496 TEST=ran the following command ./build/futility/futility gscvd -G -R 00000000:00001000 \ --keyblock tests/devkeys/arv_platform.keyblock \ --platform_priv tests/devkeys/arv_platform.vbprivk \ --board_id XYZ1 \ --root_pub_key tests/devkeys/arv_root.vbpubk "${BIOS_FILE}" using 'futility' compiled before and after this patch was applied, verified that the resulting file is the same. Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: I3ab59536cfa75a303be3e9271d9b44b1de851f5c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3958580 Reviewed-by: Julius Werner <jwerner@chromium.org>
* futility: add option to save ro_gscvd section in a blobVadim Bendebury2022-10-221-9/+35
| | | | | | | | | | | | | | | | | | | | To support the "futility update" ability to put together firmware images for different targets, the pre-signed RO_GSCVD sections need to be included in the firmware tarball. This patch adds a command line option which will make 'futilty gscvd' save the signed section in a local file for inclusion in the tarball. BRANCH=none BUG=b:245799496 TEST=verified that passing the --gscvd_out command line option results in creating a file with the RO_GSCVD section contents, identical to the section in the signed binary file. Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: Id4a75c74ad1e27c11a6005472708730b8051f036 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3954963 Reviewed-by: Julius Werner <jwerner@chromium.org>
* cmd_update: avoid variable name aliasingVadim Bendebury2022-10-221-3/+3
| | | | | | | | | | | | | | This is a noop change making reading the code a little easier, avoid naming variable the same as the function name. BRANCH=none BUG=none TEST='make futil' still succeeds Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: I5b5d742aa5463160207f05f6c19c20754e538813 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3954469 Reviewed-by: Hung-Te Lin <hungte@chromium.org>
* treewide: Fix copyrights and extra new lines at end of fileJakub Czapiga2022-10-211-1/+1
| | | | | | | | | | | | | BUG=none BRANCH=none TEST=make runtests Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: If93a65ba58c4973d4b344229c7ee26685395bbbf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3964274 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Jakub Czapiga <czapiga@google.com> Tested-by: Jakub Czapiga <czapiga@google.com>
* futility: updater: Scan patch files for the signer_config manifestfactory-corsola-15197.Bfactory-corsola-15196.BHung-Te Lin2022-10-171-16/+46
| | | | | | | | | | | | | | | | | To migrate the archive manifest generation from `setvars.sh` to `signer_config.csv`, we have to find the patch files (rootkey.*, vblock_?.*, gscvd.*) in the signer_config manifest builder. Also updated the comments for how the signer_config works. BUG=b:251040363 TEST=make; run test BRANCH=None Change-Id: I6e30b7fc55fda2b24f7809a8f2215bb9af1117af Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3937843 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility: updater: Support patching GSCVDHung-Te Lin2022-10-142-10/+25
| | | | | | | | | | | | | | | To support patching firmware image files with different GSCVD (GSC verified data for AP RO verification) per brand code, we want to read and load the data from keyset/gscvd.$model in the firmware archives. BRANCH=None BUG=b:248317123 TEST=make; run test Change-Id: I99ed4bae21b8909da2cbb1ebca0b9bbac268be5d Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3937842 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility: Remove validate_rec_mrc commandstabilize-15185.Bstabilize-15185.7.BReka Norman2022-10-141-260/+0
| | | | | | | | | | | | | | | | | | | | | | | The `futility validate_rec_mrc` command was added to allow the MrcCacheTest factory test to verify the MRC cache. However, duplicating the verification logic between coreboot and futility is not very maintainable. This caused problems recently when CB:67670 replaced the checksum in the MRC header with a hash. MrcCacheTest was changed to instead read eventlog to check that coreboot successfully updated the cache: CL:3935801. Now `futility validate_rec_mrc` is no longer used, so remove it. BRANCH=none BUG=b:242667207, b:249174725 TEST=emerge-nissa vboot_reference Change-Id: I7b78cdbfdda37e70aef3675636ed347a4ea1694e Signed-off-by: Reka Norman <rekanorman@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3949072 Tested-by: Reka Norman <rekanorman@chromium.org> Commit-Queue: Reka Norman <rekanorman@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* firmware: host: futility: Add CBFS metadata hash supportstabilize-15183.14.BJakub Czapiga2022-10-127-119/+186
| | | | | | | | | | | | | | | | | | | | | | This patch adds support for signing and verification of coreboot images supporting VBOOT_CBFS_INTEGRATION. Images with config option CONFIG_VBOOT_CBFS_INTEGRATION=y will be signed with CBFS metadata hash in signature. vb2api_get_metadata_hash() should be used to extract hash value from VBLOCK and then should be used to verify CBFS metadata. To support full verification, CBFS file data verification should also be enabled and correctly handled. BUG=b:197114807 TEST=build with CB:66909 and boot on volteer/voxel with CONFIG_VBOOT_CBFS_INTEGRATION=y BRANCH=none Signed-off-by: Jakub Czapiga <czapiga@google.com> Change-Id: I4075c84820949be24c423ed14e291c89a0032863 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3811754 Commit-Queue: Julius Werner <jwerner@chromium.org> Reviewed-by: Julius Werner <jwerner@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>
* futility: Address double freestabilize-15167.BJon Murphy2022-10-052-2/+0
| | | | | | | | | | | | | | | | | | The body_sig pointer is being freed twice. This can lead to indeterminate behavior and could corrupt memory. Remove superfluous free to avoid memory corruption. BUG=b:250952592 TEST=NA BRANCH=None Change-Id: Ie4c11e940653550e24829f253d05be08d74620f6 Signed-off-by: Jon Murphy <jpmurphy@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3935032 Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Hsuan Ting Chen <roccochen@chromium.org> Commit-Queue: Julius Werner <jwerner@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org>
* treewide: Fix license headers to conform with linterJakub Czapiga2022-10-0436-38/+36
| | | | | | | | | | | | | 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>