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 <[email protected]>
---
 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) {
-- 
1.7.1


_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to