Keith Short has uploaded this change for review.

View Change

util/cbfstool: Fallback to linear search

When the image size is a power of 2, cbfstool attempts to find the FMAP
region using a binary search. However, if the FMAP location isn't
aligned on a 16 byte boundary the binary search fails.

Fall back to linear search if binary search fails.

TEST=cbfstool ec.bin layout

Change-Id: Ifa9f6f57d1c59114fd1d4ace2d82b62e953cf6a8
Signed-off-by: Keith Short <keithshort@chromium.org>
---
M util/cbfstool/flashmap/fmap.c
1 file changed, 6 insertions(+), 3 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/08/80308/1
diff --git a/util/cbfstool/flashmap/fmap.c b/util/cbfstool/flashmap/fmap.c
index 46c31bb..cf36bbb 100644
--- a/util/cbfstool/flashmap/fmap.c
+++ b/util/cbfstool/flashmap/fmap.c
@@ -149,10 +149,13 @@
if ((image == NULL) || (image_len == 0))
return -1;

- if (popcnt(image_len) == 1)
+ if (popcnt(image_len) == 1) {
ret = fmap_bsearch(image, image_len);
- else
- ret = fmap_lsearch(image, image_len);
+ if (ret >= 0)
+ return ret;
+ }
+
+ ret = fmap_lsearch(image, image_len);

return ret;
}

To view, visit change 80308. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: Ifa9f6f57d1c59114fd1d4ace2d82b62e953cf6a8
Gerrit-Change-Number: 80308
Gerrit-PatchSet: 1
Gerrit-Owner: Keith Short <keithshort@chromium.org>
Gerrit-MessageType: newchange