* [U-Boot-Users] [PATCH] Fix NAND erase progress error
@ 2008-05-16 18:39 Hugo Villeneuve
2008-05-16 19:40 ` Scott Wood
0 siblings, 1 reply; 12+ messages in thread
From: Hugo Villeneuve @ 2008-05-16 18:39 UTC (permalink / raw)
To: u-boot
This patch fixes an error when reporting the NAND erase
progress as in this example:
U-Boot > nand erase 0000 800
NAND erase: device 0 offset 0x0, size 0x800
Erasing at 0x0 -- 6400% complete.
Signed-off-by: Hugo Villeneuve <hugo.villeneuve@lyrtech.com>
---
drivers/mtd/nand/nand_util.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/nand/nand_util.c b/drivers/mtd/nand/nand_util.c
index 6c5624a..bd21e04 100644
--- a/drivers/mtd/nand/nand_util.c
+++ b/drivers/mtd/nand/nand_util.c
@@ -209,10 +209,15 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
}
if (!opts->quiet) {
- unsigned long long n =(unsigned long long)
- (erase.addr + meminfo->erasesize - opts->offset)
- * 100;
+ unsigned long long n;
int percent;
+ size_t erased_size = erase.addr - opts->offset + meminfo->erasesize;
+
+ if (erased_size > erase_length) {
+ erased_size = erase_length;
+ }
+
+ n = (unsigned long long) erased_size * 100;
do_div(n, erase_length);
percent = (int)n;
^ permalink raw reply related [flat|nested] 12+ messages in thread* [U-Boot-Users] [PATCH] Fix NAND erase progress error
2008-05-16 18:39 [U-Boot-Users] [PATCH] Fix NAND erase progress error Hugo Villeneuve
@ 2008-05-16 19:40 ` Scott Wood
2008-05-16 20:15 ` Hugo Villeneuve
0 siblings, 1 reply; 12+ messages in thread
From: Scott Wood @ 2008-05-16 19:40 UTC (permalink / raw)
To: u-boot
On Fri, May 16, 2008 at 02:39:17PM -0400, Hugo Villeneuve wrote:
> This patch fixes an error when reporting the NAND erase
> progress as in this example:
> U-Boot > nand erase 0000 800
> NAND erase: device 0 offset 0x0, size 0x800
> Erasing at 0x0 -- 6400% complete.
So the problem is when trying to erase less than an erase block boundary?
That should be an error.
The mtd-2.6.22.1 branch emits a warning and increases the length to be
erased if it's less than one block, but that's still wrong as it won't deal
with unaligned lengths that are greater than one blocksize, and more
importantly because it's rather dangerous to erase more than was asked for
without the user having the ability to stop it after the warning is printed.
-Scott
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot-Users] [PATCH] Fix NAND erase progress error
2008-05-16 19:40 ` Scott Wood
@ 2008-05-16 20:15 ` Hugo Villeneuve
2008-05-16 20:18 ` Scott Wood
0 siblings, 1 reply; 12+ messages in thread
From: Hugo Villeneuve @ 2008-05-16 20:15 UTC (permalink / raw)
To: u-boot
Scott Wood wrote:
> On Fri, May 16, 2008 at 02:39:17PM -0400, Hugo Villeneuve wrote:
>> This patch fixes an error when reporting the NAND erase progress as
>> in this example: U-Boot > nand erase 0000 800
>> NAND erase: device 0 offset 0x0, size 0x800
>> Erasing at 0x0 -- 6400% complete.
>
> So the problem is when trying to erase less than an erase block
> boundary?
The problem seems to be present if the requested erase size is not an
exact multiple of the block size.
> That should be an error.
What should be an error, the fact that 6400% is displayed, or the fact
that the user is trying to erase less than a block? :)
> The mtd-2.6.22.1 branch emits a warning and increases the length to
> be erased if it's less than one block, but that's still wrong as it
> won't deal with unaligned lengths that are greater than one
> blocksize, and more importantly because it's rather dangerous to
> erase more than was asked for without the user having the ability to
> stop it after the warning is printed.
Here are other examples:
---
U-Boot > nand erase 100000 00800
NAND erase: device 0 offset 0x100000, size 0x800
Erasing at 0x100000 -- 6400% complete.
OK
U-Boot > nand erase 100000 20000
NAND erase: device 0 offset 0x100000, size 0x20000
Erasing at 0x100000 -- 100% complete.
OK
U-Boot > nand erase 100000 40000
NAND erase: device 0 offset 0x100000, size 0x40000
Erasing at 0x120000 -- 100% complete.
OK
U-Boot > nand erase 100000 40800
NAND erase: device 0 offset 0x100000, size 0x40800
Erasing at 0x140000 -- 148% complete.
OK
---
Hugo Villeneuve
Hardware developer | Concepteur mat?riel
Lyrtech
Phone/T?l. : (1) (418) 877-4644 #2395
Toll-free/Sans frais - Canada & USA : (1) (888) 922-4644 #2395
Fax/T?l?c. : (1) (418) 877-7710
www.lyrtech.com
Infinite possibilities...TM
THIS MESSAGE AND ALL ATTACHED DOCUMENTS ARE EXCLUSIVELY INTENDED
TO THE INDICATED RECIPIENTS AND ITS CONTENTS MAY BE CONFIDENTIAL.
IT IS STRICTLY FORBIDDEN TO ANYONE TO TAKE COGNIZANCE, USE, OR
DIVULGE THE INFORMATION CONTAINED HEREIN. IF YOU MISTAKENLY
RECEIVE THIS MESSAGE, IMMEDIATELY INFORM LYRTECH AND DESTROY THE
MESSAGE AND ATTACHMENTS FORTHWITH.THANK YOU.
LE PRESENT MESSAGE ET LES DOCUMENTS QUI Y SONT JOINTS S'ADRESSENT
EXCLUSIVEMENT AU(X)DESTINATAIRE(S) INDIQUE(S) ET LEUR TENEUR PEUT
ETRE CONFIDENTIELLE. IL EST STRICTEMENT INTERDIT A QUICONQUE D'EN
PRENDRE CONNAISSANCE, DE LES UTILISER OU DE LES DIVULGUER. SI
VOUS RECEVEZ LE PRESENT MESSAGE PAR ERREUR, VEUILLEZ EN AVISER
LYRTECH IMMEDIATEMENT ET DETRUIRE LE MESSAGE SEANCE TENANTE,
AINSI QUE LES DOCUMENTS QUI Y SONT JOINTS.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot-Users] [PATCH] Fix NAND erase progress error
2008-05-16 20:15 ` Hugo Villeneuve
@ 2008-05-16 20:18 ` Scott Wood
2008-05-16 20:29 ` Hugo Villeneuve
0 siblings, 1 reply; 12+ messages in thread
From: Scott Wood @ 2008-05-16 20:18 UTC (permalink / raw)
To: u-boot
Hugo Villeneuve wrote:
> Scott Wood wrote:
>> That should be an error.
>
> What should be an error, the fact that 6400% is displayed, or the fact
> that the user is trying to erase less than a block? :)
The latter. It should tell the user what the erase block size is, and
abort.
-Scott
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot-Users] [PATCH] Fix NAND erase progress error
2008-05-16 20:18 ` Scott Wood
@ 2008-05-16 20:29 ` Hugo Villeneuve
2008-05-16 20:34 ` Scott Wood
0 siblings, 1 reply; 12+ messages in thread
From: Hugo Villeneuve @ 2008-05-16 20:29 UTC (permalink / raw)
To: u-boot
Scott Wood wrote:
> Hugo Villeneuve wrote:
>> Scott Wood wrote:
>>> That should be an error.
>>
>> What should be an error, the fact that 6400% is displayed, or the
>> fact that the user is trying to erase less than a block? :)
>
> The latter. It should tell the user what the erase block size is, and
> abort.
>
> -Scott
I would be perfectly happy if the mtd driver reported a warning when the
requested erase size is not an exact multiple of the block size, and
allow the whole block erase to proceed. Then my patch would make sense.
Right now, there is not even a warning displayed...
Hugo V.
Hugo Villeneuve
Hardware developer | Concepteur mat?riel
Lyrtech
Phone/T?l. : (1) (418) 877-4644 #2395
Toll-free/Sans frais - Canada & USA : (1) (888) 922-4644 #2395
Fax/T?l?c. : (1) (418) 877-7710
www.lyrtech.com
Infinite possibilities...TM
THIS MESSAGE AND ALL ATTACHED DOCUMENTS ARE EXCLUSIVELY INTENDED
TO THE INDICATED RECIPIENTS AND ITS CONTENTS MAY BE CONFIDENTIAL.
IT IS STRICTLY FORBIDDEN TO ANYONE TO TAKE COGNIZANCE, USE, OR
DIVULGE THE INFORMATION CONTAINED HEREIN. IF YOU MISTAKENLY
RECEIVE THIS MESSAGE, IMMEDIATELY INFORM LYRTECH AND DESTROY THE
MESSAGE AND ATTACHMENTS FORTHWITH.THANK YOU.
LE PRESENT MESSAGE ET LES DOCUMENTS QUI Y SONT JOINTS S'ADRESSENT
EXCLUSIVEMENT AU(X)DESTINATAIRE(S) INDIQUE(S) ET LEUR TENEUR PEUT
ETRE CONFIDENTIELLE. IL EST STRICTEMENT INTERDIT A QUICONQUE D'EN
PRENDRE CONNAISSANCE, DE LES UTILISER OU DE LES DIVULGUER. SI
VOUS RECEVEZ LE PRESENT MESSAGE PAR ERREUR, VEUILLEZ EN AVISER
LYRTECH IMMEDIATEMENT ET DETRUIRE LE MESSAGE SEANCE TENANTE,
AINSI QUE LES DOCUMENTS QUI Y SONT JOINTS.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot-Users] [PATCH] Fix NAND erase progress error
2008-05-16 20:29 ` Hugo Villeneuve
@ 2008-05-16 20:34 ` Scott Wood
2008-05-16 20:39 ` Hugo Villeneuve
0 siblings, 1 reply; 12+ messages in thread
From: Scott Wood @ 2008-05-16 20:34 UTC (permalink / raw)
To: u-boot
Hugo Villeneuve wrote:
> I would be perfectly happy if the mtd driver reported a warning when the
> requested erase size is not an exact multiple of the block size, and
> allow the whole block erase to proceed. Then my patch would make sense.
That's what the mtd-2.6.22.1 branch in the NAND repository does. I
think it should reject such requests, though.
-Scott
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot-Users] [PATCH] Fix NAND erase progress error
2008-05-16 20:34 ` Scott Wood
@ 2008-05-16 20:39 ` Hugo Villeneuve
2008-05-16 20:43 ` Scott Wood
0 siblings, 1 reply; 12+ messages in thread
From: Hugo Villeneuve @ 2008-05-16 20:39 UTC (permalink / raw)
To: u-boot
Scott Wood wrote:
> Hugo Villeneuve wrote:
>> I would be perfectly happy if the mtd driver reported a warning when
>> the requested erase size is not an exact multiple of the block size,
>> and allow the whole block erase to proceed. Then my patch would make
>> sense.
>
> That's what the mtd-2.6.22.1 branch in the NAND repository does. I
> think it should reject such requests, though.
I don?t like that behavior. Let?s say that I want to program a new
binary application of 2.8MB. I want to be able to simply erase 2.8MB,
without having to do fancy math computations on my calculator based
on the block size :)
Hugo V.
Hugo Villeneuve
Hardware developer | Concepteur mat?riel
Lyrtech
Phone/T?l. : (1) (418) 877-4644 #2395
Toll-free/Sans frais - Canada & USA : (1) (888) 922-4644 #2395
Fax/T?l?c. : (1) (418) 877-7710
www.lyrtech.com
Infinite possibilities...TM
THIS MESSAGE AND ALL ATTACHED DOCUMENTS ARE EXCLUSIVELY INTENDED
TO THE INDICATED RECIPIENTS AND ITS CONTENTS MAY BE CONFIDENTIAL.
IT IS STRICTLY FORBIDDEN TO ANYONE TO TAKE COGNIZANCE, USE, OR
DIVULGE THE INFORMATION CONTAINED HEREIN. IF YOU MISTAKENLY
RECEIVE THIS MESSAGE, IMMEDIATELY INFORM LYRTECH AND DESTROY THE
MESSAGE AND ATTACHMENTS FORTHWITH.THANK YOU.
LE PRESENT MESSAGE ET LES DOCUMENTS QUI Y SONT JOINTS S'ADRESSENT
EXCLUSIVEMENT AU(X)DESTINATAIRE(S) INDIQUE(S) ET LEUR TENEUR PEUT
ETRE CONFIDENTIELLE. IL EST STRICTEMENT INTERDIT A QUICONQUE D'EN
PRENDRE CONNAISSANCE, DE LES UTILISER OU DE LES DIVULGUER. SI
VOUS RECEVEZ LE PRESENT MESSAGE PAR ERREUR, VEUILLEZ EN AVISER
LYRTECH IMMEDIATEMENT ET DETRUIRE LE MESSAGE SEANCE TENANTE,
AINSI QUE LES DOCUMENTS QUI Y SONT JOINTS.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot-Users] [PATCH] Fix NAND erase progress error
2008-05-16 20:39 ` Hugo Villeneuve
@ 2008-05-16 20:43 ` Scott Wood
2008-05-16 20:51 ` Hugo Villeneuve
0 siblings, 1 reply; 12+ messages in thread
From: Scott Wood @ 2008-05-16 20:43 UTC (permalink / raw)
To: u-boot
Hugo Villeneuve wrote:
> Scott Wood wrote:
>> Hugo Villeneuve wrote:
>>> I would be perfectly happy if the mtd driver reported a warning when
>>> the requested erase size is not an exact multiple of the block size,
>>> and allow the whole block erase to proceed. Then my patch would make
>>> sense.
>> That's what the mtd-2.6.22.1 branch in the NAND repository does. I
>> think it should reject such requests, though.
>
> I don?t like that behavior. Let?s say that I want to program a new
> binary application of 2.8MB. I want to be able to simply erase 2.8MB,
> without having to do fancy math computations on my calculator based
> on the block size :)
Hmm... maybe a flag to request round-up? Or at the very least, have
"help nand" mention the rounding-up behavior.
-Scott
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot-Users] [PATCH] Fix NAND erase progress error
2008-05-16 20:43 ` Scott Wood
@ 2008-05-16 20:51 ` Hugo Villeneuve
2008-05-16 20:54 ` Scott Wood
0 siblings, 1 reply; 12+ messages in thread
From: Hugo Villeneuve @ 2008-05-16 20:51 UTC (permalink / raw)
To: u-boot
Scott Wood wrote:
> Hugo Villeneuve wrote:
>> Scott Wood wrote:
>>> Hugo Villeneuve wrote:
>>>> I would be perfectly happy if the mtd driver reported a warning
>>>> when the requested erase size is not an exact multiple of the
>>>> block size, and allow the whole block erase to proceed. Then my
>>>> patch would make sense.
>>> That's what the mtd-2.6.22.1 branch in the NAND repository does. I
>>> think it should reject such requests, though.
>>
>> I don?t like that behavior. Let?s say that I want to program a new
>> binary application of 2.8MB. I want to be able to simply erase 2.8MB,
>> without having to do fancy math computations on my calculator based
>> on the block size :)
>
> Hmm... maybe a flag to request round-up?
Yes, maybe some kind of "-f" force flag to continue even if the
requested size is less than a block...
> Or at the very least, have
> "help nand" mention the rounding-up behavior.
I agree.
Either way, I think my patch, or a variation of it, should need to be
applied to get rid of that ugly 6400%.
Hugo V.
Hugo Villeneuve
Hardware developer | Concepteur mat?riel
Lyrtech
Phone/T?l. : (1) (418) 877-4644 #2395
Toll-free/Sans frais - Canada & USA : (1) (888) 922-4644 #2395
Fax/T?l?c. : (1) (418) 877-7710
www.lyrtech.com
Infinite possibilities...TM
THIS MESSAGE AND ALL ATTACHED DOCUMENTS ARE EXCLUSIVELY INTENDED
TO THE INDICATED RECIPIENTS AND ITS CONTENTS MAY BE CONFIDENTIAL.
IT IS STRICTLY FORBIDDEN TO ANYONE TO TAKE COGNIZANCE, USE, OR
DIVULGE THE INFORMATION CONTAINED HEREIN. IF YOU MISTAKENLY
RECEIVE THIS MESSAGE, IMMEDIATELY INFORM LYRTECH AND DESTROY THE
MESSAGE AND ATTACHMENTS FORTHWITH.THANK YOU.
LE PRESENT MESSAGE ET LES DOCUMENTS QUI Y SONT JOINTS S'ADRESSENT
EXCLUSIVEMENT AU(X)DESTINATAIRE(S) INDIQUE(S) ET LEUR TENEUR PEUT
ETRE CONFIDENTIELLE. IL EST STRICTEMENT INTERDIT A QUICONQUE D'EN
PRENDRE CONNAISSANCE, DE LES UTILISER OU DE LES DIVULGUER. SI
VOUS RECEVEZ LE PRESENT MESSAGE PAR ERREUR, VEUILLEZ EN AVISER
LYRTECH IMMEDIATEMENT ET DETRUIRE LE MESSAGE SEANCE TENANTE,
AINSI QUE LES DOCUMENTS QUI Y SONT JOINTS.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot-Users] [PATCH] Fix NAND erase progress error
@ 2008-05-16 1:58 Hugo Villeneuve
2008-05-15 22:24 ` Wolfgang Denk
0 siblings, 1 reply; 12+ messages in thread
From: Hugo Villeneuve @ 2008-05-16 1:58 UTC (permalink / raw)
To: u-boot
diff --git a/drivers/mtd/nand/nand_util.c b/drivers/mtd/nand/nand_util.c
index 6c5624a..bd21e04 100644
--- a/drivers/mtd/nand/nand_util.c
+++ b/drivers/mtd/nand/nand_util.c
@@ -209,10 +209,15 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
}
if (!opts->quiet) {
- unsigned long long n =(unsigned long long)
- (erase.addr + meminfo->erasesize - opts->offset)
- * 100;
+ unsigned long long n;
int percent;
+ size_t erased_size = erase.addr - opts->offset + meminfo->erasesize;
+
+ if (erased_size > erase_length) {
+ erased_size = erase_length;
+ }
+
+ n = (unsigned long long) erased_size * 100;
do_div(n, erase_length);
percent = (int)n;
^ permalink raw reply related [flat|nested] 12+ messages in thread* [U-Boot-Users] [PATCH] Fix NAND erase progress error
2008-05-16 1:58 Hugo Villeneuve
@ 2008-05-15 22:24 ` Wolfgang Denk
0 siblings, 0 replies; 12+ messages in thread
From: Wolfgang Denk @ 2008-05-15 22:24 UTC (permalink / raw)
To: u-boot
In message <1210903133-6960-1-git-send-email-hugo.villeneuve@lyrtech.com> you wrote:
> diff --git a/drivers/mtd/nand/nand_util.c b/drivers/mtd/nand/nand_util.c
> index 6c5624a..bd21e04 100644
> --- a/drivers/mtd/nand/nand_util.c
> +++ b/drivers/mtd/nand/nand_util.c
Please describe what the error is, nd add your signed-off-by line.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"What is wanted is not the will to believe, but the will to find out,
which is the exact opposite." - Bertrand Russell, _Sceptical_Essays_,
1928
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2008-05-16 20:54 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-16 18:39 [U-Boot-Users] [PATCH] Fix NAND erase progress error Hugo Villeneuve
2008-05-16 19:40 ` Scott Wood
2008-05-16 20:15 ` Hugo Villeneuve
2008-05-16 20:18 ` Scott Wood
2008-05-16 20:29 ` Hugo Villeneuve
2008-05-16 20:34 ` Scott Wood
2008-05-16 20:39 ` Hugo Villeneuve
2008-05-16 20:43 ` Scott Wood
2008-05-16 20:51 ` Hugo Villeneuve
2008-05-16 20:54 ` Scott Wood
-- strict thread matches above, loose matches on Subject: below --
2008-05-16 1:58 Hugo Villeneuve
2008-05-15 22:24 ` Wolfgang Denk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox