From 45e2d5d641016d6c39c66e10fda874379f3c7fa0 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Tue, 7 Jun 2022 19:34:08 +0100 Subject: x1000: check for ECC failures in bootloader uimage reader Update the uimage reader's bad block handling to treat an ECC uncorrectable error on the first page of the block as a bad block. Change-Id: Id3aa7a338fcc36c0e2381063b119efe41f957122 --- bootloader/x1000/utils.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'bootloader/x1000/utils.c') diff --git a/bootloader/x1000/utils.c b/bootloader/x1000/utils.c index 46624b0d1d..a1d90dedbb 100644 --- a/bootloader/x1000/utils.c +++ b/bootloader/x1000/utils.c @@ -189,6 +189,15 @@ static ssize_t uimage_nand_reader(void* buf, size_t count, void* rctx) while(d->page < d->end_page && read_count < count) { rc = nand_page_read(ndrv, d->page, ndrv->page_buf); + + /* Ignore ECC errors on the first page of a block. This may + * indicate a bad block. */ + if(rc == NAND_ERR_ECC_FAIL && + d->page % ndrv->ppb == 0 && d->offset == 0) { + d->page += ndrv->ppb; + continue; + } + if(rc < 0) return -1; -- cgit v1.2.3