diff --git a/fmap.c b/fmap.c index 50cb96900..70815984a 100644 --- a/fmap.c +++ b/fmap.c @@ -190,6 +190,7 @@ static int fmap_bsearch_rom(struct fmap **fmap_out, struct flashctx *const flash struct fmap *fmap; const unsigned int chip_size = flashctx->chip->total_size * 1024; const int sig_len = strlen(FMAP_SIGNATURE); + bool skip_unreadable_orig = flashctx->flags.skip_unreadable_regions; if (rom_offset + len > flashctx->chip->total_size * 1024) return 1; @@ -206,6 +207,13 @@ static int fmap_bsearch_rom(struct fmap **fmap_out, struct flashctx *const flash goto _free_ret; } + /* + * Ignore unreadable regions when trying to locate the FMAP, in order + * to avoid a large amount of false-error prints to stderr. Unreadable + * regions have already reported so errors here are redundant. + */ + flashctx->flags.skip_unreadable_regions = true; + /* * For efficient operation, we start with the largest stride possible * and then decrease the stride on each iteration. Also, check for a @@ -264,6 +272,9 @@ static int fmap_bsearch_rom(struct fmap **fmap_out, struct flashctx *const flash break; } + /* Restore original flag, since we're done searching */ + flashctx->flags.skip_unreadable_regions = skip_unreadable_orig; + if (!fmap_found) goto _free_ret;