commit | be7a40d5e04178f3b331fbf4345ea3b2a3c60392 | [log] [tgz] |
---|---|---|
author | Jett Rink <jettrink@google.com> | Fri May 19 15:25:51 2023 |
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | Sat May 20 03:47:34 2023 |
tree | 471920c4f9dbc302fcf06d6140ecdbbed217a591 | |
parent | d68a1973cf84156289c9012525897fd47ed533a9 [diff] |
main.c: print machine-ready version of SR value/mask pairs The gsctool -E command takes in SR value masks in the following format `gsctool -E SR1-Val SR1-Mask [SR2-Val SR2-Mask [SR3-Val SR3-Mask]]` Provide a string output that gives us exactly the input needed. This reduces the needs for more complex parsing and string manipulate in OS scripts. BUG=b:233971354 TEST=see the following output locally from ./ap_wpsr --name=W25Q64JW...M --start=0 --length=0x00400000 ... * SR = {0xb8, 0x00, 0x00}. * SR mask = {0xfc, 0x41, 0x04}. * SR Value/Mask = 0xB8 0xFC 0x00 0x41 0x00 0x04 Change-Id: Ica496451c3774a39c840da365b79e57c62453219 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/ap_wpsr/+/4549497 Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Tested-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
The ap_wpsr tool was built to address specific requirements of AP RO verification that intends to measure SR contents for invariance after signature validation.
The tool leverages the flashrom SPI flash chips database to produce theoretical mask,value pairs for a given WP configuration (i.e. protection range start and length) and flash chip part name.
There are however some limitations. While the tool is pure logic (no side-effects) and intended to calculate values with reasonable fidelity there could however be inaccuracies.
These inaccuracies can be the result of any combination of the following factors:
A precise flash chip name is required to be cited physically on what chip is being worked with (and not via probing or other inferences). This precise name needs to be mapped to the corresponding name within the database to produce the tool output products. The output products must be cross-validated with the datasheet to ensure the products are consistent with expectations and any errors in the database are corrected with a patch back to the canonical flashrom flashchips database upstream.
An example usage could be ./ap_wpsr -n "W25Q128.V" -s 0x40000 -l 0xFC0000
.
The ap_wpsr tool needs to be given the name of the flashrom chip entry to use for calculating mask,value pairs. This name may not match the vendor name, for example the chip “W25Q128FVSIG” corresponds to a flashrom entry called “W25Q128.V”.
These steps should be followed to find the flashrom chip name for your chip:
-n
option.There are two key parts to the tool imports/
and shim/
. The shim/
directory just contains enough symbols to allow linking of the imports/
source taken from upstream flashrom. The imports/
contains two key ingredients - the chip database and the writeprotection calculation code. These should be kept up to date by importing fresh copies from flashrom.