blacklisting and ignorelisting opcodes is just not enough. this patch does not introduce the most outstand failure injection ever, but it certainly helped me testing the other patch. maybe we want to make similar failures user configurable?
Signed-off-by: Stefan Tauner stefan.tauner@student.tuwien.ac.at --- dummyflasher.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/dummyflasher.c b/dummyflasher.c index 66d0df0..5a51d1c 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -493,6 +493,7 @@ static int emulate_spi_chip_response(unsigned int writecnt, { unsigned int offs, i, toread; static int unsigned aai_offs; + static int num_read = 0;
if (writecnt == 0) { msg_perr("No command sent to the chip!\n"); @@ -587,6 +588,13 @@ static int emulate_spi_chip_response(unsigned int writecnt, offs = writearr[1] << 16 | writearr[2] << 8 | writearr[3]; /* Truncate to emu_chip_size. */ offs %= emu_chip_size; + if(offs==(emu_chip_size/8)){ + num_read++; + if(num_read >= 4){ // verify will fail iff there has been at least one erase retry + memset(readarr, 0x13, readcnt); + break; + } + } if (readcnt > 0) memcpy(readarr, flashchip_contents + offs, readcnt); break; @@ -602,6 +610,10 @@ static int emulate_spi_chip_response(unsigned int writecnt, msg_perr("Max BYTE PROGRAM size exceeded!\n"); return 1; } + if(offs==(emu_chip_size/4)){ // will be detected at verification + memset(flashchip_contents + offs, 0x14, writecnt - 4); + break; + } memcpy(flashchip_contents + offs, writearr + 4, writecnt - 4); break; case JEDEC_AAI_WORD_PROGRAM: @@ -659,6 +671,9 @@ static int emulate_spi_chip_response(unsigned int writecnt, if (offs & (emu_jedec_se_size - 1)) msg_pdbg("Unaligned SECTOR ERASE 0x20: 0x%x\n", offs); offs &= ~(emu_jedec_se_size - 1); + if(offs==(emu_chip_size/2)){ // this will be detected early (iff block needs an erase) + break; + } memset(flashchip_contents + offs, 0xff, emu_jedec_se_size); break; case JEDEC_BE_52: