]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
env: sf: fix environment in SPI NOR
authorHeiko Schocher <hs@denx.de>
Fri, 18 Jan 2019 09:45:56 +0000 (10:45 +0100)
committerTom Rini <trini@konsulko.com>
Fri, 18 Jan 2019 18:40:36 +0000 (13:40 -0500)
commit 9a9d66f5eff0 ("env: add spi_flash_read_env function")

breaks Environment functionality, as it reads only
until 2 \0 are found, but fills the buffer with 0x0
instead 0xff which leads in an incorrect crc sum.

Fix: init the read buffer with 0xff instead 0x00

Signed-off-by: Heiko Schocher <hs@denx.de>
env/sf.c

index b3dec82c353afea75ef183145c689b34560445e2..31dd00357521d97d0c8819db918d356c5c60d778 100644 (file)
--- a/env/sf.c
+++ b/env/sf.c
@@ -98,7 +98,7 @@ static int spi_flash_read_env(struct spi_flash *flash, u32 offset, size_t len,
        u32 addr = 0;
        u32 page_size = flash->page_size;
 
-       memset(buf, 0x0, len);
+       memset(buf, 0xff, len);
        for (int i = 0; i < len / page_size; ++i) {
                int ret = spi_flash_read(flash, offset, page_size,
                                         &((char *)buf)[addr]);