Browse Source

Revert "fw_setenv: fix bug when SPI flash write size != sector size"

This reverts commit 44ecc1c216.

mtd writesize was errouneously interpreted as maximum allowed size, but
it is the minimum size. The patch raises performance issues because on
NOR flashes single bytes are written.

Signed-off-by: Stefano Babic <sbabic@denx.de>
pull/29/head
Stefano Babic 1 year ago
parent
commit
9f17a00ee5
  1. 29
      src/uboot_env.c

29
src/uboot_env.c

@ -759,8 +759,6 @@ static int mtdwrite(struct uboot_flash_env *dev, void *data)
sectors = dev->envsectors ? dev->envsectors : 1; sectors = dev->envsectors ? dev->envsectors : 1;
buf = data; buf = data;
while (count > 0) { while (count > 0) {
int blockcount;
erase.start = start; erase.start = start;
skip = is_nand_badblock(dev, start); skip = is_nand_badblock(dev, start);
@ -791,26 +789,17 @@ static int mtdwrite(struct uboot_flash_env *dev, void *data)
ret =-EIO; ret =-EIO;
goto devwrite_out; goto devwrite_out;
} }
if (lseek(dev->fd, start, SEEK_SET) < 0) {
blockcount = blocksize; ret =-EIO;
goto devwrite_out;
/* writesize can be different than the sector size. */ }
if (write(dev->fd, buf, blocksize) != blocksize) {
while (blockcount > 0) { ret =-EIO;
if (lseek(dev->fd, start, SEEK_SET) < 0) { goto devwrite_out;
ret =-EIO;
goto devwrite_out;
}
if (write(dev->fd, buf, dev->mtdinfo.writesize) != dev->mtdinfo.writesize) {
ret =-EIO;
goto devwrite_out;
}
blockcount -= dev->mtdinfo.writesize;
start += dev->mtdinfo.writesize;
buf += dev->mtdinfo.writesize;
} }
MTDLOCK(dev, &erase); MTDLOCK(dev, &erase);
start += dev->sectorsize;
buf += blocksize;
count -= blocksize; count -= blocksize;
ret += blocksize; ret += blocksize;
} }

Loading…
Cancel
Save