diff options
author | Stefan Agner <stefan.agner@toradex.com> | 2016-09-16 14:39:48 -0700 |
---|---|---|
committer | Marcel Ziswiler <marcel.ziswiler@toradex.com> | 2016-09-29 06:03:51 +0200 |
commit | 2bb0703b30a6febfe6708e4ee1ce061bb19dd807 (patch) | |
tree | 7a5213a229bd70a086dd695472120c6fb27f2379 | |
parent | 11824819d53f37913b404eaca2977f0c9c5964ff (diff) |
cmd_writebcb_mx7: fix skip bad block when writing bootloader
Correctly skip bad blocks when writing boot loader. Despite this
fix U-Boot will generate excessive amount of messages when hitting
a bad block:
Size of write exceeds partition or device limit
However, the command continues to write page by page until writing
succeeds.
Note that despite the correct bad block skip schema in place, the
current FCB uses DISBBM = 1 which seems to disable the skip bad
block handling in Boot ROM.
Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
-rw-r--r-- | arch/arm/imx-common/cmd_writebcb_mx7.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/arch/arm/imx-common/cmd_writebcb_mx7.c b/arch/arm/imx-common/cmd_writebcb_mx7.c index 326ed6ec7d4..4267cd75468 100644 --- a/arch/arm/imx-common/cmd_writebcb_mx7.c +++ b/arch/arm/imx-common/cmd_writebcb_mx7.c @@ -372,19 +372,27 @@ static void create_dbbt(nand_info_t *nand, uint8_t *buf) static void write_bootloader(nand_info_t *nand, uint8_t * addr, loff_t off, ulong fw_size) { - int i, j, ret; + int i, j, ret = 0; size_t maxsize; unsigned used_page_size, used_page_size_tmp; - ret = 0; used_page_size = 3 * nand->writesize / 4; maxsize = nand->writesize; - for (i = 0, j = 0; i < fw_size; - i += used_page_size, j += nand->writesize) { + for (i = 0, j = 0; i < fw_size; j += nand->writesize) { used_page_size_tmp = used_page_size; - ret |= nand_write_skip_bad(nand, off + j, &used_page_size_tmp, + ret = nand_write_skip_bad(nand, off + j, &used_page_size_tmp, NULL, maxsize, (u_char *)addr + i, WITH_WR_VERIFY); + + /* Increment only if data have been written */ + i += used_page_size_tmp; + + /* Ignore EFBIG, it means that we hit a bad block... */ + if (ret == -EFBIG) + ret = 0; + + if (ret) + break; } printf("Bootloader %d bytes written to 0x%x: %s\n", (int)fw_size, (int) off, ret ? "ERROR" : "OK"); |