summaryrefslogtreecommitdiff
path: root/futility
Commit message (Collapse)AuthorAgeFilesLines
* futility/: Drop dup host programmer defineHEADmainEdward O'Callaghan2023-05-183-7/+6
| | | | | | | | | | | | | | BUG=b:282585789 BRANCH=none TEST=`cros_run_unit_tests --host --packages vboot_reference`. Change-Id: I263ea5a68da3be4fdb07bfd0197645180d32ed3f Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4542040 Tested-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Nikolai Artemiev <nartemiev@google.com> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Auto-Submit: Edward O'Callaghan <quasisec@chromium.org>
* 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.c: Inline write_ec_firmware()Edward O'Callaghan2023-05-171-28/+22
| | | | | | | | | | | | | | | | Avoid indirection. BUG=b:282585789 BRANCH=none TEST=`cros_run_unit_tests --host --packages vboot_reference`. Change-Id: I5391c349ff60569e4dcc6c1c4605ccb9901c290b Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4532320 Commit-Queue: Nikolai Artemiev <nartemiev@google.com> Reviewed-by: Nikolai Artemiev <nartemiev@google.com> Tested-by: Edward O'Callaghan <quasisec@chromium.org> Auto-Submit: Edward O'Callaghan <quasisec@chromium.org>
* 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.c: Dedup update_legacy_firmware() logicEdward O'Callaghan2023-05-161-21/+19
| | | | | | | | | | | | | BUG=b:282585789 BRANCH=none TEST=`cros_run_unit_tests --host --packages vboot_reference`. Change-Id: I8fdc14236a478cc1ad0f39e091b19223cb3d9470 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4532321 Reviewed-by: Nikolai Artemiev <nartemiev@google.com> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org>
* futility/: Inline write_firmware() as write_system_firmware()Edward O'Callaghan2023-05-163-25/+14
| | | | | | | | | | | | | | | Avoid confusing indirections. BUG=b:282585789 BRANCH=none TEST=`cros_run_unit_tests --host --packages vboot_reference`. Change-Id: I5fdc01affcce2399955b594abf98c7550815b56b Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4532319 Tested-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Nikolai Artemiev <nartemiev@google.com> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org>
* futility/updater.c: Rename write_optional_firmware()Edward O'Callaghan2023-05-161-6/+5
| | | | | | | | | | | | | | | The function relates to the EC path. BUG=b:282585789 BRANCH=none TEST=`cros_run_unit_tests --host --packages vboot_reference`. Change-Id: I0da0df25f659404bd639a863a68a2b717d593d1d Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4532318 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.c: Drop redundant params to write_optional_firmware()Edward O'Callaghan2023-05-161-8/+5
| | | | | | | | | | | | | BUG=b:282585789 BRANCH=none TEST=`cros_run_unit_tests --host --packages vboot_reference`. Change-Id: I3da2da752cc45a34b25616fea225654abe60a214 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4532317 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.c: Drop redundant has_valid_update() in EC pathEdward O'Callaghan2023-05-161-2/+0
| | | | | | | | | | | | | BUG=b:282585789 BRANCH=none TEST=`cros_run_unit_tests --host --packages vboot_reference`. Change-Id: Ic3ba500b45cdc9098808aca69eb852ec317d094b Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4532316 Reviewed-by: Nikolai Artemiev <nartemiev@google.com> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org>
* futility/cmd_dump_fmap.c: Rewrite with scoped logicEdward O'Callaghan2023-05-151-4/+4
| | | | | | | | | | | | | | | | Scope fmap header to loop construct. Also do not exit(1) on error branches, return error codes. BUG=b:268397597 TEST=`emerge-nissa vboot_reference`. Change-Id: I0190cb55740a21cbf9a74929fa6dd612f398d350 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4313543 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>
* futility/cmd_create.c: Drop dead commentEdward O'Callaghan2023-05-151-1/+0
| | | | | | | | | | | | | | BUG=b:268397597 BRANCH=none TEST=`emerge-nissa vboot_reference`. TEST=`cros_run_unit_tests --host --packages vboot_reference`. Change-Id: I21935ef6733d345949ffd1d8964aa9805318109a Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4531328 Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Sam McNally <sammc@chromium.org>
* futility/misc.c: Check mmap() ret with std valueEdward O'Callaghan2023-05-151-1/+1
| | | | | | | | | | | | | | | BUG=b:268397597 BRANCH=none TEST=`emerge-nissa vboot_reference`. TEST=`$ cros_run_unit_tests --host --packages="vboot_reference flashrom"`. TEST=`$ cros_run_unit_tests --board=nissa --packages="vboot_reference flashrom"`. Change-Id: I0033d52fb14ece7397451ba6283592c726833a94 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4531327 Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Sam McNally <sammc@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org>
* futility/misc.c: Use ERROR() macro consistentlyEdward O'Callaghan2023-05-151-22/+16
| | | | | | | | | | | | | | | BUG=b:268397597 BRANCH=none TEST=`emerge-nissa vboot_reference`. TEST=`$ cros_run_unit_tests --host --packages="vboot_reference flashrom"`. TEST=`$ cros_run_unit_tests --board=nissa --packages="vboot_reference flashrom"`. Change-Id: I86035534ba6318bad29c8cb43c3b72e2f984e953 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4531326 Tested-by: Edward O'Callaghan <quasisec@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Sam McNally <sammc@chromium.org>
* futility/file_type_bios.c: Improve branch readabilityEdward O'Callaghan2023-05-151-12/+10
| | | | | | | | | | | | | | | | BUG=b:268397597 BRANCH=none TEST=`emerge-nissa vboot_reference`. TEST=`$ cros_run_unit_tests --host --packages="vboot_reference flashrom"`. TEST=`$ cros_run_unit_tests --board=nissa --packages="vboot_reference flashrom"`. Change-Id: I3eb8810a7c5efd7042f422bb772567daf87e803c Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4531325 Reviewed-by: Sam McNally <sammc@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Auto-Submit: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org>
* futility/cmd_dump_fmap.c: Rewrite to se proper arg identifiersEdward O'Callaghan2023-05-151-15/+15
| | | | | | | | | | | | | The previous function parameter names were cryptic at best. BUG=b:268397597 TEST=`emerge-nissa vboot_reference`. Change-Id: I6f384db9fcfc855caf229fef338117f47b46cea3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4313542 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_create.c: Drop globalsEdward O'Callaghan2023-05-151-38/+41
| | | | | | | | | | | | | | | | | | | Write proper functions that consume and return values. Allow code to be maintainable and extensible. Fix types where required while here as well. BUG=b:268397597 BRANCH=none TEST=`emerge-nissa vboot_reference`. TEST=`cros_run_unit_tests --host --packages vboot_reference`. Change-Id: I9a615506685b45d0c05936aa83ee3c5b08f8c04a Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4313545 Reviewed-by: Sam McNally <sammc@chromium.org> Auto-Submit: Edward O'Callaghan <quasisec@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org>
* futility/cmd_dump_fmap.c: Rewrite without globalsEdward O'Callaghan2023-05-151-36/+36
| | | | | | | | | | | | | | | | | | | Write proper functions that consume and return values. Allow code to be maintainable and extensible. Fix types required while here as well. Deal with odd func recursion with const opt param. BUG=b:268397597 TEST=`emerge-nissa vboot_reference`. TEST=`$ cros_run_unit_tests --host --packages="vboot_reference flashrom"`. TEST=`$ cros_run_unit_tests --board=nissa --packages="vboot_reference flashrom"`. Change-Id: I09245ce703054369b8fad960927f68fb5c386cf1 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4313541 Commit-Queue: Sam McNally <sammc@chromium.org> Reviewed-by: Sam McNally <sammc@chromium.org> Auto-Submit: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org>
* Add checks for a few minor overflow risksJulius Werner2023-05-131-4/+4
| | | | | | | | | | | | | | | | This patch fixes a few locations where specific maliciously crafted input could cause an arithmetic overflow to bypass a size check. In none of those instances is the data being parsed actually untrusted for our use case, so there was no real security risk here. This is just extra hardening. BUG=chromium:1441030,b:280378929 TEST=Booted CoachZ Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: I65f2d483f1e67686b7a22f0f7eb3ce5c3eabfdfa Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4505019 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
* futility/cmd_flash_util.c: Print fw expected wp sr conf valuesEdward O'Callaghan2023-05-121-30/+37
| | | | | | | | | | | | | | | | | | | | | AP RO verification in the case of non-factory flows wishes to determine the WP configuration values needed to calculate the SR configuration data as defined by the firmware image. Since we already do this to configure WP correctly on the DUT using FW derived values parsed from the WP_RO region within the FMAP we can simply print the offset and length. BUG=b:281888335 TEST=`cros_run_unit_tests --host --packages vboot_reference`. Change-Id: Iafa0cc4193453cc67952aa4ff1f1554ac1861882 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4520486 Reviewed-by: Nikolai Artemiev <nartemiev@google.com> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org> Auto-Submit: Edward O'Callaghan <quasisec@chromium.org>
* futility/: EOL PD firmware updating supportEdward O'Callaghan2023-05-055-44/+14
| | | | | | | | | | | | | | | | | | | The kunimitsu/glados family uses a PD MCU. These include lars, sentry, caroline, and chell. The kunimitsu family reaches AUE 2023-Jun-01. As part of removing cros_ec out of flashrom drop which support for this subtype so then EOL it from futility too. BUG=b:262782150,b:280268486 BRANCH=none TEST=`cros_run_unit_tests --board=nissa --packages="vboot_reference flashrom"`. Cq-Depend: chromium:4453124, chromium:4486860 Change-Id: I111492c7386dec012419cb0581e302e7e1f1719e Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4486657 Reviewed-by: Sam McNally <sammc@chromium.org> Auto-Submit: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Edward O'Callaghan <quasisec@chromium.org>
* 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>