* [U-Boot] [PATCH 1/2] cfi: Check for blank before erase
@ 2012-08-17 20:36 Joe Hershberger
2012-08-17 20:36 ` [U-Boot] [PATCH 2/2] cfi: Make the flash erase and write operations abortable Joe Hershberger
2012-09-03 9:34 ` [U-Boot] [PATCH 1/2] cfi: Check for blank before erase Stefan Roese
0 siblings, 2 replies; 4+ messages in thread
From: Joe Hershberger @ 2012-08-17 20:36 UTC (permalink / raw)
To: u-boot
Added an optional check in the CFI driver to evaluate if the sector is
already blank before issuing an erase command. Improves erase time by
over a factor of 10 if already blank.
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
---
drivers/mtd/cfi_flash.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index f0f301a..97a4fd7 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -1078,6 +1078,32 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
for (sect = s_first; sect <= s_last; sect++) {
if (info->protect[sect] == 0) { /* not protected */
+#ifdef CONFIG_SYS_FLASH_CHECK_BLANK_BEFORE_ERASE
+ int k;
+ int size;
+ int erased;
+ u32 *flash;
+
+ /*
+ * Check if whole sector is erased
+ */
+ size = flash_sector_size(info, sect);
+ erased = 1;
+ flash = (u32 *)info->start[sect];
+ /* divide by 4 for longword access */
+ size = size >> 2;
+ for (k = 0; k < size; k++) {
+ if (flash_read32(flash++) != 0xffffffff) {
+ erased = 0;
+ break;
+ }
+ }
+ if (erased) {
+ if (flash_verbose)
+ putc(',');
+ continue;
+ }
+#endif
switch (info->vendor) {
case CFI_CMDSET_INTEL_PROG_REGIONS:
case CFI_CMDSET_INTEL_STANDARD:
--
1.7.11.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH 2/2] cfi: Make the flash erase and write operations abortable
2012-08-17 20:36 [U-Boot] [PATCH 1/2] cfi: Check for blank before erase Joe Hershberger
@ 2012-08-17 20:36 ` Joe Hershberger
2012-09-03 9:35 ` Stefan Roese
2012-09-03 9:34 ` [U-Boot] [PATCH 1/2] cfi: Check for blank before erase Stefan Roese
1 sibling, 1 reply; 4+ messages in thread
From: Joe Hershberger @ 2012-08-17 20:36 UTC (permalink / raw)
To: u-boot
Check for ctrlc() in operations that take time and loop over the flash
addresses.
In netconsole, tstc() is expensive. Only check once in a while to not
slow down the operation significantly.
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
---
common/cmd_flash.c | 3 ++-
common/flash.c | 3 +++
drivers/mtd/cfi_flash.c | 11 +++++++++++
include/flash.h | 1 +
4 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/common/cmd_flash.c b/common/cmd_flash.c
index 0e9b2e3..e55d366 100644
--- a/common/cmd_flash.c
+++ b/common/cmd_flash.c
@@ -443,7 +443,8 @@ 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 == 0)
+ printf("Erased %d sectors\n", erased);
} else if (rcode == 0) {
puts ("Error: start and/or end address"
" not on sector boundary\n");
diff --git a/common/flash.c b/common/flash.c
index 781cb9c..8244ba2 100644
--- a/common/flash.c
+++ b/common/flash.c
@@ -221,6 +221,9 @@ void flash_perror (int err)
case ERR_PROG_ERROR:
puts ("General Flash Programming Error\n");
break;
+ case ERR_ABORTED:
+ puts("Flash Programming Aborted\n");
+ break;
default:
printf ("%s[%d] FIXME: rc=%d\n", __FILE__, __LINE__, err);
break;
diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 97a4fd7..43140f3 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -1077,6 +1077,11 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
for (sect = s_first; sect <= s_last; sect++) {
+ if (ctrlc()) {
+ printf("\n");
+ return 1;
+ }
+
if (info->protect[sect] == 0) { /* not protected */
#ifdef CONFIG_SYS_FLASH_CHECK_BLANK_BEFORE_ERASE
int k;
@@ -1379,6 +1384,9 @@ int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
src += i;
cnt -= i;
FLASH_SHOW_PROGRESS(scale, dots, digit, i);
+ /* Only check every once in a while */
+ if ((cnt & 0xFFFF) < buffered_size && ctrlc())
+ return ERR_ABORTED;
}
#else
while (cnt >= info->portwidth) {
@@ -1391,6 +1399,9 @@ int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
wp += info->portwidth;
cnt -= info->portwidth;
FLASH_SHOW_PROGRESS(scale, dots, digit, info->portwidth);
+ /* Only check every once in a while */
+ if ((cnt & 0xFFFF) < info->portwidth && ctrlc())
+ return ERR_ABORTED;
}
#endif /* CONFIG_SYS_FLASH_USE_BUFFER_WRITE */
diff --git a/include/flash.h b/include/flash.h
index e614d07..6d70bdd 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -141,6 +141,7 @@ extern flash_info_t *flash_get_info(ulong base);
#define ERR_UNKNOWN_FLASH_VENDOR 32
#define ERR_UNKNOWN_FLASH_TYPE 64
#define ERR_PROG_ERROR 128
+#define ERR_ABORTED 256
/*-----------------------------------------------------------------------
* Protection Flags for flash_protect():
--
1.7.11.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH 1/2] cfi: Check for blank before erase
2012-08-17 20:36 [U-Boot] [PATCH 1/2] cfi: Check for blank before erase Joe Hershberger
2012-08-17 20:36 ` [U-Boot] [PATCH 2/2] cfi: Make the flash erase and write operations abortable Joe Hershberger
@ 2012-09-03 9:34 ` Stefan Roese
1 sibling, 0 replies; 4+ messages in thread
From: Stefan Roese @ 2012-09-03 9:34 UTC (permalink / raw)
To: u-boot
On 08/17/2012 10:36 PM, Joe Hershberger wrote:
> Added an optional check in the CFI driver to evaluate if the sector is
> already blank before issuing an erase command. Improves erase time by
> over a factor of 10 if already blank.
>
> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Applied to u-boot-cfi-flash/master.
Thanks,
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH 2/2] cfi: Make the flash erase and write operations abortable
2012-08-17 20:36 ` [U-Boot] [PATCH 2/2] cfi: Make the flash erase and write operations abortable Joe Hershberger
@ 2012-09-03 9:35 ` Stefan Roese
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Roese @ 2012-09-03 9:35 UTC (permalink / raw)
To: u-boot
On 08/17/2012 10:36 PM, Joe Hershberger wrote:
> Check for ctrlc() in operations that take time and loop over the flash
> addresses.
>
> In netconsole, tstc() is expensive. Only check once in a while to not
> slow down the operation significantly.
>
> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Applied to u-boot-cfi-flash/master.
Thanks,
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-09-03 9:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-17 20:36 [U-Boot] [PATCH 1/2] cfi: Check for blank before erase Joe Hershberger
2012-08-17 20:36 ` [U-Boot] [PATCH 2/2] cfi: Make the flash erase and write operations abortable Joe Hershberger
2012-09-03 9:35 ` Stefan Roese
2012-09-03 9:34 ` [U-Boot] [PATCH 1/2] cfi: Check for blank before erase Stefan Roese
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.