* [Buildroot] [PATCH 1/1] package/libubootenv: backport fix for NOR flashes
@ 2023-07-28 21:29 Brandon Maier via buildroot
2023-07-29 8:55 ` Thomas Petazzoni via buildroot
2023-08-30 19:15 ` Peter Korsgaard
0 siblings, 2 replies; 3+ messages in thread
From: Brandon Maier via buildroot @ 2023-07-28 21:29 UTC (permalink / raw)
To: buildroot; +Cc: Pierre-Jean Texier, Brandon Maier
Fixes a bug present since v0.3.3 that causes extremely slow writes to
NOR flashes.
Signed-off-by: Brandon Maier <brandon.maier@collins.com>
---
...-fix-bug-when-SPI-flash-write-size-s.patch | 70 +++++++++++++++++++
1 file changed, 70 insertions(+)
create mode 100644 package/libubootenv/0002-Revert-fw_setenv-fix-bug-when-SPI-flash-write-size-s.patch
diff --git a/package/libubootenv/0002-Revert-fw_setenv-fix-bug-when-SPI-flash-write-size-s.patch b/package/libubootenv/0002-Revert-fw_setenv-fix-bug-when-SPI-flash-write-size-s.patch
new file mode 100644
index 0000000000..084fd34e61
--- /dev/null
+++ b/package/libubootenv/0002-Revert-fw_setenv-fix-bug-when-SPI-flash-write-size-s.patch
@@ -0,0 +1,70 @@
+From 35bbc4d8155ed86ca7200e060dad98bdfbce684d Mon Sep 17 00:00:00 2001
+From: Stefano Babic <sbabic@denx.de>
+Date: Thu, 15 Jun 2023 16:54:46 +0200
+Subject: [PATCH] Revert "fw_setenv: fix bug when SPI flash write size !=
+ sector size"
+
+This reverts commit 44ecc1c216007272a6f99a104a71c9d410969d9e.
+
+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>
+Upstream: https://github.com/sbabic/libubootenv/commit/9f17a00ee56dc5cfb1d9b51e6639d67b64cb3309
+---
+ src/uboot_env.c | 29 +++++++++--------------------
+ 1 file changed, 9 insertions(+), 20 deletions(-)
+
+diff --git a/src/uboot_env.c b/src/uboot_env.c
+index c5eefe7..76e2619 100644
+--- a/src/uboot_env.c
++++ b/src/uboot_env.c
+@@ -712,8 +712,6 @@ static int mtdwrite(struct uboot_flash_env *dev, void *data)
+ sectors = dev->envsectors ? dev->envsectors : 1;
+ buf = data;
+ while (count > 0) {
+- int blockcount;
+-
+ erase.start = start;
+
+ skip = is_nand_badblock(dev, start);
+@@ -744,26 +742,17 @@ static int mtdwrite(struct uboot_flash_env *dev, void *data)
+ ret =-EIO;
+ goto devwrite_out;
+ }
+-
+- blockcount = blocksize;
+-
+- /* writesize can be different than the sector size. */
+-
+- while (blockcount > 0) {
+- if (lseek(dev->fd, start, SEEK_SET) < 0) {
+- 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;
++ if (lseek(dev->fd, start, SEEK_SET) < 0) {
++ ret =-EIO;
++ goto devwrite_out;
++ }
++ if (write(dev->fd, buf, blocksize) != blocksize) {
++ ret =-EIO;
++ goto devwrite_out;
+ }
+ MTDLOCK(dev, &erase);
++ start += dev->sectorsize;
++ buf += blocksize;
+ count -= blocksize;
+ ret += blocksize;
+ }
+--
+2.41.0
+
--
2.41.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Buildroot] [PATCH 1/1] package/libubootenv: backport fix for NOR flashes
2023-07-28 21:29 [Buildroot] [PATCH 1/1] package/libubootenv: backport fix for NOR flashes Brandon Maier via buildroot
@ 2023-07-29 8:55 ` Thomas Petazzoni via buildroot
2023-08-30 19:15 ` Peter Korsgaard
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Petazzoni via buildroot @ 2023-07-29 8:55 UTC (permalink / raw)
To: Brandon Maier via buildroot; +Cc: Pierre-Jean Texier, Brandon Maier
On Fri, 28 Jul 2023 21:29:52 +0000
Brandon Maier via buildroot <buildroot@buildroot.org> wrote:
> Fixes a bug present since v0.3.3 that causes extremely slow writes to
> NOR flashes.
>
> Signed-off-by: Brandon Maier <brandon.maier@collins.com>
> ---
> ...-fix-bug-when-SPI-flash-write-size-s.patch | 70 +++++++++++++++++++
> 1 file changed, 70 insertions(+)
> create mode 100644 package/libubootenv/0002-Revert-fw_setenv-fix-bug-when-SPI-flash-write-size-s.patch
Applied to master, thanks.
Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Buildroot] [PATCH 1/1] package/libubootenv: backport fix for NOR flashes
2023-07-28 21:29 [Buildroot] [PATCH 1/1] package/libubootenv: backport fix for NOR flashes Brandon Maier via buildroot
2023-07-29 8:55 ` Thomas Petazzoni via buildroot
@ 2023-08-30 19:15 ` Peter Korsgaard
1 sibling, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2023-08-30 19:15 UTC (permalink / raw)
To: Brandon Maier via buildroot; +Cc: Pierre-Jean Texier, Brandon Maier
>>>>> "Brandon" == Brandon Maier via buildroot <buildroot@buildroot.org> writes:
> Fixes a bug present since v0.3.3 that causes extremely slow writes to
> NOR flashes.
> Signed-off-by: Brandon Maier <brandon.maier@collins.com>
Committed to 2023.02.x and 2023.05.x, thanks.
--
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-30 19:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-28 21:29 [Buildroot] [PATCH 1/1] package/libubootenv: backport fix for NOR flashes Brandon Maier via buildroot
2023-07-29 8:55 ` Thomas Petazzoni via buildroot
2023-08-30 19:15 ` Peter Korsgaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).