host/lib: add lightweight flashrom wrapper library

Lightweight wrapper around flashrom, exposing two APIs:

    flashrom_read(programmer, region, data_out, size_out)
    flashrom_write(programmer, region, data, size)

|region| can be NULL, in which case operate on the whole flash chip.

The intended usage of this wrapper library is to read/write VBNV from
SPI flash directly, avoiding the call thru mosys (which has deprecated
the command).  Bringing this logic into crossystem directly will also
help with expanding VBNV to 64-bytes.

TEST=provided unit tests

Change-Id: I3997bd03a2db7e58e4e76fc200c637dd3b5b20a4
Signed-off-by: Jack Rosenthal <>
5 files changed