diff options
author | Heiko Schocher <hs@denx.de> | 2016-06-07 06:55:44 (GMT) |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2016-06-09 17:53:13 (GMT) |
commit | 9ae63f46a387573236372b937ada34daa55b893d (patch) | |
tree | 24f4e30a579e3562d2ea71d328f8b36baeeaeaa8 /drivers | |
parent | 02b11f11993bc99c0ace4e750ba03f347502ebe9 (diff) | |
download | u-boot-fsl-qoriq-9ae63f46a387573236372b937ada34daa55b893d.tar.xz |
dfu, nand, ubi: fix erasing after write finish
writting to ubi nand partitions need after write ends an erase
of the remaining sectors. This fail, if dfu write size was not
a multiple of erasesize, example log:
Failure erase: -1
Fix this error.
Signed-off-by: Heiko Schocher <hs@denx.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/dfu/dfu_nand.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/dfu/dfu_nand.c b/drivers/dfu/dfu_nand.c index ab782be..9fb874c 100644 --- a/drivers/dfu/dfu_nand.c +++ b/drivers/dfu/dfu_nand.c @@ -139,6 +139,7 @@ static int dfu_read_medium_nand(struct dfu_entity *dfu, u64 offset, void *buf, static int dfu_flush_medium_nand(struct dfu_entity *dfu) { int ret = 0; + u64 off; /* in case of ubi partition, erase rest of the partition */ if (dfu->data.nand.ubi) { @@ -155,7 +156,16 @@ static int dfu_flush_medium_nand(struct dfu_entity *dfu) mtd = nand_info[nand_curr_device]; memset(&opts, 0, sizeof(opts)); - opts.offset = dfu->data.nand.start + dfu->offset + + off = dfu->offset; + if ((off & (mtd->erasesize - 1)) != 0) { + /* + * last write ended with unaligned length + * sector is erased, jump to next + */ + off = off & ~((mtd->erasesize - 1)); + off += mtd->erasesize; + } + opts.offset = dfu->data.nand.start + off + dfu->bad_skip; opts.length = dfu->data.nand.start + dfu->data.nand.size - opts.offset; |