fix flash_sect_erase() to display correct message
PATCH 1/1 fix flash_sect_erase() to display correct message
flash_sect_erase() displays message "Erased #N sectors" even when there are some protected sectors found and command "erase" fail.
--- common/cmd_flash.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
common/cmd_flash.c +4 -1
@@ -451,7 +451,10 @@ int flash_sect_erase (ulong addr_first, ulong addr_last) rcode =flash_erase (info, s_first[bank], s_last[bank]); } } -printf ("Erased %d sectors\n" , erased); +if (rcode ==ERR_PROTECTED ) +printf ("Not erased - protected sector(s) found\n" ); +else +printf ("Erased %d sectors\n" , erased); }else if (rcode ==0 ) {puts ("Error: start and/or end address" " not on sector boundary\n" );
Signature · 9 lines
1.6.2.5 ------- Seunghyeon Rhee, Ph.D. / Director LPM Technology Inc. T +82-70-8255-6007 F +82-2-6442-6462 M +82-10-2790-0657
PATCH 1/1 fix flash_sect_erase() to display correct message
Quoted 2 lines · On Friday 13 November 2009 09:06:32 ??? wrote:
flash_sect_erase()displays message "Erased #N sectors" even when there are some protected sectors found and command "erase" fail.
Applied to u-boot-cfi-flash/master. Thanks.
Cheers,
Stefan
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de
PATCH 1/1 fix flash_sect_erase() to display correct message
Dear Stefan Roese,
Quoted 4 lines · In message <[email protected]> you wrote:
Quoted 2 lines
flash_sect_erase()displays message "Erased #N sectors" even when there are some protected sectors found and command "erase" fail.Applied to u-boot-cfi-flash/master. Thanks.
Sory, but you were too fast for me. Please put this commit on hold.
Best regards,
Wolfgang Denk
Signature · 5 lines
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
You get a wonderful view from the point of no return.
- Terry Pratchett, _Making_Money_PATCH 1/1 fix flash_sect_erase() to display correct message
Hi Wolfgang,
Quoted 6 lines · On Tuesday 17 November 2009 22:22:23 Wolfgang Denk wrote:
Quoted 4 lines
Quoted 2 lines
flash_sect_erase()displays message "Erased #N sectors" even when there are some protected sectors found and command "erase" fail.Applied to u-boot-cfi-flash/master. Thanks.
Sory, but you were too fast for me. Please put this commit on hold.
Yes, removed from master again.
Cheers,
Stefan
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de
PATCH 1/1 fix flash_sect_erase() to display correct message
In reply to 이승현Dear =?UTF-8?B?7J207Iq57ZiE?=,
Quoted 14 lines · In message <[email protected]> you…
flash_sect_erase()displays message "Erased #N sectors" even when there are some protected sectors found and command "erase" fail.Signed-off-by Seunghyeon Rhee <[email protected]>--- common/cmd_flash.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)common/cmd_flash.c +0
-0@@ -451,7 +451,10 @@ int flash_sect_erase (ulong addr_first, ulong addr_last) rcode =flash_erase (info, s_first[bank], s_last[bank]);
common/cmd_flash.c int flash_sect_erase (ulong addr_first, ulong addr_last) · line 460
Quoted 10 lines
common/cmd_flash.c +4
-1} } -printf ("Erased %d sectors\n" , erased); +if (rcode ==ERR_PROTECTED ) +printf ("Not erased - protected sector(s) found\n" ); +else +printf ("Erased %d sectors\n" , erased); }else if (rcode ==0 ) {puts ("Error: start and/or end address" " not on sector boundary\n" );
I think this patch is not an improvement. Now it prints "Not erased" even when sectors _have_ successfully been earased, which is at least as wrong als the old behaviour.
Just to see what we are talking about:
Preparation:
============
=> fli 2
Bank # 2: CFI conformant FLASH (32 x 16) Size: 4 MB in 35 Sectors
AMD Standard command set, Manufacturer ID: 0x04, Device ID: 0x2249 Erase timeout: 16384 ms, write timeout: 1 ms
Sector Start Addresses:
40400000 40408000 4040C000 40410000 40420000 40440000 40460000 40480000 404A0000 404C0000 404E0000 40500000 40520000 40540000 40560000 40580000 405A0000 405C0000 405E0000 40600000 40620000 40640000 40660000 40680000 406A0000 406C0000 406E0000 40700000 40720000 40740000 40760000 40780000 407A0000 407C0000 407E0000
=> protect on 2:2-4
Protect Flash Sectors 2-4 in Bank # 2
=> fli 2
Bank # 2: CFI conformant FLASH (32 x 16) Size: 4 MB in 35 Sectors
AMD Standard command set, Manufacturer ID: 0x04, Device ID: 0x2249 Erase timeout: 16384 ms, write timeout: 1 ms
Sector Start Addresses:
40400000 40408000 4040C000 RO 40410000 RO 40420000 RO 40440000 40460000 40480000 404A0000 404C0000 404E0000 40500000 40520000 40540000 40560000 40580000 405A0000 405C0000 405E0000 40600000 40620000 40640000 40660000 40680000 406A0000 406C0000 406E0000 40700000 40720000 40740000 40760000 40780000 407A0000 407C0000 407E0000
Case 1:
=======
=> erase 40400000 4047FFFF
- Warning: 3 protected sectors will not be erased! .... done
Erased 7 sectors
Case 2:
=======
=> erase 40400000 +7FFFF
- Warning: 3 protected sectors will not be erased! .... done
Erased 7 sectors
Case 3:
=======
=> erase 2:0-6
Erase Flash Sectors 0-6 in Bank # 2 - Warning: 3 protected sectors will not be erased! .... done
Case 4:
=======
=> erase bank 2
Erase Flash Bank # 2 - Warning: 3 protected sectors will not be erased! ................................ done
As you can see, we _always_ print a warning message.
You can argument that it is incorrect to print "Erased 7 sectors" in cases 1 and 2, as actually only 7 - 3 = 4 have been erased, but printing "Not erased" would definitely be worse.
If you want, and if you can find a clean way to implement it, it might make sense to change the output into something like "Erased 4 (instead of 7 requested) sectors" or the like.
NAK for the patch as is.
Best regards,
Wolfgang Denk
Signature · 8 lines
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
The manager will be continually amazed that policies he took for com-
mon knowledge are totally unknown by some member of his team. Since
his fundamental job is to keep everybody going in the same direction,
his chief daily task will be communication, not decision-making.
- Fred Brooks, "The Mythical Man Month"PATCH 1/1 fix flash_sect_erase() to display correct message
Dear Wolfgang Denk,
Quoted 98 lines · Wolfgang Denk
Dear =?UTF-8?B?7J207Iq57ZiE?=,
Quoted 15 lines · In message <[email protected]> you…
flash_sect_erase()displays message "Erased #N sectors" even when there are some protected sectors found and command "erase" fail.Signed-off-by Seunghyeon Rhee <[email protected]>--- common/cmd_flash.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)common/cmd_flash.c +0
-0@@ -451,7 +451,10 @@ int flash_sect_erase (ulong addr_first, ulong addr_last) rcode =flash_erase (info, s_first[bank], s_last[bank]);common/cmd_flash.c int flash_sect_erase (ulong addr_first, ulong addr_last) · line 460
Quoted 10 lines
common/cmd_flash.c +4
-1} } -printf ("Erased %d sectors\n" , erased); +if (rcode ==ERR_PROTECTED ) +printf ("Not erased - protected sector(s) found\n" ); +else +printf ("Erased %d sectors\n" , erased); }else if (rcode ==0 ) {puts ("Error: start and/or end address" " not on sector boundary\n" );I think this patch is not an improvement. Now it prints "Not erased" even when sectors _have_ successfully been earased, which is at least as wrong als the old behaviour.
Just to see what we are talking about:
Preparation:
=============> fli 2
Bank # 2: CFI conformant FLASH (32 x 16) Size: 4 MB in 35 Sectors
AMD Standard command set, Manufacturer ID:0x04, Device ID:0x2249Erase timeout: 16384 ms, write timeout: 1 msSector Start Addresses:
40400000 40408000 4040C000 40410000 40420000 40440000 40460000 40480000 404A0000 404C0000 404E0000 40500000 40520000 40540000 40560000 40580000 405A0000 405C0000 405E0000 40600000 40620000 40640000 40660000 40680000 406A0000 406C0000 406E0000 40700000 40720000 40740000 40760000 40780000 407A0000 407C0000 407E0000=> protect on 2:2-4
Protect Flash Sectors 2-4 in Bank # 2
=> fli 2Bank # 2: CFI conformant FLASH (32 x 16) Size: 4 MB in 35 Sectors
AMD Standard command set, Manufacturer ID:0x04, Device ID:0x2249Erase timeout: 16384 ms, write timeout: 1 msSector Start Addresses:
40400000 40408000 4040C000 RO 40410000 RO 40420000 RO 40440000 40460000 40480000 404A0000 404C0000 404E0000 40500000 40520000 40540000 40560000 40580000 405A0000 405C0000 405E0000 40600000 40620000 40640000 40660000 40680000 406A0000 406C0000 406E0000 40700000 40720000 40740000 40760000 40780000 407A0000 407C0000 407E0000Case 1:
========> erase 40400000 4047FFFF
- Warning: 3 protected sectors will not be erased! .... done
Erased 7 sectorsCase 2:
========> erase 40400000 +7FFFF
- Warning: 3 protected sectors will not be erased! .... done
Erased 7 sectorsCase 3:
========> erase 2:0-6
Erase Flash Sectors 0-6 in Bank # 2 - Warning: 3 protected sectors will not be erased! .... doneCase 4:
=======
Quoted 7 lines
=> erase bank 2
Erase Flash Bank # 2 - Warning: 3 protected sectors will not be erased! ................................ doneAs you can see, we _always_ print a warning message.
Actually, we usually print the warning message but not _always_. That depends on the flash implementation (*flash.c) of each board. At least 20 implementations currently do nothing and return with ERR_PROTECTED if they found any protected sectors. I was porting U-Boot to my board and found the artifact. Unfortunately (or fortunately in some respect), I chose smdk2410's flash.c as a template which belongs to the _irregular_ case.
Quoted 8 lines
You can argument that it is incorrect to print "Erased 7 sectors" in cases 1 and 2, as actually only 7 - 3 = 4 have been erased, but printing "Not erased" would definitely be worse.
If you want, and if you can find a clean way to implement it, it might make sense to change the output into something like "Erased 4 (instead of 7 requested) sectors" or the like.
I think we need to first make all of them consistent. My suggestion is:
- display a warning message in flash_erase() that there are some protected sectors and erase unprotected sectors like now.
- remove the number indicating how manny sectors are erased from the message in flash_sect_erase() or any caller of flash_erase(). A simple message like "done" would be enough.
Quoted 3 lines
NAK for the patch as is.
Agree, of course.
Quoted 6 lines
Best regards,
Wolfgang Denk
Best regards,
Seunghyeon Rhee
PATCH 1/1 fix flash_sect_erase() to display correct message
Dear =?UTF-8?B?IlNldW5naHllb24gUmhlZSAo7J207Iq57ZiEKSI=?=,
Quoted 4 lines · In message <[email protected]> you wrote:
Quoted 4 lines
I think this patch is not an improvement. Now it prints "Not erased" even when sectors _have_ successfully been earased, which is at least as wrong als the old behaviour.
...
Quoted 4 lines
Quoted 2 lines
As you can see, we _always_ print a warning message.
Actually, we usually print the warning message but not _always_. That depends on the flash implementation (*flash.c) of each board.
Ah! So you are talking about a custom flash driver.
Quoted 2 lines
At least 20 implementations currently do nothing and return with
ERR_PROTECTEDif they found any protected sectors. I was porting U-Boot
Well, in this case we should consider this flash driver incomplete or broken and fix that one first.
Quoted 3 lines
to my board and found the artifact. Unfortunately (or fortunately in some respect), I chose smdk2410's
flash.cas a template which belongs to the _irregular_ case.
So I suggest you dump your copy of that driver code, and use the CFI driver instead - it seems the smdk2410 flash driver supports only CFI conformant flashes anyway, so it could/should be removed.
Quoted 5 lines
Quoted 4 lines
If you want, and if you can find a clean way to implement it, it might make sense to change the output into something like "Erased 4 (instead of 7 requested) sectors" or the like.
I think we need to first make all of them consistent. My suggestion is:
OK, then please start by removing obsolete and redundant driver code and use the CFI driver wherever possible.
Quoted 2 lines
- display a warning message in
flash_erase()that there are some protected sectors and erase unprotected sectors like now.
OK.
Quoted 3 lines
- remove the number indicating how manny sectors are erased from the message in
flash_sect_erase()or any caller offlash_erase(). A simple message like "done" would be enough.
I disagree. I find the number of erased sectors a pretty useful information (for example when it comes to calculate ease timings).
Best regards,
Wolfgang Denk
Signature · 5 lines
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 Alles Gescheite ist schon gedacht worden, man mu? nur versuchen, es noch einmal zu denken. -- Goethe, Maximen und Reflexionen