On Thu, Jul 21, 2011 at 05:54:46PM +0200, Stefan Tauner wrote:
previously the dummies were initialized to be empty (all ones), which makes writes skip erasing altogether. with this patch the default is to fill it with random bytes instead and the old behavior can be enforced with stating "empty=yes" on the command line.
Signed-off-by: Stefan Tauner stefan.tauner@student.tuwien.ac.at
I'd make the programmer options a bit more generic to allow for other content easily and consistently:
-p dummy:content=ff -p dummy:content=00 -p dummy:content=random -p dummy:content=incrementing
etc.
The default should be documented in the manpage.
- empty = extract_programmer_param("empty");
- if (empty != NULL) {
if (strstr(empty, "yes"))
Why not strcasecmp() here?
Uwe.
previously the dummies were initialized to be empty (all ones), which makes writes skip erasing altogether. with this patch the default is to fill it with random bytes instead. additionally one can decide other options with the "content" parameter: content=ones - old behavior content=random - new default content=zeros - filled with 0x00 content=increment - filled with i++
Signed-off-by: Stefan Tauner stefan.tauner@student.tuwien.ac.at --- dummyflasher.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/dummyflasher.c b/dummyflasher.c index fca228c..476f0e6 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -94,6 +94,10 @@ int dummy_init(void) { char *bustext = NULL; char *tmp = NULL; + char *con; + enum {RAND, INC, ZEROS, ONES} sel = RAND; + unsigned int i; + uint8_t inc = 0; #if EMULATE_CHIP struct stat image_stat; #endif @@ -128,6 +132,18 @@ int dummy_init(void) msg_pdbg("Support for all flash bus types disabled.\n"); free(bustext);
+ con = extract_programmer_param("content"); + if (con != NULL) { + msg_pdbg("Requested content is: %s.\n", con); + if (!strcasecmp(con, "zeros")) + sel = ZEROS; + else if (!strcasecmp(con, "ones")) + sel = ONES; + else if (!strcasecmp(con, "increment")) + sel = INC; + free(con); + } + tmp = extract_programmer_param("spi_write_256_chunksize"); if (tmp) { spi_write_256_chunksize = atoi(tmp); @@ -198,8 +214,28 @@ int dummy_init(void) return 1; }
- msg_pdbg("Filling fake flash chip with 0xff, size %i\n", emu_chip_size); - memset(flashchip_contents, 0xff, emu_chip_size); + msg_pdbg("Filling fake flash chip containing %i bytes with ", + emu_chip_size); + switch (sel) { + case ONES: + msg_pdbg("0xff.\n"); + memset(flashchip_contents, 0xff, emu_chip_size); + break; + case ZEROS: + msg_pdbg("0x00.\n"); + memset(flashchip_contents, 0x00, emu_chip_size); + break; + case RAND: + msg_pdbg("random data.\n"); + for (i = 0; i < emu_chip_size; i++) + flashchip_contents[i] = rand(); + break; + case INC: + msg_pdbg("incremented data.\n"); + for (i = 0; i < emu_chip_size; i++) + flashchip_contents[i] = inc++; + break; + }
emu_persistent_image = extract_programmer_param("image"); if (!emu_persistent_image) {