Index: u-boot-2014.10/tools/env/fw_env.c =================================================================== --- u-boot-2014.10.orig/tools/env/fw_env.c 2017-11-01 12:53:09.477769600 +0530 +++ u-boot-2014.10/tools/env/fw_env.c 2017-11-01 12:54:18.193945833 +0530 @@ -712,6 +712,7 @@ size_t blocklen; /* erase / write length - one block on NAND, 0 on NOR */ size_t processed = 0; /* progress counter */ + int no_of_badblock = 0; /* no of bad block present */ size_t readlen = count; /* current read length */ off_t top_of_range; /* end of the last block we may use */ off_t block_seek; /* offset inside the current block to the start @@ -762,6 +763,7 @@ if (rc) { /* block is bad */ blockstart += blocklen; + no_of_badblock++; continue; } @@ -781,6 +783,14 @@ fprintf(stderr, "Read 0x%x bytes at 0x%llx on %s\n", rc, blockstart + block_seek, DEVNAME(dev)); #endif + /* + * Add badblock size to processed to avoid out of partition + * check + */ + if (no_of_badblock) + processed += readlen * no_of_badblock; + + no_of_badblock=0; processed += readlen; readlen = min (blocklen, count - processed); block_seek = 0; @@ -806,6 +816,7 @@ size_t erasesize; /* erase / write length - one block on NAND, whole area on NOR */ size_t processed = 0; /* progress counter */ + int no_of_badblock = 0; /* no of bad block present */ size_t write_total; /* total size to actually write - excluding bad blocks */ off_t erase_offset; /* offset to the first erase block (aligned) @@ -922,6 +933,7 @@ if (rc) { /* block is bad */ blockstart += blocklen; + no_of_badblock++; continue; } @@ -983,6 +995,14 @@ if (!libubi && mtd_type != MTD_ABSENT) ioctl(fd, MEMLOCK, &erase); + /* + * Add badblock size to processed to avoid out of partition + * check + */ + if (no_of_badblock) + processed += erasesize * no_of_badblock; + + no_of_badblock=0; processed += erasesize; block_seek = 0; blockstart += erasesize;