From: Jerry Van Baren <gvb.uboot@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH 1/2 resend] Flash programming progress countdown.
Date: Tue, 18 Mar 2008 21:42:15 -0400 [thread overview]
Message-ID: <47E06F77.3080609@gmail.com> (raw)
Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
---
Hi Stefan,
[This is a resend of a patch sent prior to the merge window opening.
The proposed implementation was discussed extensively. No comments were
received on this latest version of the implementation so it is either OK
or nobody was paying attention at the time. - gvb]
OK, that was a fun way to waste way too much time. :-)
The resulting implementation counts down from n/5 to 1 (9..1, normally):
Copy to Flash... 9....8....7....6....5....4....3....2....1....done
I made it configurable by CONFIG_FLASH_SHOW_PROGRESS which is expected to
be an integer. When jdl completes his mission and we have a kernel-style
Kconfig, I envision an integer configuration with a recommended value
of 45.
I added a description to the README in what seemed to be the logical
place, at the end of the flash configs. If my logic doesn't match your
logic, holler and I'll move it.
Patch 2/2 will be enabling on the MPC8360EMDS board. I don't know how
the community would like to address this, I'm assuming it is best to
let the board maintainers pick this up rather than slamming it into
the boards that have CFI flash (grep says 407 boards).
README | 5 +++++
drivers/mtd/cfi_flash.c | 44
+++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 48 insertions(+), 1 deletions(-)
diff --git a/README b/README
index 491397a..a237829 100644
--- a/README
+++ b/README
@@ -1945,6 +1945,11 @@ Configuration Settings:
is useful, if some of the configured banks are only
optionally available.
+- CONFIG_FLASH_SHOW_PROGRESS
+ If defined (must be an integer), print out countdown
+ digits and dots. Recommended value: 45 (9..1) for 80
+ column displays, 15 (3..1) for 40 column displays.
+
- CFG_RX_ETH_BUFFER:
Defines the number of ethernet receive buffers. On some
ethernet controllers it is recommended to set this value
diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 439c950..9347c35 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -1180,6 +1180,22 @@ void flash_print_info (flash_info_t * info)
}
/*-----------------------------------------------------------------------
+ * This is used in a few places in write_buf() to show programming
+ * progress. Making it a function is nasty because it needs to do side
+ * effect updates to digit and dots. Repeated code is nasty too, so
+ * we define it once here.
+ */
+#define FLASH_SHOW_PROGRESS(scale, dots, digit) \
+ if ((scale > 0) && (dots <= 0)) { \
+ if ((digit % 5) == 0) \
+ printf ("%d", digit / 5); \
+ else \
+ putc ('.'); \
+ digit--; \
+ dots += scale; \
+ }
+
+/*-----------------------------------------------------------------------
* Copy memory to flash, returns:
* 0 - OK
* 1 - write timeout
@@ -1192,10 +1208,23 @@ int write_buff (flash_info_t * info, uchar *
src, ulong addr, ulong cnt)
int aln;
cfiword_t cword;
int i, rc;
-
#ifdef CFG_FLASH_USE_BUFFER_WRITE
int buffered_size;
#endif
+#ifdef CONFIG_FLASH_SHOW_PROGRESS
+ int digit = CONFIG_FLASH_SHOW_PROGRESS;
+ int scale = 0;
+ int dots = 0;
+
+ /*
+ * Suppress if there are fewer than CONFIG_FLASH_SHOW_PROGRESS writes.
+ */
+ if (cnt >= CONFIG_FLASH_SHOW_PROGRESS) {
+ scale = (int)((cnt + CONFIG_FLASH_SHOW_PROGRESS - 1) /
+ CONFIG_FLASH_SHOW_PROGRESS);
+ }
+#endif
+
/* get lower aligned address */
wp = (addr & ~(info->portwidth - 1));
@@ -1219,6 +1248,10 @@ int write_buff (flash_info_t * info, uchar * src,
ulong addr, ulong cnt)
return rc;
wp += i;
+#ifdef CONFIG_FLASH_SHOW_PROGRESS
+ dots -= i;
+ FLASH_SHOW_PROGRESS(scale, dots, digit);
+#endif
}
/* handle the aligned part */
@@ -1248,6 +1281,10 @@ int write_buff (flash_info_t * info, uchar * src,
ulong addr, ulong cnt)
wp += i;
src += i;
cnt -= i;
+#ifdef CONFIG_FLASH_SHOW_PROGRESS
+ dots -= i;
+ FLASH_SHOW_PROGRESS(scale, dots, digit);
+#endif
}
#else
while (cnt >= info->portwidth) {
@@ -1259,8 +1296,13 @@ int write_buff (flash_info_t * info, uchar * src,
ulong addr, ulong cnt)
return rc;
wp += info->portwidth;
cnt -= info->portwidth;
+#ifdef CONFIG_FLASH_SHOW_PROGRESS
+ dots -= info->portwidth;
+ FLASH_SHOW_PROGRESS(scale, dots, digit);
+#endif
}
#endif /* CFG_FLASH_USE_BUFFER_WRITE */
+
if (cnt == 0) {
return (0);
}
--
1.5.4.1
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
U-Boot-Users mailing list
U-Boot-Users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/u-boot-users
reply other threads:[~2008-03-19 1:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47E06F77.3080609@gmail.com \
--to=gvb.uboot@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox