Clone this repo:
  1. 255db42 imports: Keep up with flashrom by Hsuan Ting Chen · 3 months ago factory-brox-16086.B factory-nissa-16077.B firmware-R130-16032.B firmware-R131-16062.B firmware-brox-16080.B firmware-ec-R131-16063.2.B firmware-ec-R132-16093.3.B main release-R130-16033.B release-R131-16063.B release-R132-16093.B stabilize-16033.43.B stabilize-16033.58.B stabilize-16055.B stabilize-starline-16056.B stabilize-starline-16082.B stabilize-starline-16084.B stabilize-starline-16093.2.B stabilize-starline-16095.B
  2. 6a49659 imports: Keep up with flashrom by Hsuan Ting Chen · 7 months ago firmware-R126-15885.B firmware-R127-15916.B firmware-R128-15963.B firmware-R129-16001.B firmware-android-15949.B firmware-hps-15892.B firmware-ti50-mp-15980.B firmware-ti50-prepvt-15974.B release-R126-15886.B release-R127-15917.B release-R128-15964.B release-R129-16002.B stabilize-15886.46.B stabilize-15886.63.B stabilize-15886.66.B stabilize-15888.B stabilize-15905.B stabilize-15917.61.B stabilize-15917.65.B stabilize-15926.B stabilize-15964.20.B stabilize-15964.42.B stabilize-15964.9.B stabilize-16002.44.B stabilize-16002.51.B stabilize-hps-15890.B stabilize-quickfix-15886.43.B
  3. 6ed9655 OWNERS: Add roccochen and jjsu by [email protected] · 12 months ago factory-geralt-15840.B factory-rex-15708.B firmware-android-geralt-15842.88.B firmware-geralt-15842.B firmware-rex-15709.B release-R122-15753.B release-R123-15786.B release-R124-15823.B release-R125-15853.B stabilize-15714.B stabilize-15753.46.B stabilize-15753.55.B stabilize-15756.B stabilize-15786.48.B stabilize-15786.58.B stabilize-15793.B stabilize-15823.40.B stabilize-15828.B stabilize-15855.B stabilize-15857.B stabilize-quickfix-15786.49.B stabilize-quickfix-15823.44.B
  4. abc266b imports: Keep up with flashrom by [email protected] · 12 months ago
  5. be7a40d main.c: print machine-ready version of SR value/mask pairs by Jett Rink · 1 year, 7 months ago factory-brya-15684.B factory-corsola-15196.B factory-skyrim-15384.B firmware-cr50-efi-15611.28.B firmware-cr50-mp-15611.B firmware-cr50-prepvt-15608.B release-R115-15474.B release-R116-15509.B release-R117-15572.B release-R118-15604.B release-R119-15633.B release-R120-15662.B release-R121-15699.B stabilize-15474.38.B stabilize-15474.53.B stabilize-15474.70.B stabilize-15483.B stabilize-15485.B stabilize-15509.37.B stabilize-15509.63.B stabilize-15509.72.B stabilize-15511.B stabilize-15519.B stabilize-15531.B stabilize-15532.B stabilize-15561.B stabilize-15562.B stabilize-15563.B stabilize-15564.B stabilize-15572.16.B stabilize-15572.39.B stabilize-15572.4.B stabilize-15572.50.B stabilize-15572.57.B stabilize-15572.63.B stabilize-15588.B stabilize-15604.16.B stabilize-15604.45.B stabilize-15604.56.B stabilize-15604.57.B stabilize-15610.B stabilize-15633.44.B stabilize-15633.58.B stabilize-15633.69.B stabilize-15642.B stabilize-15654.B stabilize-15662.64.B stabilize-15662.76.B stabilize-15662.78.B stabilize-15662.80.B stabilize-15662.88.B stabilize-15677.B stabilize-15699.58.B stabilize-15699.66.B stabilize-FLEX-15662.115.B stabilize-quickfix-15662.77.B

ap_wpsr tool

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.

limitations

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:

  • Incorrect writeprotoct SR topology data within the database.
  • Duplicate chips or otherwise ambiguous chip identifiers (id or string name).
  • OTP fused values within the SPI flash chip itself.

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.

usage

An example usage could be ./ap_wpsr -n "W25Q128.V" -s 0x40000 -l 0xFC0000.

finding chip names

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:

  • Check the chip's datasheet to find the vendor and device ID values.
  • Inspect flashchips.h to find matching ID define macros.
  • Inspect flashchips.c to find the chip entry that uses those ID macros
  • If there are multiple flashrom chip entries with the same IDs, check all of them against the datasheet to find the correct one.
  • Finally, check that the chip entry has a reg_bits field and that it matches the datasheet exactly. Verify that all WP-related bits in the datasheet are included in reg_bits and vice versa.
  • If there are no matching chip entries, create one for the chip and send a patch to upstream flashrom for review.
  • Pass the matching entry's name to the tool via the -n option.

src structure

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.