futility: Change find_fmap() to search larger alignments first

This patch changes the FMAP detection mechanism in host utilities to use
the same algorithm as flashrom: try to check the offset with the largest
possible alignment first, then subsequently check other offsets in the
order of larger to smaller alignments. This provides consistency between
the tools and makes the chance of finding the "wrong" FMAP (e.g. a bit
pattern that just looks like an FMAP header, maybe from a piece of
source code that tries to look for the same) less likely, since we
usually try to prefer large alignments for the FMAP offset (for flashrom
efficiency).

BRANCH=None (should be updated on the signers... is that a branch?)
BUG=chromium:447051
TEST='make runtests'. Manually ran the new dump_fmap on all images in
tests/futility/data, and on a "known broken" Veyron_Pinky image that had
a "fake" FMAP header at a 4-byte aligned offset.

Change-Id: I15873573a93f3926c70136679dccd626e5038614
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/240750
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
1 file changed