All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] env: sf: fix environment in SPI NOR
@ 2019-01-18  9:45 Heiko Schocher
  2019-01-19  2:54 ` [U-Boot] " Tom Rini
  0 siblings, 1 reply; 4+ messages in thread
From: Heiko Schocher @ 2019-01-18  9:45 UTC (permalink / raw)
  To: u-boot

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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/env/sf.c b/env/sf.c
index b3dec82c35..31dd003575 100644
--- 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]);
-- 
2.17.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] env: sf: fix environment in SPI NOR
  2019-01-18  9:45 [U-Boot] [PATCH] env: sf: fix environment in SPI NOR Heiko Schocher
@ 2019-01-19  2:54 ` Tom Rini
  2019-01-21  9:53   ` Heiko Schocher
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Rini @ 2019-01-19  2:54 UTC (permalink / raw)
  To: u-boot

On Fri, Jan 18, 2019 at 10:45:56AM +0100, Heiko Schocher wrote:

> 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>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190118/2a77eaa6/attachment.sig>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] env: sf: fix environment in SPI NOR
  2019-01-19  2:54 ` [U-Boot] " Tom Rini
@ 2019-01-21  9:53   ` Heiko Schocher
  2019-01-21 15:46     ` Tom Rini
  0 siblings, 1 reply; 4+ messages in thread
From: Heiko Schocher @ 2019-01-21  9:53 UTC (permalink / raw)
  To: u-boot

Hello Tom,

Am 19.01.2019 um 03:54 schrieb Tom Rini:
> On Fri, Jan 18, 2019 at 10:45:56AM +0100, Heiko Schocher wrote:
> 
>> 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>
> 
> Applied to u-boot/master, thanks!

I am sorry, this patch was nonsense. After erasing the flash, and
saving a default Environment, the CONFIG_ENV_SIZE bytes are filled
with 0x00. So the memset with 0x00 should be OK. I have no idea
what gone wrong on my board :-(

I am not sure what gone wrong here, so, please can you revert this
patch?

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] env: sf: fix environment in SPI NOR
  2019-01-21  9:53   ` Heiko Schocher
@ 2019-01-21 15:46     ` Tom Rini
  0 siblings, 0 replies; 4+ messages in thread
From: Tom Rini @ 2019-01-21 15:46 UTC (permalink / raw)
  To: u-boot

On Mon, Jan 21, 2019 at 10:53:12AM +0100, Heiko Schocher wrote:
> Hello Tom,
> 
> Am 19.01.2019 um 03:54 schrieb Tom Rini:
> >On Fri, Jan 18, 2019 at 10:45:56AM +0100, Heiko Schocher wrote:
> >
> >>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>
> >
> >Applied to u-boot/master, thanks!
> 
> I am sorry, this patch was nonsense. After erasing the flash, and
> saving a default Environment, the CONFIG_ENV_SIZE bytes are filled
> with 0x00. So the memset with 0x00 should be OK. I have no idea
> what gone wrong on my board :-(
> 
> I am not sure what gone wrong here, so, please can you revert this
> patch?

OK, thanks!

> 
> bye,
> Heiko
> -- 
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190121/e9ffd9ff/attachment.sig>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-01-21 15:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-18  9:45 [U-Boot] [PATCH] env: sf: fix environment in SPI NOR Heiko Schocher
2019-01-19  2:54 ` [U-Boot] " Tom Rini
2019-01-21  9:53   ` Heiko Schocher
2019-01-21 15:46     ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.